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