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