VERB_code_2.3
zhematrix-_zhematrix.hpp
1 //=============================================================================
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] zhematrix::operator=(const _zhematrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  shallow_copy(mat);
11  return *this;
12 }
13 
17 
18 //=============================================================================
21 {
22 #ifdef CPPL_VERBOSE
23  std::cerr << "# [MARK] zhematrix::operator+=(const _zhematrix&)"
24  << std::endl;
25 #endif//CPPL_VERBOSE
26 
27 #ifdef CPPL_DEBUG
28  if(N!=mat.N){
29  std::cerr << "[ERROR] zhematrix::operator+=(_zhematrix&)" << std::endl
30  << "These two matrises can not make a summation." << std::endl
31  << "Your input was (" << N << "x" << N << ") += ("
32  << mat.N << "x" << mat.N << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
38  Array[i+N*j]+=mat.Array[i+N*j];
39  }}
40 
41  mat.destroy();
42  return *this;
43 }
44 
45 //=============================================================================
48 {
49 #ifdef CPPL_VERBOSE
50  std::cerr << "# [MARK] zhematrix::operator-=(const _zhematrix&)"
51  << std::endl;
52 #endif//CPPL_VERBOSE
53 
54 #ifdef CPPL_DEBUG
55  if(N!=mat.N){
56  std::cerr << "[ERROR] zhematrix::operator-=(_zhematrix&)" << std::endl
57  << "These two matrises can not make a sutraction." << std::endl
58  << "Your input was (" << N << "x" << N << ") -= ("
59  << mat.N << "x" << mat.N << ")." << std::endl;
60  exit(1);
61  }
62 #endif//CPPL_DEBUG
63 
64  for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
65  Array[i+N*j]-=mat.Array[i+N*j];
66  }}
67 
68  mat.destroy();
69  return *this;
70 }
71 
75 
76 //=============================================================================
78 inline _zhematrix operator+(const zhematrix& matA, const _zhematrix& matB)
79 {
80 #ifdef CPPL_VERBOSE
81  std::cerr << "# [MARK] operator+(const zhematrix&, const _zhematrix&)"
82  << std::endl;
83 #endif//CPPL_VERBOSE
84 
85 #ifdef CPPL_DEBUG
86  if(matA.N!=matB.N){
87  std::cerr << "[ERROR] operator+(zhematrix&, _zhematrix&)" << std::endl
88  << "These two matrises can not make a summation." << std::endl
89  << "Your input was (" << matA.N << "x" << matA.N << ") + ("
90  << matB.N << "x" << matB.N << ")." << std::endl;
91  exit(1);
92  }
93 #endif//CPPL_DEBUG
94 
95  for(long i=0; i<matA.N; i++){ for(long j=0; j<=i; j++){
96  matB.Array[i+matA.N*j]+=matA.Array[i+matA.N*j];
97  }}
98 
99  return matB;
100 }
101 
102 //=============================================================================
104 inline _zhematrix operator-(const zhematrix& matA, const _zhematrix& matB)
105 {
106 #ifdef CPPL_VERBOSE
107  std::cerr << "# [MARK] operator-(const zhematrix&, const _zhematrix&)"
108  << std::endl;
109 #endif//CPPL_VERBOSE
110 
111 #ifdef CPPL_DEBUG
112  if(matA.N!=matB.N){
113  std::cerr << "[ERROR] operator-(zhematrix&, _zhematrix&)" << std::endl
114  << "These two matrises can not make a subtraction." << std::endl
115  << "Your input was (" << matA.N << "x" << matA.N << ") - ("
116  << matB.N << "x" << matB.N << ")." << std::endl;
117  exit(1);
118  }
119 #endif//CPPL_DEBUG
120 
121  for(long i=0; i<matA.N; i++){ for(long j=0; j<=i; j++){
122  matB.Array[i] =matA.Array[i]-matB.Array[i];
123  }}
124 
125  return matB;
126 }
127 
128 //=============================================================================
130 inline _zgematrix operator*(const zhematrix& matA, const _zhematrix& matB)
131 {
132 #ifdef CPPL_VERBOSE
133  std::cerr << "# [MARK] operator*(const zhematrix&, const _zhematrix&)"
134  << std::endl;
135 #endif//CPPL_VERBOSE
136 
137 #ifdef CPPL_DEBUG
138  if(matA.N!=matB.N){
139  std::cerr << "[ERROR] operator*(zhematrix&, _zhematrix&)" << std::endl
140  << "These two matrises can not make a product." << std::endl
141  << "Your input was (" << matA.N << "x" << matA.N << ") * ("
142  << matB.N << "x" << matB.N << ")." << std::endl;
143  exit(1);
144  }
145 #endif//CPPL_DEBUG
146 
147  matB.complete();
148  zgematrix newmat( matA.N, matB.N );
149 
150  zhemm_( 'L', 'L', matA.N, matB.N, std::complex<double>(1.0,0.0),
151  matA.Array, matA.N, matB.Array, matB.N,
152  std::complex<double>(0.0,0.0), newmat.array, newmat.m );
153 
154  matB.destroy();
155  return _(newmat);
156 }
(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Matrix Class
Definition: _zhematrix.hpp:3
void shallow_copy(const _zhematrix &)
Definition: zhematrix-misc.hpp:125
zhematrix & operator+=(const zhematrix &)
Definition: zhematrix-zhematrix.hpp:22
long const & m
matrix row size (readable)
Definition: zgematrix.hpp:14
friend _zrovector operator-(const _zrovector &)
Definition: _zrovector-unary.hpp:15
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::complex< double > * Array
1D Array to store matrix data
Definition: _zhematrix.hpp:8
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
friend _zgematrix i(const zhematrix &)
Definition: zhematrix-calc.hpp:20
void complete() const
Definition: _zhematrix-misc.hpp:22
void destroy() const
Definition: _zhematrix-misc.hpp:3
friend _zrovector operator*(const zrovector &, const zgematrix &)
Definition: zrovector-zgematrix.hpp:3
std::complex< double > * Array
1D Array to store vector data
Definition: _zrovector.hpp:8
zhematrix & operator=(const zhematrix &)
Definition: zhematrix-zhematrix.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
std::complex< double > *const & array
1D array to store matrix data (readable)
Definition: zgematrix.hpp:16
zhematrix & operator-=(const zhematrix &)
Definition: zhematrix-zhematrix.hpp:48
friend const _zrovector & operator+(const _zrovector &)
Definition: _zrovector-unary.hpp:3