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