VERB_code_2.3
zgematrix-zhematrix.hpp
1 //=============================================================================
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] zgematrix::operator=(const zhematrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  resize(mat.N, mat.N);
11  for(long i=0; i<mat.N; i++){ for(long j=0; j<mat.N; j++){
12  operator()(i,j) =mat(i,j);
13  }}
14 
15  return *this;
16 }
17 
21 
22 //=============================================================================
25 {
26 #ifdef CPPL_VERBOSE
27  std::cerr << "# [MARK] zgematrix::operator+=(const zhematrix&)"
28  << std::endl;
29 #endif//CPPL_VERBOSE
30 
31 #ifdef CPPL_DEBUG
32  if(N!=mat.N || M!=mat.N){
33  std::cerr << "[ERROR] zgematrix::operator+=(zhematrix&)" << std::endl
34  << "These two matrises can not make a summation." << std::endl
35  << "Your input was (" << M << "x" << N << ") += ("
36  << mat.N << "x" << mat.N << ")." << std::endl;
37  exit(1);
38  }
39 #endif//CPPL_DEBUG
40 
41  for(long i=0; i<M; i++){ for( long j=0; j<N; j++){
42  operator()(i,j) += mat(i,j);
43  }}
44 
45  return *this;
46 }
47 
48 //=============================================================================
51 {
52 #ifdef CPPL_VERBOSE
53  std::cerr << "# [MARK] zgematrix::operator-=(const zhematrix&)"
54  << std::endl;
55 #endif//CPPL_VERBOSE
56 
57 #ifdef CPPL_DEBUG
58  if(N!=mat.N || M!=mat.N){
59  std::cerr << "[ERROR] zgematrix::operator-=(zhematrix&)" << std::endl
60  << "These two matrises can not make a sutraction." << std::endl
61  << "Your input was (" << M << "x" << N << ") -= ("
62  << mat.N << "x" << mat.N << ")." << std::endl;
63  exit(1);
64  }
65 #endif//CPPL_DEBUG
66 
67  for(long i=0; i<M; i++){ for(long j=0; j<N; j++){
68  operator()(i,j) -= mat(i,j);
69  }}
70 
71  return *this;
72 }
73 
74 //=============================================================================
77 {
78 #ifdef CPPL_VERBOSE
79  std::cerr << "# [MARK] zgematrix::operator*=(const zhematrix&)"
80  << std::endl;
81 #endif//CPPL_VERBOSE
82 
83 #ifdef CPPL_DEBUG
84  if(N!=mat.N){
85  std::cerr << "[ERROR] zgematrix::operator*=(zhematrix&)" << std::endl
86  << "These two matrises can not make a product." << std::endl
87  << "Your input was (" << M << "x" << N << ") *= ("
88  << mat.N << "x" << mat.N << ")." << std::endl;
89  exit(1);
90  }
91 #endif//CPPL_DEBUG
92 
93  zgematrix newmat( M, mat.N );
94 
95  zhemm_( 'R', 'L', mat.N, N, std::complex<double>(1.0,0.0), mat.Array, mat.N,
96  Array, M, std::complex<double>(0.0,0.0), newmat.array, newmat.m );
97 
98  swap(*this,newmat);
99  return *this;
100 }
101 
105 
106 //=============================================================================
108 inline _zgematrix operator+(const zgematrix& matA, const zhematrix& matB)
109 {
110 #ifdef CPPL_VERBOSE
111  std::cerr << "# [MARK] operator+(const zgematrix&, const zhematrix&)"
112  << std::endl;
113 #endif//CPPL_VERBOSE
114 
115 #ifdef CPPL_DEBUG
116  if(matA.N!=matB.N || matA.M!=matB.N){
117  std::cerr << "[ERROR] operator+(zgematrix&, _zgematrix&)" << std::endl
118  << "These two matrises can not make a summation." << std::endl
119  << "Your input was (" << matA.M << "x" << matA.N << ") + ("
120  << matB.N << "x" << matB.N << ")." << std::endl;
121  exit(1);
122  }
123 #endif//CPPL_DEBUG
124 
125  zgematrix newmat(matA);
126  for(long i=0; i<matA.M; i++){ for(long j=0; j<matA.N; j++){
127  newmat(i,j) += matB(i,j);
128  }}
129 
130  return _(newmat);
131 }
132 
133 //=============================================================================
135 inline _zgematrix operator-(const zgematrix& matA, const zhematrix& matB)
136 {
137 #ifdef CPPL_VERBOSE
138  std::cerr << "# [MARK] operator-(const zgematrix&, const zhematrix&)"
139  << std::endl;
140 #endif//CPPL_VERBOSE
141 
142 #ifdef CPPL_DEBUG
143  if(matA.N!=matB.N || matA.M!=matB.N){
144  std::cerr << "[ERROR] operator-(zgematrix&, _zgematrix&)" << std::endl
145  << "These two matrises can not make a subtraction." << std::endl
146  << "Your input was (" << matA.M << "x" << matA.N << ") - ("
147  << matB.N << "x" << matB.N << ")." << std::endl;
148  exit(1);
149  }
150 #endif//CPPL_DEBUG
151 
152  zgematrix newmat(matA);
153  for(long i=0; i<matA.M; i++){ for(long j=0; j<matA.N; j++){
154  newmat(i,j) -= matB(i,j);
155  }}
156 
157  return _(newmat);
158 }
159 
160 //=============================================================================
162 inline _zgematrix operator*(const zgematrix& matA, const zhematrix& matB)
163 {
164 #ifdef CPPL_VERBOSE
165  std::cerr << "# [MARK] operator*(const zgematrix&, const zhematrix&)"
166  << std::endl;
167 #endif//CPPL_VERBOSE
168 
169 #ifdef CPPL_DEBUG
170  if(matA.N!=matB.N){
171  std::cerr << "[ERROR] operator*(zgematrix&, _zhematrix&)" << std::endl
172  << "These two matrises can not make a product." << std::endl
173  << "Your input was (" << matA.M << "x" << matA.N << ") * ("
174  << matB.N << "x" << matB.N << ")." << std::endl;
175  exit(1);
176  }
177 #endif//CPPL_DEBUG
178 
179  zgematrix newmat( matA.M, matA.N );
180  zhemm_( 'R', 'L', newmat.M, newmat.N, std::complex<double>(1.0,0.0),
181  matB.Array, newmat.N, matA.Array, newmat.M,
182  std::complex<double>(0.0,0.0), newmat.array, newmat.M );
183 
184  return _(newmat);
185 }
void resize(const long &, const long &)
Definition: zgematrix-misc.hpp:126
long const & m
matrix row size (readable)
Definition: zgematrix.hpp:14
zgematrix & operator-=(const zgematrix &)
Definition: zgematrix-zgematrix.hpp:45
friend _zrovector operator-(const _zrovector &)
Definition: _zrovector-unary.hpp:15
zgematrix & operator=(const zgematrix &)
Definition: zgematrix-zgematrix.hpp:3
friend _zgematrix i(const zgematrix &)
Definition: zgematrix-calc.hpp:21
zgematrix & operator*=(const zgematrix &)
Definition: zgematrix-zgematrix.hpp:68
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
std::complex< double > & operator()(const long &, const long &)
Definition: zgematrix-io.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
zgematrix & operator+=(const zgematrix &)
Definition: zgematrix-zgematrix.hpp:22
friend void swap(zgematrix &, zgematrix &)
Definition: zgematrix-misc.hpp:154
Complex Double-precision Hermitian Matrix Class [L-type (UPLO=L) Strage].
Definition: zhematrix.hpp:4
std::complex< double > *const & array
1D array to store matrix data (readable)
Definition: zgematrix.hpp:16
friend const _zrovector & operator+(const _zrovector &)
Definition: _zrovector-unary.hpp:3