#include<FVSparseM.h>
  

// compute y=A*x
template<> void FVSparseM<double>::Mult(FVSparseM<double> &x, FVSparseM<double> &y)
{
    y = 0.0;
	double val;
	//#pragma omp parallel for num_threads(nb_thread)
    for (size_t i=0; i<this->nb_rows; i++)
	{
		if(!_row[i]) continue; // no line i so y[i)=0    
		for(size_t j=0;j<this->nb_cols;j++)
		{
			if(!x._col[j]) continue; 
			val=0.0;
			for (size_t jj=0; jj<(this->_row[i])->size(); jj++)
			{
				//cout<<"i="<<i<<" j="<<  (*(row[i]))[jj].index<<" val="<< a[(*(row[i]))[jj].pos]<<endl;
				val += _a[(*(this->_row[i]))[jj].pos] * x.getValue((*(_row[i]))[jj].index,j);
			}
			y.setValue(i,j,val);
		}
	}
}
 