My Project
_zhematrix-zhematrix.hpp
1 //=============================================================================
3 inline _zhematrix operator+(const _zhematrix& matA, const zhematrix& matB)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] operator+(const _zhematrix&, const zhematrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  if(matA.N!=matB.N){
12  std::cerr << "[ERROR] operator+(_zhematrix&, zhematrix&)" << std::endl
13  << "These two matrises can not make a summation." << std::endl
14  << "Your input was (" << matA.N << "x" << matA.N << ") + ("
15  << matB.N << "x" << matB.N << ")." << std::endl;
16  exit(1);
17  }
18 #endif//CPPL_DEBUG
19 
20  for(long i=0; i<matA.N; i++){
21  for(long j=0; j<matA.N; j++){
22  matA.Array[i+matA.N*j]+=matB.Array[i+matA.N*j];
23  }
24  }
25 
26  return matA;
27 }
28 
29 //=============================================================================
31 inline _zhematrix operator-(const _zhematrix& matA, const zhematrix& matB)
32 {
33 #ifdef CPPL_VERBOSE
34  std::cerr << "# [MARK] operator-(const _zhematrix&, const zhematrix&)"
35  << std::endl;
36 #endif//CPPL_VERBOSE
37 
38 #ifdef CPPL_DEBUG
39  if(matA.N!=matB.N){
40  std::cerr << "[ERROR] operator-(_zhematrix&, zhematrix&)" << std::endl
41  << "These two matrises can not make a subtraction." << std::endl
42  << "Your input was (" << matA.N << "x" << matA.N << ") - ("
43  << matB.N << "x" << matB.N << ")." << std::endl;
44  exit(1);
45  }
46 #endif//CPPL_DEBUG
47 
48  for(long i=0; i<matA.N; i++){
49  for(long j=0; j<matA.N; j++){
50  matA.Array[i+matA.N*j]-=matB.Array[i+matA.N*j];
51  }
52  }
53 
54  return matA;
55 }
56 
57 //=============================================================================
59 inline _zgematrix operator*(const _zhematrix& matA, const zhematrix& matB)
60 {
61 #ifdef CPPL_VERBOSE
62  std::cerr << "# [MARK] operator*(const _zhematrix&, const zhematrix&)"
63  << std::endl;
64 #endif//CPPL_VERBOSE
65 
66 #ifdef CPPL_DEBUG
67  if(matA.N!=matB.N){
68  std::cerr << "[ERROR] operator*(_zhematrix&, zhematrix&)" << std::endl
69  << "These two matrises can not make a product." << std::endl
70  << "Your input was (" << matA.N << "x" << matA.N << ") * ("
71  << matB.N << "x" << matB.N << ")." << std::endl;
72  exit(1);
73  }
74 #endif//CPPL_DEBUG
75 
76  matB.complete();
77  zgematrix newmat( matA.N, matB.N );
78 
79  zhemm_( 'L', 'L', matA.N, matB.N, std::complex<double>(1.0,0.0),
80  matA.Array, matA.N, matB.Array, matB.N,
81  std::complex<double>(0.0,0.0), newmat.array, newmat.m );
82 
83  matA.destroy();
84  return _(newmat);
85 }
(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Matrix Class
Definition: _zhematrix.hpp:3
friend _zrovector operator-(const _zrovector &)
Definition: _zrovector-unary.hpp:15
void complete() const
Definition: zhematrix-misc.hpp:3
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
void destroy() const
Definition: _zhematrix-misc.hpp:3
std::complex< double > * Array
1D Array to store matrix data
Definition: _zhematrix.hpp:8
friend _zrovector operator*(const zrovector &, const zgematrix &)
Definition: zrovector-zgematrix.hpp:3
Complex Double-precision Hermitian Matrix Class [L-type (UPLO=L) Strage].
Definition: zhematrix.hpp:4
long N
matrix column or row size
Definition: _zhematrix.hpp:7
friend const _zrovector & operator+(const _zrovector &)
Definition: _zrovector-unary.hpp:3