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