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