My Project
dsymatrix-_dsymatrix.hpp
1 //=============================================================================
3 inline dsymatrix& dsymatrix::operator=(const _dsymatrix& mat)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] dsymatrix::operator=(const _dsymatrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  shallow_copy(mat);
11  return *this;
12 }
13 
17 
18 //=============================================================================
20 inline dsymatrix& dsymatrix::operator+=(const _dsymatrix& mat)
21 {
22 #ifdef CPPL_VERBOSE
23  std::cerr << "# [MARK] dsymatrix::operator+=(const _dsymatrix&)"
24  << std::endl;
25 #endif//CPPL_VERBOSE
26 
27 #ifdef CPPL_DEBUG
28  if(N!=mat.N){
29  std::cerr << "[ERROR] dsymatrix::operator+=(_dsymatrix&)" << std::endl
30  << "These two matrises can not make a summation." << std::endl
31  << "Your input was (" << N << "x" << N << ") += ("
32  << mat.N << "x" << mat.N << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  for(long i=0; i<N*N; i++){
38  Array[i]+=mat.Array[i];
39  }
40 
41  mat.destroy();
42  return *this;
43 }
44 
45 //=============================================================================
47 inline dsymatrix& dsymatrix::operator-=(const _dsymatrix& mat)
48 {
49 #ifdef CPPL_VERBOSE
50  std::cerr << "# [MARK] dsymatrix::operator-=(const _dsymatrix&)"
51  << std::endl;
52 #endif//CPPL_VERBOSE
53 
54 #ifdef CPPL_DEBUG
55  if(N!=mat.N){
56  std::cerr << "[ERROR] dsymatrix::operator-=(_dsymatrix&)" << std::endl
57  << "These two matrises can not make a sutraction." << std::endl
58  << "Your input was (" << N << "x" << N << ") -= ("
59  << mat.N << "x" << mat.N << ")." << std::endl;
60  exit(1);
61  }
62 #endif//CPPL_DEBUG
63 
64  for(long i=0; i<N*N; i++){
65  Array[i]-=mat.Array[i];
66  }
67 
68  mat.destroy();
69  return *this;
70 }
71 
75 
76 //=============================================================================
78 inline _dsymatrix operator+(const dsymatrix& matA, const _dsymatrix& matB)
79 {
80 #ifdef CPPL_VERBOSE
81  std::cerr << "# [MARK] operator+(const dsymatrix&, const _dsymatrix&)"
82  << std::endl;
83 #endif//CPPL_VERBOSE
84 
85 #ifdef CPPL_DEBUG
86  if(matA.N!=matB.N){
87  std::cerr << "[ERROR] operator+(dsymatrix&, _dsymatrix&)" << std::endl
88  << "These two matrises can not make a summation." << std::endl
89  << "Your input was (" << matA.N << "x" << matA.N << ") + ("
90  << matB.N << "x" << matB.N << ")." << std::endl;
91  exit(1);
92  }
93 #endif//CPPL_DEBUG
94 
95  for(long i=0; i<matA.N*matA.N; i++){
96  matB.Array[i]+=matA.Array[i];
97  }
98 
99  return matB;
100 }
101 
102 //=============================================================================
104 inline _dsymatrix operator-(const dsymatrix& matA, const _dsymatrix& matB)
105 {
106 #ifdef CPPL_VERBOSE
107  std::cerr << "# [MARK] operator-(const dsymatrix&, const _dsymatrix&)"
108  << std::endl;
109 #endif//CPPL_VERBOSE
110 
111 #ifdef CPPL_DEBUG
112  if(matA.N!=matB.N){
113  std::cerr << "[ERROR] operator-(dsymatrix&, _dsymatrix&)" << std::endl
114  << "These two matrises can not make a subtraction." << std::endl
115  << "Your input was (" << matA.N << "x" << matA.N << ") - ("
116  << matB.N << "x" << matB.N << ")." << std::endl;
117  exit(1);
118  }
119 #endif//CPPL_DEBUG
120 
121  for(long i=0; i<matA.N*matA.N; i++){
122  matB.Array[i] =matA.Array[i]-matB.Array[i];
123  }
124 
125  return matB;
126 }
127 
128 //=============================================================================
130 inline _dgematrix operator*(const dsymatrix& matA, const _dsymatrix& matB)
131 {
132 #ifdef CPPL_VERBOSE
133  std::cerr << "# [MARK] operator*(const dsymatrix&, const _dsymatrix&)"
134  << std::endl;
135 #endif//CPPL_VERBOSE
136 
137 #ifdef CPPL_DEBUG
138  if(matA.N!=matB.N){
139  std::cerr << "[ERROR] operator*(dsymatrix&, _dsymatrix&)" << std::endl
140  << "These two matrises can not make a product." << std::endl
141  << "Your input was (" << matA.N << "x" << matA.N << ") * ("
142  << matB.N << "x" << matB.N << ")." << std::endl;
143  exit(1);
144  }
145 #endif//CPPL_DEBUG
146 
147  matA.complete();
148  matB.complete();
149  dgematrix newmat( matA.N, matA.N );
150 
151  dgemm_( 'N', 'N', matA.N, matB.N, matA.N, 1.0, matA.Array, matA.N,
152  matB.Array, matB.N, 0.0, newmat.array, matA.N );
153 
154  matB.destroy();
155  return _(newmat);
156 }
dsymatrix & operator-=(const dsymatrix &)
Definition: dsymatrix-dsymatrix.hpp:47
void destroy() const
Definition: _dsymatrix-misc.hpp:3
friend _dgematrix i(const dsymatrix &)
Definition: dsymatrix-calc.hpp:22
double * Array
1D Array to store vector data
Definition: _drovector.hpp:8
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
double * Array
1D Array to store matrix data
Definition: _dsymatrix.hpp:8
Real Double-precision Symmetric Matrix Class [L-type (UPLO=L) Strage].
Definition: dsymatrix.hpp:3
friend _drovector operator-(const _drovector &)
Definition: _drovector-unary.hpp:15
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
dsymatrix & operator+=(const dsymatrix &)
Definition: dsymatrix-dsymatrix.hpp:22
void shallow_copy(const _dsymatrix &)
Definition: dsymatrix-misc.hpp:108
dsymatrix & operator=(const dsymatrix &)
Definition: dsymatrix-dsymatrix.hpp:3
friend _drovector operator*(const drovector &, const dgematrix &)
Definition: drovector-dgematrix.hpp:3
long N
matrix column or row size
Definition: _dsymatrix.hpp:7
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Matrix Class
Definition: _dsymatrix.hpp:3
void complete() const
Definition: _dsymatrix-misc.hpp:22
void complete() const
Definition: dsymatrix-misc.hpp:3
friend const _drovector & operator+(const _drovector &)
Definition: _drovector-unary.hpp:3