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