CPPLapack
 All Classes Files Functions Variables Friends Pages
_dgematrix-dgbmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! _dgematrix+dgbmatrix operator */
3 inline _dgematrix operator+(const _dgematrix& matA, const dgbmatrix& 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  for(CPPL_INT i=0; i<matB.m; i++){
15  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
16  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
17  matA(i,j) += matB(i,j);
18  }
19  }
20 
21  return matA;
22 }
23 
24 //=============================================================================
25 /*! _dgematrix-dgbmatrix operator */
26 inline _dgematrix operator-(const _dgematrix& matA, const dgbmatrix& matB)
27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if(matA.n!=matB.n || matA.m!=matB.m){
30  ERROR_REPORT;
31  std::cerr << "These two matrises can not make a summation." << std::endl
32  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  for(CPPL_INT i=0; i<matB.m; i++){
38  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
39  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
40  matA(i,j) -= matB(i,j);
41  }
42  }
43 
44  return matA;
45 }
46 
47 //=============================================================================
48 /*! _dgematrix*dgbmatrix operator */
49 inline _dgematrix operator*(const _dgematrix& matA, const dgbmatrix& matB)
50 {CPPL_VERBOSE_REPORT;
51 #ifdef CPPL_DEBUG
52  if(matA.n!=matB.m){
53  ERROR_REPORT;
54  std::cerr << "These two matrises can not make a product." << std::endl
55  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
56  exit(1);
57  }
58 #endif//CPPL_DEBUG
59 
60  dgematrix newmat( matA.m, matB.n );
61  newmat.zero();
62 
63  for(CPPL_INT i=0; i<newmat.m; i++){
64  for(CPPL_INT j=0; j<newmat.n; j++){
65  const CPPL_INT kmax =std::min(matB.m,j+matB.kl+1);
66  for(CPPL_INT k=std::max(CPPL_INT(0),j-matB.ku); k<kmax; k++){
67  newmat(i,j) += matA(i,k)*matB(k,j);
68  }
69  }
70  }
71 
72  matA.destroy();
73  return _(newmat);
74 }
_dgematrix operator-(const _dgematrix &matA, const dgbmatrix &matB)
CPPL_INT m
matrix row size
Definition: dgbmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
dgematrix & zero()
_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 kl
lower band width
Definition: dgbmatrix.hpp:11
CPPL_INT ku
upper band width
Definition: dgbmatrix.hpp:12
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
_dgematrix operator*(const _dgematrix &matA, const dgbmatrix &matB)
Real Double-precision General Band Matrix Class.
Definition: dgbmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
void destroy() const
CPPL_INT n
matrix column size
Definition: dgbmatrix.hpp:10
_dgematrix operator+(const _dgematrix &matA, const dgbmatrix &matB)
_dcovector _(dcovector &vec)