//=============================================================================
/*! 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
  
#ifdef _OPENMP// for multi CPU ////////////////////////////////////////////////
  long i;
  dcovector newvec(mat.N);
#pragma omp parallel for
  for(i=0; i<mat.m; i++){
    double val(0.);
    for(std::vector< std::pair<long,long> >::const_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 ////////////////////////////////////////////////////////
  /*
  dcovector newvec(mat.N);  
  for(long i=0; i<mat.m; i++){
    double val(0.);
    for(std::vector< std::pair<long,long> >::const_iterator p=mat.line[i].begin(); p!=mat.line[i].end(); p++){
      val +=mat.array[p->second]*vec(p->first);
    }
    newvec(i)=val;
  }
  */
  
  ///*
  dcovector newvec(dcovector(mat.N).zero());
  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]);
    }
  }
  //*/
  
  /*
  dcovector newvec(dcovector(mat.N).zero());
  double *ap(mat.Array);
  long *ip(mat.Indx), *jp(mat.Jndx), c(0);
  while(c<mat.VOL){
    newvec((*ip)) +=(*ap)*vec((*jp));
    if((*ip)!=(*jp)){
      newvec((*jp)) +=(*ap)*vec((*ip));
    }
    ap++;
    ip++; jp++; c++;
  }
  */
  
#endif/////////////////////////////////////////////////////////////////////////
  
  return _(newvec);
}