//=============================================================================
/*! dssmatrix*dcovector operator */
inline _dcovector operator*(const dssmatrix& mat, const dcovector& vec)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator*(const dssmatrix&, const dcovector&)" << std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(mat.N!=vec.L){
std::cerr << "[ERROR] operator*(const dssmatrix&, const dcovector&)" << std::endl
<< "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(mat.N);
//newvec.zero();
#ifdef _OPENMP//for multi CPU
long i;
#pragma omp parallel for
for(i=0; i<mat.m; i++){
double val(0.);
for(std::vector< std::pair<long,long> >::iterator p=mat.line[i].begin(); p!=mat.line[i].end(); p++){
val +=mat.array[p->second]*vec(p->first);
}
newvec(i)=val;
}
#else//for single CPU
for(long i=0; i<mat.m; i++){
double val(0.);
for(std::vector< std::pair<long,long> >::iterator p=mat.line[i].begin(); p!=mat.line[i].end(); p++){
val +=mat.array[p->second]*vec(p->first);
}
newvec(i)=val;
}
/*
for(long c=0; c<mat.VOL; c++){
newvec(mat.Indx[c]) +=mat.Array[c]*vec(mat.Jndx[c]);
if(mat.Indx[c]!=mat.Jndx[c]){
newvec(mat.Jndx[c]) +=mat.Array[c]*vec(mat.Indx[c]);
}
}
*/
#endif
return _(newvec);
}