CPPLapack
 All Classes Files Functions Variables Friends Pages
_zgematrix-zssmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! _zgematrix+zhematrix operator */
3 inline _zgematrix operator+(const _zgematrix& matA, const zhematrix& 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  for(CPPL_INT c=0; c<matB.vol; c++){
15  matA(matB.indx[c],matB.jndx[c]) += matB.array[c];
16  }
17 
18  return matA;
19 }
20 
21 //=============================================================================
22 /*! _zgematrix-zhematrix operator */
23 inline _zgematrix operator-(const _zgematrix& matA, const zhematrix& matB)
24 {CPPL_VERBOSE_REPORT;
25 #ifdef CPPL_DEBUG
26  if(matA.m!=matB.m || matA.n!=matB.n){
27  ERROR_REPORT;
28  std::cerr << "These two matrises can not make a subtraction." << std::endl
29  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
30  exit(1);
31  }
32 #endif//CPPL_DEBUG
33 
34  //// change sign ////
35  for(CPPL_INT i=0; i<matA.m*matA.n; i++){
36  matA.array[i]=-matA.array[i];
37  }
38 
39  //// add ////
40  for(CPPL_INT c=0; c<matB.vol; c++){
41  matA(matB.indx[c],matB.jndx[c]) += matB.array[c];
42  }
43 
44  return matA;
45 }
46 
47 //=============================================================================
48 /*! _zgematrix*zhematrix operator */
49 inline _zgematrix operator*(const _zgematrix& matA, const zhematrix& 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  for(CPPL_INT c=0; c<matB.vol; c++){
64  for(CPPL_INT i=0; i<matA.m; i++){
65  newmat(i,matB.jndx[c]) += matA(i,matB.indx[c])*matB.array[c];
66  }
67  }
68 
69  matA.destroy();
70  return _(newmat);
71 }
CPPL_INT m
matrix row size
Definition: _zgematrix.hpp:9
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT const & m
matrix row size
Definition: zhematrix.hpp:10
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
zgematrix & zero()
CPPL_INT n
matrix column size
Definition: zhematrix.hpp:11
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
comple * array
1D array to store matrix data
Definition: zhematrix.hpp:12
_zgematrix operator-(const _zgematrix &matA, const zhematrix &matB)
void destroy() const
comple * array
1D array to store matrix data
Definition: _zgematrix.hpp:11
_zgematrix operator+(const _zgematrix &matA, const zhematrix &matB)
Complex Double-precision Hermitian Matrix Class [l-type (UPLO=l) Strage].
Definition: zhematrix.hpp:4
_dcovector _(dcovector &vec)
CPPL_INT n
matrix column size
Definition: _zgematrix.hpp:10
_zgematrix operator*(const _zgematrix &matA, const zhematrix &matB)