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 91 of file dgsmatrix-dgsmatrix.hpp.

References _(), dgsmatrix::data, dgsmatrix::m, and dgsmatrix::n.

92 {CPPL_VERBOSE_REPORT;
93 #ifdef CPPL_DEBUG
94  if(matA.n!=matB.n || matA.m!=matB.m){
95  ERROR_REPORT;
96  std::cerr << "These two matrises can not make a summation." << std::endl
97  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
98  exit(1);
99  }
100 #endif//CPPL_DEBUG
101 
102  dgsmatrix newmat(matA);
103 
104  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
105  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
106  newmat(it->i, it->j) +=it->v;
107  }
108 
109  return _(newmat);
110 }
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
_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 114 of file dgsmatrix-dgsmatrix.hpp.

References _(), dgsmatrix::data, dgsmatrix::m, and dgsmatrix::n.

115 {CPPL_VERBOSE_REPORT;
116 #ifdef CPPL_DEBUG
117  if(matA.n!=matB.n || matA.m!=matB.m){
118  ERROR_REPORT;
119  std::cerr << "These two matrises can not make a subtraction." << std::endl
120  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
121  exit(1);
122  }
123 #endif//CPPL_DEBUG
124 
125  dgsmatrix newmat(matA);
126 
127  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
128  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
129  newmat(it->i, it->j) -=it->v;
130  }
131 
132  return _(newmat);
133 }
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
_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 137 of file dgsmatrix-dgsmatrix.hpp.

References _(), dgsmatrix::data, dgsmatrix::m, dgsmatrix::n, and dgsmatrix::rows.

138 {CPPL_VERBOSE_REPORT;
139 #ifdef CPPL_DEBUG
140  if(matA.n!=matB.m){
141  ERROR_REPORT;
142  std::cerr << "These two matrises can not make a product." << std::endl
143  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
144  exit(1);
145  }
146 #endif//CPPL_DEBUG
147 
148  dgsmatrix newmat( matA.m, matB.n );
149 
150  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
151  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
152  CPPL_INT k =it->j;
153  const std::vector<CPPL_INT>::const_iterator matB_rows_k_end =matB.rows[k].end();
154  for(std::vector<CPPL_INT>::const_iterator p=matB.rows[k].begin(); p!=matB_rows_k_end; p++){
155  newmat(it->i,matB.data[*p].j) +=it->v*matB.data[*p].v;
156  }
157  }
158 
159  return _(newmat);
160 }
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
_dcovector _(dcovector &vec)
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 m
matrix row size
Definition: dgsmatrix.hpp:9