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