CPPLapack
 All Classes Files Functions Variables Friends Pages
zhsmatrix-_zhsmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! zhsmatrix=_zhsmatrix operator */
4 {CPPL_VERBOSE_REPORT;
5  shallow_copy(mat);
6  return *this;
7 }
8 
9 ///////////////////////////////////////////////////////////////////////////////
10 ///////////////////////////////////////////////////////////////////////////////
11 ///////////////////////////////////////////////////////////////////////////////
12 
13 //=============================================================================
14 /*! zhsmatrix+=_zhsmatrix operator */
16 {CPPL_VERBOSE_REPORT;
17 #ifdef CPPL_DEBUG
18  if(n!=mat.n){
19  ERROR_REPORT;
20  std::cerr << "These two matrises can not make a summation." << std::endl
21  << "Your input was (" << n << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
22  exit(1);
23  }
24 #endif//CPPL_DEBUG
25 
26  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
27  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
28  (*this)(it->i,it->j) +=it->v;
29  }
30 
31  mat.destroy();
32  return *this;
33 }
34 
35 //=============================================================================
36 /*! zhsmatrix-=_zhsmatrix operator */
38 {CPPL_VERBOSE_REPORT;
39 #ifdef CPPL_DEBUG
40  if(n!=mat.n){
41  ERROR_REPORT;
42  std::cerr << "These two matrises can not make a sutraction." << std::endl
43  << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
44  exit(1);
45  }
46 #endif//CPPL_DEBUG
47 
48  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
49  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
50  (*this)(it->i,it->j) -=it->v;
51  }
52 
53  mat.destroy();
54  return *this;
55 }
56 
57 ///////////////////////////////////////////////////////////////////////////////
58 ///////////////////////////////////////////////////////////////////////////////
59 ///////////////////////////////////////////////////////////////////////////////
60 
61 //=============================================================================
62 /*! zhsmatrix+_zhsmatrix operator */
63 inline _zhsmatrix operator+(const zhsmatrix& matA, const _zhsmatrix& matB)
64 {CPPL_VERBOSE_REPORT;
65 #ifdef CPPL_DEBUG
66  if(matA.n!=matB.n){
67  ERROR_REPORT;
68  std::cerr << "These two matrises can not make a summation." << std::endl
69  << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
70  exit(1);
71  }
72 #endif//CPPL_DEBUG
73 
74  zhsmatrix newmat(matB);
75 
76  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
77  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
78  newmat(it->i,it->j) +=it->v;
79  }
80 
81  return _(newmat);
82 }
83 
84 //=============================================================================
85 /*! zhsmatrix-_zhsmatrix operator */
86 inline _zhsmatrix operator-(const zhsmatrix& matA, const _zhsmatrix& matB)
87 {CPPL_VERBOSE_REPORT;
88 #ifdef CPPL_DEBUG
89  if(matA.n!=matB.n){
90  ERROR_REPORT;
91  std::cerr << "These two matrises can not make a subtraction." << std::endl
92  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
93  exit(1);
94  }
95 #endif//CPPL_DEBUG
96 
97  zhsmatrix newmat(-matB);
98 
99  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
100  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
101  newmat(it->i,it->j) +=it->v;
102  }
103 
104  return _(newmat);
105 }
106 
107 //=============================================================================
108 /*! zhsmatrix*_zhsmatrix operator */
109 /*
110 inline _zgsmatrix operator*(const zhsmatrix& matA, const _zhsmatrix& matB)
111 {CPPL_VERBOSE_REPORT;
112 #ifdef CPPL_DEBUG
113  if(matA.n!=matB.n){
114  ERROR_REPORT;
115  std::cerr << "These two matrises can not make a product." << std::endl
116  << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
117  exit(1);
118  }
119 #endif//CPPL_DEBUG
120 
121  zhsmatrix newmat( matA.n, 0 );
122 
123  for(CPPL_INT c=0; c<matA.vol; c++){
124  CPPL_INT k(matA.jndx[c]);
125  std::vector< std::pair<CPPL_INT,CPPL_INT> >::iterator p;
126  for(p=matB.line[k].begin(); p!=matB.line[k].end(); p++){
127  newmat(matA.indx[c],p->first) +=matA.array[c]*matB.array[p->second];
128  }
129  }
130 
131  matB.destroy();
132  return _(newmat);
133 }
134 */
std::vector< zcomponent > data
matrix data
Definition: _zhsmatrix.hpp:12
zhsmatrix & operator+=(const zhsmatrix &)
zhsmatrix & operator=(const zhsmatrix &)
zhsmatrix & operator-=(const zhsmatrix &)
_zhsmatrix operator-(const zhsmatrix &matA, const _zhsmatrix &matB)
void destroy() const
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
_zhsmatrix operator+(const zhsmatrix &matA, const _zhsmatrix &matB)
Complex Double-precision Hermitian Sparse Matrix Class.
Definition: zhsmatrix.hpp:3
void shallow_copy(const _zhsmatrix &)
_dcovector _(dcovector &vec)
(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Sparse Matrix Class ...
Definition: _zhsmatrix.hpp:3