My Project
_zgbmatrix-_zgematrix.hpp
1 //=============================================================================
3 inline _zgematrix operator+(const _zgbmatrix& matA, const _zgematrix& matB)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] operator+(const _zgbmatrix&, const _zgematrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  if(matA.N!=matB.N || matA.M!=matB.M){
12  std::cerr << "[ERROR] operator+(_zgbmatrix&, _zgematrix&)" << std::endl
13  << "These two matrises can not make a summation." << std::endl
14  << "Your input was (" << matA.M << "x" << matA.N << ") + ("
15  << matB.M << "x" << matB.N << ")." << std::endl;
16  exit(1);
17  }
18 #endif//CPPL_DEBUG
19 
20  for(long i=0; i<matA.M; i++){
21  for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
22  matB(i,j)+=matA(i,j);
23  }
24  }
25 
26  matA.destroy();
27  return matB;
28 }
29 
30 //=============================================================================
32 inline _zgematrix operator-(const _zgbmatrix& matA, const _zgematrix& matB)
33 {
34 #ifdef CPPL_VERBOSE
35  std::cerr << "# [MARK] operator-(const _zgbmatrix&, const _zgematrix&)"
36  << std::endl;
37 #endif//CPPL_VERBOSE
38 
39 #ifdef CPPL_DEBUG
40  if(matA.N!=matB.N || matA.M!=matB.M){
41  std::cerr << "[ERROR] operator+(_zgbmatrix&, _zgematrix&)" << std::endl
42  << "These two matrises can not make a summation." << std::endl
43  << "Your input was (" << matA.M << "x" << matA.N << ") + ("
44  << matB.M << "x" << matB.N << ")." << std::endl;
45  exit(1);
46  }
47 #endif//CPPL_DEBUG
48 
49  for(long i=0; i<matA.M; i++){
50  for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
51  matB(i,j) =matA(i,j)-matB(i,j);
52  }
53  }
54 
55  matA.destroy();
56  return matB;
57 }
58 
59 //=============================================================================
61 inline _zgematrix operator*(const _zgbmatrix& matA, const _zgematrix& matB)
62 {
63 #ifdef CPPL_VERBOSE
64  std::cerr << "# [MARK] operator*(const _zgbmatrix&, const _zgematrix&)"
65  << std::endl;
66 #endif//CPPL_VERBOSE
67 
68 #ifdef CPPL_DEBUG
69  if(matA.N!=matB.M){
70  std::cerr << "[ERROR] operator*(_zgbmatrix&, _zgematrix&)" << std::endl
71  << "These two matrises can not make a product." << std::endl
72  << "Your input was (" << matA.M << "x" << matA.N << ") * ("
73  << matB.M << "x" << matB.N << ")." << std::endl;
74  exit(1);
75  }
76 #endif//CPPL_DEBUG
77 
78  zgematrix newmat( matA.M, matB.N );
79  newmat.zero();
80 
81  long i, j, k;
82 #pragma omp parallel for private(j,k)
83  for(i=0; i<newmat.m; i++){
84  for(j=0; j<newmat.n; j++){
85  for(k=max(0,i-matA.KL); k<min(matA.N,i+matA.KU+1); k++){
86  newmat(i,j)+=matA(i,k)*matB(k,j);
87  }
88  }
89  }
90 
91  matA.destroy();
92  matB.destroy();
93  return _(newmat);
94 }
long N
matrix column size
Definition: _zgematrix.hpp:8
friend _zrovector operator-(const _zrovector &)
Definition: _zrovector-unary.hpp:15
long N
matrix column size
Definition: _zgbmatrix.hpp:8
void destroy() const
Definition: _zgbmatrix-misc.hpp:3
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
long KU
upper band width
Definition: _zgbmatrix.hpp:10
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
void destroy() const
Definition: _zgematrix-misc.hpp:3
friend _zrovector operator*(const zrovector &, const zgematrix &)
Definition: zrovector-zgematrix.hpp:3
long M
matrix row size
Definition: _zgbmatrix.hpp:7
(DO NOT USE) Smart-temporary Complex Double-precision General Band Matrix Class
Definition: _zgbmatrix.hpp:3
long M
matrix row size
Definition: _zgematrix.hpp:7
friend const _zrovector & operator+(const _zrovector &)
Definition: _zrovector-unary.hpp:3
long KL
lower band width
Definition: _zgbmatrix.hpp:9