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