VERB_code_2.3
_zgbmatrix-calc.hpp
1 //=============================================================================
3 inline _zgbmatrix t(const _zgbmatrix& mat)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] t(const _zgbmatrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  zgbmatrix newmat(mat.N, mat.M, mat.KU, mat.KL);
11  for(long i=0; i<newmat.m; i++){
12  for(long j=max(0,i-newmat.kl); j<min(newmat.n,i+newmat.ku+1); j++){
13  newmat(i,j) =mat(j,i);
14  }
15  }
16 
17  mat.destroy();
18  return _(newmat);
19 }
20 
21 //=============================================================================
23 inline _zgematrix i(const _zgbmatrix& mat)
24 {
25 #ifdef CPPL_VERBOSE
26  std::cerr << "# [MARK] i(const _zgbmatrix&)"
27  << std::endl;
28 #endif//CPPL_VERBOSE
29 
30 #ifdef CPPL_DEBUG
31  if(mat.M!=mat.N){
32  std::cerr << "[ERROR] i(_zgbmatrix&) " << std::endl
33  << "This matrix is not square and has no inverse matrix."
34  << std::endl
35  << "Your input was (" << mat.M << "x" << mat.N << ")."
36  << std::endl;
37  exit(1);
38  }
39 #endif//CPPL_DEBUG
40 
41  zgbmatrix mat_cp;
42  mat_cp.shallow_copy(mat);
43 
44  zgematrix mat_inv(mat.M,mat.N);
45  mat_inv.identity();
46 
47  mat_cp.zgbsv(mat_inv);
48 
49  return _(mat_inv);
50 }
51 
55 
56 //=============================================================================
58 inline _zgbmatrix conj(const _zgbmatrix& mat)
59 {
60 #ifdef CPPL_VERBOSE
61  std::cerr << "# [MARK] conj(const _zgbmatrix&)"
62  << std::endl;
63 #endif//CPPL_VERBOSE
64 
65  for(long i=0; i<mat.M; i++){
66  for(long j=max(0,i-mat.KL); j<min(mat.N,i+mat.KU+1); j++){
67  mat(i,j) =std::conj(mat(i,j));
68  }
69  }
70 
71  return mat;
72 }
73 
74 //=============================================================================
76 inline _zgbmatrix conjt(const _zgbmatrix& mat)
77 {
78 #ifdef CPPL_VERBOSE
79  std::cerr << "# [MARK] conjt(const _zgbmatrix&)"
80  << std::endl;
81 #endif//CPPL_VERBOSE
82 
83  zgbmatrix newmat(mat.N, mat.M, mat.KU, mat.KL);
84  for(long i=0; i<newmat.m; i++){
85  for(long j=max(0,i-newmat.kl); j<min(newmat.n,i+newmat.ku+1); j++){
86  newmat(i,j) =std::conj(mat(j,i));
87  }
88  }
89 
90  mat.destroy();
91  return _(newmat);
92 }
void identity()
Definition: zgematrix-misc.hpp:38
double max(double v1, double v2)
Return maximum.
Definition: variousFunctions.cpp:355
long const & n
matrix column size (readable)
Definition: zgbmatrix.hpp:17
long N
matrix column size
Definition: _zgbmatrix.hpp:8
void destroy() const
Definition: _zgbmatrix-misc.hpp:3
long zgbsv(zgematrix &)
Definition: zgbmatrix-lapack.hpp:5
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
long KU
upper band width
Definition: _zgbmatrix.hpp:10
friend _zcovector conjt(const _zrovector &)
Definition: _zrovector-calc.hpp:33
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
friend _zrovector conj(const _zrovector &)
Definition: _zrovector-calc.hpp:20
Complex Double-precision General Band Matrix Class.
Definition: zgbmatrix.hpp:3
long const & m
matrix row size (readable)
Definition: zgbmatrix.hpp:16
long M
matrix row size
Definition: _zgbmatrix.hpp:7
long const & kl
lower band width (readable)
Definition: zgbmatrix.hpp:18
long const & ku
upper band width (readable)
Definition: zgbmatrix.hpp:19
(DO NOT USE) Smart-temporary Complex Double-precision General Band Matrix Class
Definition: _zgbmatrix.hpp:3
friend _zcovector t(const _zrovector &)
Definition: _zrovector-calc.hpp:3
long KL
lower band width
Definition: _zgbmatrix.hpp:9
void shallow_copy(const _zgbmatrix &)
Definition: zgbmatrix-misc.hpp:107