VERB_code_2.3
_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  zgematrix newmat(matB);
21  for(long i=0; i<matA.M; i++){
22  for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
23  newmat(i,j)+=matA(i,j);
24  }
25  }
26 
27  matA.destroy();
28  return _(newmat);
29 }
30 
31 //=============================================================================
33 inline _zgematrix operator-(const _zgbmatrix& matA, const zgematrix& matB)
34 {
35 #ifdef CPPL_VERBOSE
36  std::cerr << "# [MARK] operator-(const _zgbmatrix&, const zgematrix&)"
37  << std::endl;
38 #endif//CPPL_VERBOSE
39 
40 #ifdef CPPL_DEBUG
41  if(matA.N!=matB.N || matA.M!=matB.M){
42  std::cerr << "[ERROR] operator+(_zgbmatrix&, zgematrix&)" << std::endl
43  << "These two matrises can not make a summation." << std::endl
44  << "Your input was (" << matA.M << "x" << matA.N << ") + ("
45  << matB.M << "x" << matB.N << ")." << std::endl;
46  exit(1);
47  }
48 #endif//CPPL_DEBUG
49 
50  zgematrix newmat(-matB);
51  for(long i=0; i<matA.M; i++){
52  for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
53  newmat(i,j)+=matA(i,j);
54  }
55  }
56 
57  matA.destroy();
58  return _(newmat);
59 }
60 
61 //=============================================================================
63 inline _zgematrix operator*(const _zgbmatrix& matA, const zgematrix& matB)
64 {
65 #ifdef CPPL_VERBOSE
66  std::cerr << "# [MARK] operator*(const _zgbmatrix&, const zgematrix&)"
67  << std::endl;
68 #endif//CPPL_VERBOSE
69 
70 #ifdef CPPL_DEBUG
71  if(matA.N!=matB.M){
72  std::cerr << "[ERROR] operator*(zgbmatrix&, zgematrix&)" << std::endl
73  << "These two matrises can not make a product." << std::endl
74  << "Your input was (" << matA.M << "x" << matA.N << ") * ("
75  << matB.M << "x" << matB.N << ")." << std::endl;
76  exit(1);
77  }
78 #endif//CPPL_DEBUG
79 
80  zgematrix newmat( matA.M, matB.N );
81  newmat.zero();
82 
83  long i, j, k;
84 #pragma omp parallel for private(j,k)
85  for(i=0; i<newmat.m; i++){
86  for(j=0; j<newmat.n; j++){
87  for(k=max(0,i-matA.KL); k<min(matA.N,i+matA.KU+1); k++){
88  newmat(i,j)+=matA(i,k)*matB(k,j);
89  }
90  }
91  }
92 
93  matA.destroy();
94  return _(newmat);
95 }
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
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
friend const _zrovector & operator+(const _zrovector &)
Definition: _zrovector-unary.hpp:3
long KL
lower band width
Definition: _zgbmatrix.hpp:9