CPPLapack
 All Classes Files Functions Variables Friends Pages
Functions
zgsmatrix-_zgsmatrix.hpp File Reference

Go to the source code of this file.

Functions

_zgsmatrix operator+ (const zgsmatrix &matA, const _zgsmatrix &matB)
 
_zgsmatrix operator- (const zgsmatrix &matA, const _zgsmatrix &matB)
 
_zgsmatrix operator* (const zgsmatrix &matA, const _zgsmatrix &matB)
 

Function Documentation

_zgsmatrix operator+ ( const zgsmatrix matA,
const _zgsmatrix matB 
)
inline

zgsmatrix+_zgsmatrix operator

Definition at line 92 of file zgsmatrix-_zgsmatrix.hpp.

References _(), zgsmatrix::data, _zgsmatrix::m, zgsmatrix::m, zgsmatrix::n, and _zgsmatrix::n.

93 {CPPL_VERBOSE_REPORT;
94 #ifdef CPPL_DEBUG
95  if(matA.n!=matB.n || matA.m!=matB.m){
96  ERROR_REPORT;
97  std::cerr << "These two matrises can not make a summation." << std::endl
98  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
99  exit(1);
100  }
101 #endif//CPPL_DEBUG
102 
103  zgsmatrix newmat(matB);
104 
105  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
106  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
107  newmat(it->i,it->j) += it->v;
108  }
109 
110  return _(newmat);
111 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_dcovector _(dcovector &vec)
_zgsmatrix operator- ( const zgsmatrix matA,
const _zgsmatrix matB 
)
inline

zgsmatrix-_zgsmatrix operator

Definition at line 115 of file zgsmatrix-_zgsmatrix.hpp.

References _(), zgsmatrix::chsign(), zgsmatrix::data, _zgsmatrix::m, zgsmatrix::m, zgsmatrix::n, and _zgsmatrix::n.

116 {CPPL_VERBOSE_REPORT;
117 #ifdef CPPL_DEBUG
118  if(matA.n!=matB.n || matA.m!=matB.m){
119  ERROR_REPORT;
120  std::cerr << "These two matrises can not make a subtraction." << std::endl
121  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
122  exit(1);
123  }
124 #endif//CPPL_DEBUG
125 
126  zgsmatrix newmat(matB);
127  newmat.chsign();
128 
129  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
130  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
131  newmat(it->i,it->j) += it->v;
132  }
133 
134  return _(newmat);
135 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_dcovector _(dcovector &vec)
_zgsmatrix operator* ( const zgsmatrix matA,
const _zgsmatrix matB 
)
inline

zgsmatrix*_zgsmatrix operator

Definition at line 139 of file zgsmatrix-_zgsmatrix.hpp.

References _(), zgsmatrix::data, _zgsmatrix::data, _zgsmatrix::destroy(), _zgsmatrix::m, zgsmatrix::m, _zgsmatrix::n, zgsmatrix::n, and _zgsmatrix::rows.

140 {CPPL_VERBOSE_REPORT;
141 #ifdef CPPL_DEBUG
142  if(matA.n!=matB.m){
143  ERROR_REPORT;
144  std::cerr << "These two matrises can not make a product." << std::endl
145  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
146  exit(1);
147  }
148 #endif//CPPL_DEBUG
149 
150  zgsmatrix newmat(matA.m, matB.n);
151 
152  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
153  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
154  CPPL_INT k =it->j;
155  const std::vector<CPPL_INT>::iterator matB_rows_k_end =matB.rows[k].end();
156  for(std::vector<CPPL_INT>::iterator p=matB.rows[k].begin(); p!=matB_rows_k_end; p++){
157  newmat(it->i,matB.data[*p].j) += it->v*matB.data[*p].v;
158  }
159  }
160 
161  matB.destroy();
162  return _(newmat);
163 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _zgsmatrix.hpp:12
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
void destroy() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_dcovector _(dcovector &vec)
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11