CPPLapack
 All Classes Files Functions Variables Friends Pages
_zgematrix-zgsmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! _zgematrix+zgsmatrix operator */
3 inline _zgematrix operator+(const _zgematrix& matA, const zgsmatrix& matB)
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.m || matA.n!=matB.n){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  const size_t matB_data_size =matB.data.size();
15  for(size_t c=0; c<matB_data_size; c++){
16  const zcomponent& z =matB.data[c];
17  matA(z.i,z.j) += z.v;
18  }
19 
20  return matA;
21 }
22 
23 //=============================================================================
24 /*! _zgematrix-zgsmatrix operator */
25 inline _zgematrix operator-(const _zgematrix& matA, const zgsmatrix& matB)
26 {CPPL_VERBOSE_REPORT;
27 #ifdef CPPL_DEBUG
28  if(matA.m!=matB.m || matA.n!=matB.n){
29  ERROR_REPORT;
30  std::cerr << "These two matrises can not make a subtraction." << std::endl
31  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
32  exit(1);
33  }
34 #endif//CPPL_DEBUG
35 
36  const size_t matB_data_size =matB.data.size();
37  for(size_t c=0; c<matB_data_size; c++){
38  const zcomponent& z =matB.data[c];
39  matA(z.i,z.j) -= z.v;
40  }
41 
42  return matA;
43 }
44 
45 //=============================================================================
46 /*! _zgematrix*zgsmatrix operator */
47 inline _zgematrix operator*(const _zgematrix& matA, const zgsmatrix& matB)
48 {CPPL_VERBOSE_REPORT;
49 #ifdef CPPL_DEBUG
50  if(matA.n!=matB.m){
51  ERROR_REPORT;
52  std::cerr << "These two matrises can not make a product." << std::endl
53  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
54  exit(1);
55  }
56 #endif//CPPL_DEBUG
57 
58  zgematrix newmat(matA.m, matB.n);
59  newmat.zero();
60 
61  const size_t matB_data_size =matB.data.size();
62  for(size_t c=0; c<matB_data_size; c++){
63  const zcomponent& z =matB.data[c];
64  for(CPPL_INT i=0; i<matA.m; i++){
65  newmat(i,z.j) += matA(i,z.i)*z.v;
66  }
67  }
68 
69  matA.destroy();
70  return _(newmat);
71 }
comple v
value of the component
Definition: zcomponent.hpp:11
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
CPPL_INT m
matrix row size
Definition: _zgematrix.hpp:9
_zgematrix operator-(const _zgematrix &matA, const zgsmatrix &matB)
_zgematrix operator*(const _zgematrix &matA, const zgsmatrix &matB)
_dgematrix i(const _dgbmatrix &mat)
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
zgematrix & zero()
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
Component Class for Complex Double-precision Sparse Matrix Classes.
Definition: zcomponent.hpp:3
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
CPPL_INT j
j index of the component
Definition: zcomponent.hpp:10
void destroy() const
_zgematrix operator+(const _zgematrix &matA, const zgsmatrix &matB)
CPPL_INT i
i index of the component
Definition: zcomponent.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_dcovector _(dcovector &vec)
CPPL_INT n
matrix column size
Definition: _zgematrix.hpp:10