CPPLapack
 All Classes Files Functions Variables Friends Pages
drovector-_dssmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! drovector*_dssmatrix operator */
3 inline _drovector operator*(const drovector& vec, const _dssmatrix& mat)
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(vec.l!=mat.n){
7  ERROR_REPORT;
8  std::cerr << "These vector and matrix can not make a product." << std::endl
9  << "Your input was (" << vec.l << ") * (" << mat.n << "x" << mat.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  drovector newvec(mat.n);
15  newvec.zero();
16 
17  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
18  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
19  newvec(it->j) += vec(it->i)*it->v;
20  if(it->i!=it->j){
21  newvec(it->i) += vec(it->j)*it->v;
22  }
23  }
24 
25  mat.destroy();
26  return _(newvec);
27 }
std::vector< dcomponent > data
matrix data
Definition: _dssmatrix.hpp:12
_drovector operator*(const drovector &vec, const _dssmatrix &mat)
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Sparse Matrix Class
Definition: _dssmatrix.hpp:3
CPPL_INT l
vector size
Definition: drovector.hpp:9
Real Double-precision Row Vector Class.
Definition: drovector.hpp:3
drovector & zero()
(DO NOT USE) Smart-temporary Real Double-precision Row Vector Class
Definition: _drovector.hpp:3
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
void destroy() const
_dcovector _(dcovector &vec)