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