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