CPPLapack
 All Classes Files Functions Variables Friends Pages
zgematrix-_zgbmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! zgematrix+=_zgbmatrix operator */
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(n!=mat.n || m!=mat.m){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  for(CPPL_INT i=0; i<mat.m; i++){
15  const CPPL_INT jmax =std::min(n,i+mat.ku+1);
16  for(CPPL_INT j=std::max(CPPL_INT(0),i-mat.kl); j<jmax; j++){
17  operator()(i,j)+=mat(i,j);
18  }
19  }
20 
21  mat.destroy();
22  return *this;
23 }
24 
25 //=============================================================================
26 /*! zgematrix-=_zgbmatrix operator */
28 {CPPL_VERBOSE_REPORT;
29 #ifdef CPPL_DEBUG
30  if(n!=mat.n || m!=mat.m){
31  ERROR_REPORT;
32  std::cerr << "These two matrises can not make a subtraction." << std::endl
33  << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
34  exit(1);
35  }
36 #endif//CPPL_DEBUG
37 
38  for(CPPL_INT i=0; i<mat.m; i++){
39  const CPPL_INT jmax =std::min(n,i+mat.ku+1);
40  for(CPPL_INT j=std::max(CPPL_INT(0),i-mat.kl); j<jmax; j++){
41  operator()(i,j) -= mat(i,j);
42  }
43  }
44 
45  mat.destroy();
46  return *this;
47 }
48 //=============================================================================
49 /*! zgematrix*=_zgbmatrix operator */
51 {CPPL_VERBOSE_REPORT;
52 #ifdef CPPL_DEBUG
53  if(n!=mat.m){
54  ERROR_REPORT;
55  std::cerr << "These two matrises can not make a product." << std::endl
56  << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
57  exit(1);
58  }
59 #endif//CPPL_DEBUG
60 
61  zgematrix newmat(m,mat.n);
62  newmat.zero();
63 
64  for(CPPL_INT i=0; i<newmat.m; i++){
65  for(CPPL_INT j=0; j<newmat.n; j++){
66  const CPPL_INT kmax =std::min(mat.m,j+mat.kl+1);
67  for(CPPL_INT k=std::max(CPPL_INT(0),j-mat.ku); k<kmax; k++){
68  newmat(i,j) += operator()(i,k)*mat(k,j);
69  }
70  }
71  }
72 
73  swap(*this,newmat);
74  mat.destroy();
75  return *this;
76 }
77 
78 ///////////////////////////////////////////////////////////////////////////////
79 ///////////////////////////////////////////////////////////////////////////////
80 ///////////////////////////////////////////////////////////////////////////////
81 
82 //=============================================================================
83 /*! zgematrix+_zgbmatrix operator */
84 inline _zgematrix operator+(const zgematrix& matA, const _zgbmatrix& matB)
85 {CPPL_VERBOSE_REPORT;
86 #ifdef CPPL_DEBUG
87  if(matA.n!=matB.n || matA.m!=matB.m){
88  ERROR_REPORT;
89  std::cerr << "These two matrises can not make a summation." << std::endl
90  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
91  exit(1);
92  }
93 #endif//CPPL_DEBUG
94 
95  zgematrix newmat(matA);
96 
97  for(CPPL_INT i=0; i<matB.m; i++){
98  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
99  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
100  newmat(i,j)+=matB(i,j);
101  }
102  }
103 
104  matB.destroy();
105  return _(newmat);
106 }
107 
108 //=============================================================================
109 /*! zgematrix-_zgbmatrix operator */
110 inline _zgematrix operator-(const zgematrix& matA, const _zgbmatrix& matB)
111 {CPPL_VERBOSE_REPORT;
112 #ifdef CPPL_DEBUG
113  if(matA.n!=matB.n || matA.m!=matB.m){
114  ERROR_REPORT;
115  std::cerr << "These two matrises can not make a summation." << std::endl
116  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
117  exit(1);
118  }
119 #endif//CPPL_DEBUG
120 
121  zgematrix newmat(matA);
122 
123  for(CPPL_INT i=0; i<matB.m; i++){
124  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
125  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
126  newmat(i,j)-=matB(i,j);
127  }
128  }
129 
130  matB.destroy();
131  return _(newmat);
132 }
133 
134 //=============================================================================
135 /*! zgematrix*_zgbmatrix operator */
136 inline _zgematrix operator*(const zgematrix& matA, const _zgbmatrix& matB)
137 {CPPL_VERBOSE_REPORT;
138 #ifdef CPPL_DEBUG
139  if(matA.n!=matB.m){
140  ERROR_REPORT;
141  std::cerr << "These two matrises can not make a product." << std::endl
142  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
143  exit(1);
144  }
145 #endif//CPPL_DEBUG
146 
147  zgematrix newmat( matA.m, matB.n );
148  newmat.zero();
149 
150  for(CPPL_INT i=0; i<newmat.m; i++){
151  for(CPPL_INT j=0; j<newmat.n; j++){
152  const CPPL_INT kmax =std::min(matB.m,j+matB.kl+1);
153  for(CPPL_INT k=std::max(CPPL_INT(0),j-matB.ku); k<kmax; k++){
154  newmat(i,j)+=matA(i,k)*matB(k,j);
155  }
156  }
157  }
158 
159  matB.destroy();
160  return _(newmat);
161 }
CPPL_INT ku
upper band width
Definition: _zgbmatrix.hpp:12
_zgematrix operator-(const zgematrix &matA, const _zgbmatrix &matB)
CPPL_INT kl
lower band width
Definition: _zgbmatrix.hpp:11
comple & operator()(const CPPL_INT &, const CPPL_INT &)
Definition: zgematrix-io.hpp:3
zgematrix & operator-=(const zgematrix &)
_dgematrix i(const _dgbmatrix &mat)
void destroy() const
friend _zgematrix i(const zgematrix &)
_zgematrix operator*(const zgematrix &matA, const _zgbmatrix &matB)
CPPL_INT n
matrix column size
Definition: zgematrix.hpp:10
zgematrix & operator*=(const zgematrix &)
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
zgematrix & zero()
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
(DO NOT USE) Smart-temporary Complex Double-precision General Band Matrix Class
Definition: _zgbmatrix.hpp:3
zgematrix & operator+=(const zgematrix &)
friend void swap(zgematrix &, zgematrix &)
CPPL_INT m
matrix row size
Definition: _zgbmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: _zgbmatrix.hpp:10
_dcovector _(dcovector &vec)
_zgematrix operator+(const zgematrix &matA, const _zgbmatrix &matB)