VERB_code_2.3
zhematrix-zgematrix.hpp
1 //=============================================================================
3 inline _zgematrix operator+(const zhematrix& matA, const zgematrix& matB)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] operator+(const zhematrix&, const zgematrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  if(matA.N!=matB.N || matA.N!=matB.M){
12  std::cerr << "[ERROR] operator+(zhematrix&, zgematrix&)" << std::endl
13  << "These two matrises can not make a summation." << std::endl
14  << "Your input was (" << matA.N << "x" << matA.N << ") + ("
15  << matB.M << "x" << matB.N << ")." << std::endl;
16  exit(1);
17  }
18 #endif//CPPL_DEBUG
19 
20  zgematrix newmat(matB);
21  for(long i=0; i<matA.N; i++){ for(long j=0; j<matA.N; j++){
22  newmat(i,j)+=matA(i,j);
23  }}
24 
25  return _(newmat);
26 }
27 
28 //=============================================================================
30 inline _zgematrix operator-(const zhematrix& matA, const zgematrix& matB)
31 {
32 #ifdef CPPL_VERBOSE
33  std::cerr << "# [MARK] operator-(const zhematrix&, const zgematrix&)"
34  << std::endl;
35 #endif//CPPL_VERBOSE
36 
37 #ifdef CPPL_DEBUG
38  if(matA.N!=matB.N || matA.N!=matB.M){
39  std::cerr << "[ERROR] operator+(zhematrix&, zgematrix&)" << std::endl
40  << "These two matrises can not make a summation." << std::endl
41  << "Your input was (" << matA.N << "x" << matA.N << ") + ("
42  << matB.M << "x" << matB.N << ")." << std::endl;
43  exit(1);
44  }
45 #endif//CPPL_DEBUG
46 
47  zgematrix newmat(-matB);
48  for(long i=0; i<matA.N; i++){ for(long j=0; j<matA.N; j++){
49  newmat(i,j)+=matA(i,j);
50  }}
51 
52  return _(newmat);
53 }
54 
55 
56 //=============================================================================
58 inline _zgematrix operator*(const zhematrix& matA, const zgematrix& matB)
59 {
60 #ifdef CPPL_VERBOSE
61  std::cerr << "# [MARK] operator*(const zhematrix&, const zgematrix&)"
62  << std::endl;
63 #endif//CPPL_VERBOSE
64 
65 #ifdef CPPL_DEBUG
66  if(matA.N!=matB.M){
67  std::cerr << "[ERROR] operator*(zhematrix&, zgematrix&)" << std::endl
68  << "These two matrises can not make a product." << std::endl
69  << "Your input was (" << matA.N << "x" << matA.N << ") * ("
70  << matB.M << "x" << matB.N << ")." << std::endl;
71  exit(1);
72  }
73 #endif//CPPL_DEBUG
74 
75  zgematrix newmat( matA.N, matB.N );
76  zhemm_( 'L', 'L', matA.N, matB.N, std::complex<double>(1.0,0.0),
77  matA.Array, matA.N, matB.Array, matB.M,
78  std::complex<double>(0.0,0.0), newmat.array, newmat.M );
79 
80  return _(newmat);
81 }
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
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
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