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  return matA;
23 }
24 
25 //=============================================================================
27 inline _dsymatrix operator-(const _dsymatrix& matA, const dsymatrix& matB)
28 {
29 #ifdef CPPL_VERBOSE
30  std::cerr << "# [MARK] operator-(const _dsymatrix&, const dsymatrix&)"
31  << std::endl;
32 #endif//CPPL_VERBOSE
33 
34 #ifdef CPPL_DEBUG
35  if(matA.N!=matB.N){
36  std::cerr << "[ERROR] operator-(_dsymatrix&, dsymatrix&)" << std::endl
37  << "These two matrises can not make a subtraction." << std::endl
38  << "Your input was (" << matA.N << "x" << matA.N << ") - ("
39  << matB.N << "x" << matB.N << ")." << std::endl;
40  exit(1);
41  }
42 #endif//CPPL_DEBUG
43 
44  for(long i=0; i<matA.N*matA.N; i++){ matA.Array[i]-=matB.Array[i]; }
45 
46  return matA;
47 }
48 
49 //=============================================================================
51 inline _dgematrix operator*(const _dsymatrix& matA, const dsymatrix& matB)
52 {
53 #ifdef CPPL_VERBOSE
54  std::cerr << "# [MARK] operator*(const _dsymatrix&, const dsymatrix&)"
55  << std::endl;
56 #endif//CPPL_VERBOSE
57 
58 #ifdef CPPL_DEBUG
59  if(matA.N!=matB.N){
60  std::cerr << "[ERROR] operator*(_dsymatrix&, dsymatrix&)" << std::endl
61  << "These two matrises can not make a product." << std::endl
62  << "Your input was (" << matA.N << "x" << matA.N << ") * ("
63  << matB.N << "x" << matB.N << ")." << std::endl;
64  exit(1);
65  }
66 #endif//CPPL_DEBUG
67 
68  matA.complete();
69  matB.complete();
70  dgematrix newmat(matA.N, matA.N);
71 
72  dgemm_( 'N', 'N', matA.N, matB.N, matA.N, 1.0, matA.Array, matA.N,
73  matB.Array, matB.N, 0.0, newmat.array, matA.N );
74 
75  matA.destroy();
76  return _(newmat);
77 }
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
Real Double-precision Symmetric Matrix Class [L-type (UPLO=L) Strage].
Definition: dsymatrix.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
void complete() const
Definition: dsymatrix-misc.hpp:3
friend const _drovector & operator+(const _drovector &)
Definition: _drovector-unary.hpp:3