CPPLapack
 All Classes Files Functions Variables Friends Pages
_zhsmatrix-zhsmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! _zhsmatrix+zhsmatrix operator */
3 inline _zhsmatrix operator+(const _zhsmatrix& matA, const zhsmatrix& matB)
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(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.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  zhsmatrix newmat(matA);
15 
16  const std::vector<zcomponent>::const_iterator matB_data_end =matB.data.end();
17  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
18  newmat(it->i,it->j) +=it->v;
19  }
20 
21  return _(newmat);
22 }
23 
24 //=============================================================================
25 /*! _zhsmatrix-zhsmatrix operator */
26 inline _zhsmatrix operator-(const _zhsmatrix& matA, const zhsmatrix& matB)
27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if(matA.n!=matB.n){
30  ERROR_REPORT;
31  std::cerr << "These two matrises can not make a subtraction." << std::endl
32  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  zhsmatrix newmat(matA);
38 
39  const std::vector<zcomponent>::const_iterator matB_data_end =matB.data.end();
40  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
41  newmat(it->i,it->j) -=it->v;
42  }
43 
44  return _(newmat);
45 }
46 
47 //=============================================================================
48 /*! _zhsmatrix*zhsmatrix operator */
49 /*
50 inline _zhsmatrix operator*(const _zhsmatrix& matA, const zhsmatrix& matB)
51 {CPPL_VERBOSE_REPORT;
52 #ifdef CPPL_DEBUG
53  if(matA.n!=matB.m){
54  ERROR_REPORT;
55  std::cerr << "These two matrises can not make a product." << std::endl
56  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
57  exit(1);
58  }
59 #endif//CPPL_DEBUG
60 
61  zhsmatrix newmat( matA.m, matB.n, 0 );
62 
63  for(CPPL_INT c=0; c<matA.vol; c++){
64  CPPL_INT k(matA.jndx[c]);
65  std::vector< std::pair<CPPL_INT,CPPL_INT> >::iterator p;
66  for(p=matB.Col[k].begin(); p!=matB.Col[k].end(); p++){
67  newmat(matA.indx[c],p->first) +=matA.array[c]*matB.array[p->second];
68  }
69  }
70 
71  matA.destroy();
72  return _(newmat);
73 }
74 */
CPPL_INT n
matrix column size
Definition: zhsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: _zhsmatrix.hpp:11
std::vector< zcomponent > data
matrix data
Definition: zhsmatrix.hpp:11
Complex Double-precision Hermitian Sparse Matrix Class.
Definition: zhsmatrix.hpp:3
_zhsmatrix operator-(const _zhsmatrix &matA, const zhsmatrix &matB)
_dcovector _(dcovector &vec)
(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Sparse Matrix Class ...
Definition: _zhsmatrix.hpp:3
_zhsmatrix operator+(const _zhsmatrix &matA, const zhsmatrix &matB)