CPPLapack
 All Classes Files Functions Variables Friends Pages
_zgsmatrix-_zhematrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! _zgsmatrix+_zhematrix operator */
3 inline _zgematrix operator+(const _zgsmatrix& matA, const _zhematrix& matB)
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.n || matA.n!=matB.n){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  zgematrix newmat( matB.to_zgematrix() );
15 
16  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
17  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
18  newmat(it->i,it->j) += it->v;
19  }
20 
21  matA.destroy();
22  matB.destroy();
23  return _(newmat);
24 }
25 
26 //=============================================================================
27 /*! _zgsmatrix-_zhematrix operator */
28 inline _zgematrix operator-(const _zgsmatrix& matA, const _zhematrix& matB)
29 {CPPL_VERBOSE_REPORT;
30 #ifdef CPPL_DEBUG
31  if(matA.m!=matB.n || matA.n!=matB.n){
32  ERROR_REPORT;
33  std::cerr << "These two matrises can not make a subtraction." << std::endl
34  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
35  exit(1);
36  }
37 #endif//CPPL_DEBUG
38 
39  //// shallow copy to zgematrix ////
40  zgematrix newmat( (-matB).to_zgematrix() );
41 
42  //// add ////
43  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
44  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
45  newmat(it->i,it->j) += it->v;
46  }
47 
48  ////////
49  matA.destroy();
50  matB.destroy();
51  return _(newmat);
52 }
53 
54 //=============================================================================
55 /*! _zgsmatrix*_zhematrix operator */
56 inline _zgematrix operator*(const _zgsmatrix& matA, const _zhematrix& matB)
57 {CPPL_VERBOSE_REPORT;
58 #ifdef CPPL_DEBUG
59  if(matA.n!=matB.n){
60  ERROR_REPORT;
61  std::cerr << "These two matrises can not make a product." << std::endl
62  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
63  exit(1);
64  }
65 #endif//CPPL_DEBUG
66 
67  zgematrix newmat(matA.m, matB.n);
68  newmat.zero();
69 
70  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
71  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
72  for(CPPL_INT i=0; i<matB.n; i++){
73  newmat(it->i,i) += it->v*matB(it->j,i);
74  }
75  }
76 
77  matA.destroy();
78  matB.destroy();
79  return _(newmat);
80 }
(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Matrix Class
Definition: _zhematrix.hpp:3
CPPL_INT n
matrix column size
Definition: _zhematrix.hpp:11
_zgematrix operator*(const _zgsmatrix &matA, const _zhematrix &matB)
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
(DO NOT USE) Smart-temporary Real Double-precision General Sparse Matrix Class
Definition: _zgsmatrix.hpp:3
_zgematrix operator+(const _zgsmatrix &matA, const _zhematrix &matB)
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
zgematrix & zero()
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
_zgematrix operator-(const _zgsmatrix &matA, const _zhematrix &matB)
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
void destroy() const
void destroy() const
_zgematrix to_zgematrix() const
_dcovector _(dcovector &vec)
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11