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