Menu

[r147]: / trunk / include / dssmatrix- / dssmatrix-_dcovector.hpp  Maximize  Restore  History

Download this file

27 lines (23 with data), 790 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//=============================================================================
/*! dssmatrix*_dcovector operator */
inline _dcovector operator*(const dssmatrix& mat, const _dcovector& vec)
{VERBOSE_REPORT;
#ifdef CPPL_DEBUG
if(mat.n!=vec.l){
ERROR_REPORT;
std::cerr << "These matrix and vector can not make a product." << std::endl
<< "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
dcovector newvec(dcovector(mat.n));
newvec.zero();
for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
newvec(it->i) +=it->v*vec(it->j);
if(it->i!=it->j){
newvec(it->j) +=it->v*vec(it->i);
}
}
vec.destroy();
return _(newvec);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.