CPPLapack
 All Classes Files Functions Variables Friends Pages
Functions
dgsmatrix-_dgsmatrix.hpp File Reference

Go to the source code of this file.

Functions

_dgsmatrix operator+ (const dgsmatrix &matA, const _dgsmatrix &matB)
 
_dgsmatrix operator- (const dgsmatrix &matA, const _dgsmatrix &matB)
 
_dgsmatrix operator* (const dgsmatrix &matA, const _dgsmatrix &matB)
 

Function Documentation

_dgsmatrix operator+ ( const dgsmatrix matA,
const _dgsmatrix matB 
)
inline

dgsmatrix+_dgsmatrix operator

Definition at line 92 of file dgsmatrix-_dgsmatrix.hpp.

References _(), dgsmatrix::data, _dgsmatrix::m, dgsmatrix::m, dgsmatrix::n, and _dgsmatrix::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  dgsmatrix newmat(matB);
104 
105  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
106  for(std::vector<dcomponent>::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 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
_dcovector _(dcovector &vec)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgsmatrix operator- ( const dgsmatrix matA,
const _dgsmatrix matB 
)
inline

dgsmatrix-_dgsmatrix operator

Definition at line 115 of file dgsmatrix-_dgsmatrix.hpp.

References _(), dgsmatrix::chsign(), dgsmatrix::data, _dgsmatrix::m, dgsmatrix::m, dgsmatrix::n, and _dgsmatrix::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  dgsmatrix newmat(matB);
127  newmat.chsign();
128 
129  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
130  for(std::vector<dcomponent>::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 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
_dcovector _(dcovector &vec)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgsmatrix operator* ( const dgsmatrix matA,
const _dgsmatrix matB 
)
inline

dgsmatrix*_dgsmatrix operator

Definition at line 139 of file dgsmatrix-_dgsmatrix.hpp.

References _(), dgsmatrix::data, _dgsmatrix::data, _dgsmatrix::destroy(), _dgsmatrix::m, dgsmatrix::m, _dgsmatrix::n, dgsmatrix::n, and _dgsmatrix::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  dgsmatrix newmat(matA.m, matB.n);
151 
152  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
153  for(std::vector<dcomponent>::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 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _dgsmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: _dgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
void destroy() const
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
_dcovector _(dcovector &vec)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9