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