CPPLapack
 All Classes Files Functions Variables Friends Pages
_dgematrix-dgematrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! _dgematrix+dgematrix operator */
3 inline _dgematrix operator+(const _dgematrix& matA, const dgematrix& matB)
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.n!=matB.n || matA.m!=matB.m){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  const CPPL_INT mn =matA.m*matA.n;
15  for(CPPL_INT i=0; i<mn; i++){
16  matA.array[i]+=matB.array[i];
17  }
18 
19  return matA;
20 }
21 
22 //=============================================================================
23 /*! _dgematrix-dgematrix operator */
24 inline _dgematrix operator-(const _dgematrix& matA, const dgematrix& matB)
25 {CPPL_VERBOSE_REPORT;
26 #ifdef CPPL_DEBUG
27  if(matA.n!=matB.n || matA.m!=matB.m){
28  ERROR_REPORT;
29  std::cerr << "These two matrises can not make a subtraction." << std::endl
30  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
31  exit(1);
32  }
33 #endif//CPPL_DEBUG
34 
35  const CPPL_INT mn =matA.m*matA.n;
36  for(CPPL_INT i=0; i<mn; i++){
37  matA.array[i]-=matB.array[i];
38  }
39 
40  return matA;
41 }
42 
43 //=============================================================================
44 /*! _dgematrix*dgematrix operator */
45 inline _dgematrix operator*(const _dgematrix& matA, const dgematrix& matB)
46 {CPPL_VERBOSE_REPORT;
47 #ifdef CPPL_DEBUG
48  if(matA.n!=matB.m){
49  ERROR_REPORT;
50  std::cerr << "These two matrises can not make a product." << std::endl
51  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
52  exit(1);
53  }
54 #endif//CPPL_DEBUG
55 
56  dgematrix newmat( matA.m, matB.n );
57  char transa ='n';
58  char transb ='n';
59  double alpha =1.;
60  double beta =0.;
61 
62  dgemm_( &transa, &transb, &matA.m, &matB.n, &matA.n, &alpha, matA.array, &matA.m, matB.array, &matB.m, &beta, newmat.array, &matA.m );
63 
64  matA.destroy();
65  return _(newmat);
66 }
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
double * array
1D array to store matrix data
Definition: dgematrix.hpp:11
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dgematrix.hpp:10
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
double * array
1D array to store matrix data
Definition: _dgematrix.hpp:11
_dgematrix operator+(const _dgematrix &matA, const dgematrix &matB)
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
void destroy() const
_dcovector _(dcovector &vec)
_dgematrix operator-(const _dgematrix &matA, const dgematrix &matB)
_dgematrix operator*(const _dgematrix &matA, const dgematrix &matB)