CPPLapack
 All Classes Files Functions Variables Friends Pages
dgrmatrix-dcovector.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! dgrmatrix*dcovector operator */
3 inline _dcovector operator*(const dgrmatrix& mat, const dcovector& vec)
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.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14 #ifdef __INTEL_COMPILER
15  dcovector newvec(mat.m);
16  char transa ='N';
17  MKL_INT m =MKL_INT(mat.m);
18  double* a =const_cast<double*>(&mat.a[0]);
19  MKL_INT* ia =const_cast<MKL_INT*>(&mat.ia[0]);
20  MKL_INT* ja =const_cast<MKL_INT*>(&mat.ja[0]);
21  MKL_DCSRGEMV(&transa, &m, a, ia, ja, vec.array, newvec.array);
22  return _(newvec);
23 
24 
25 #else //__INTEL_COMPILER is not defined
26  dcovector newvec(mat.m);
27 #pragma omp parallel for
28  for(CPPL_INT i=0; i<mat.m; i++){
29  double sum =0.;
30  int k_beg =mat.ia[i]-1;
31  int k_end =mat.ia[i+1]-1;
32  for(int k=k_beg; k<k_end; k++){
33  int j =mat.ja[k]-1;
34  sum += mat.a[k] * vec(j);
35  }
36  newvec(i) =sum;
37  }
38  return _(newvec);
39 #endif//__INTEL_COMPILER
40 }
std::vector< double > a
matrix component values
Definition: dgrmatrix.hpp:11
CPPL_INT l
vector size
Definition: dcovector.hpp:9
std::vector< CPPL_INT > ia
rowIndex (NOT zero-based BUT one-based indexing)
Definition: dgrmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dgrmatrix.hpp:10
double * array
1D array to store vector data
Definition: dcovector.hpp:11
_dcovector operator*(const dgrmatrix &mat, const dcovector &vec)
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
CPPL_INT m
matrix row size
Definition: dgrmatrix.hpp:9
std::vector< CPPL_INT > ja
columns (NOT zero-based BUT one-based indexing)
Definition: dgrmatrix.hpp:13
(DO NOT USE) Smart-temporary Real Double-precision Column Vector Class
Definition: _dcovector.hpp:3
_dcovector _(dcovector &vec)
Real Double-precision General Compressed Sparse Row (CSR) Matrix Class.
Definition: dgrmatrix.hpp:3