CPPLapack
 All Classes Files Functions Variables Friends Pages
Functions
_dssmatrix-dcovector.hpp File Reference

Go to the source code of this file.

Functions

_dcovector operator* (const _dssmatrix &mat, const dcovector &vec)
 

Function Documentation

_dcovector operator* ( const _dssmatrix mat,
const dcovector vec 
)
inline

_dssmatrix*dcovector operator

Definition at line 3 of file _dssmatrix-dcovector.hpp.

References _(), _dssmatrix::data, _dssmatrix::destroy(), dcovector::l, _dssmatrix::n, and dcovector::zero().

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(mat.n!=vec.l){
7  ERROR_REPORT;
8  std::cerr << "These matrix and vector can not make a product." << std::endl
9  << "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dcovector newvec(mat.n);
15  newvec.zero();
16 
17  const std::vector<dcomponent>::iterator mat_data_end =mat.data.end();
18  for(std::vector<dcomponent>::iterator it=mat.data.begin(); it!=mat_data_end; it++){
19  newvec(it->i) +=it->v*vec(it->j);
20  if(it->i!=it->j){
21  newvec(it->j) +=it->v*vec(it->i);
22  }
23  }
24 
25  mat.destroy();
26  return _(newvec);
27 }
std::vector< dcomponent > data
matrix data
Definition: _dssmatrix.hpp:12
CPPL_INT l
vector size
Definition: dcovector.hpp:9
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
void destroy() const
_dcovector _(dcovector &vec)