My Project
_zgematrix-calc.hpp
1 //=============================================================================
3 inline _zgematrix t(const _zgematrix& mat)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] t(const _zgematrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  zgematrix newmat(mat.N,mat.M);
11 
12  for(long i=0; i<newmat.m; i++){
13  for(long j=0; j<newmat.n; j++){
14  newmat(i,j) =mat(j,i);
15  }
16  }
17 
18  mat.destroy();
19  return _(newmat);
20 }
21 
22 //=============================================================================
24 inline _zgematrix i(const _zgematrix& mat)
25 {
26 #ifdef CPPL_VERBOSE
27  std::cerr << "# [MARK] i(const _zgematrix&)"
28  << std::endl;
29 #endif//CPPL_VERBOSE
30 
31 #ifdef CPPL_DEBUG
32  if(mat.M!=mat.N){
33  std::cerr << "[ERROR] t(_zgematrix&) " << std::endl
34  << "This matrix is not square and has no inverse matrix."
35  << std::endl
36  << "Your input was (" << mat.M << "x" << mat.N << ")."
37  << std::endl;
38  exit(1);
39  }
40 #endif//CPPL_DEBUG
41  zgematrix 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.zgesv(mat_inv);
48 
49  return _(mat_inv);
50 }
51 
55 
56 //=============================================================================
58 inline _zgematrix conj(const _zgematrix& mat)
59 {
60 #ifdef CPPL_VERBOSE
61  std::cerr << "# [MARK] conj(const _zgematrix&)"
62  << std::endl;
63 #endif//CPPL_VERBOSE
64 
65  for(long i=0; i<mat.M; i++){ for(long j=0; j<mat.N; j++){
66  mat(i,j) =std::conj(mat(i,j));
67  }}
68 
69  return mat;
70 }
71 
72 //=============================================================================
74 inline _zgematrix conjt(const _zgematrix& mat)
75 {
76 #ifdef CPPL_VERBOSE
77  std::cerr << "# [MARK] conjt(const _zgematrix&)"
78  << std::endl;
79 #endif//CPPL_VERBOSE
80 
81  zgematrix newmat(mat.N,mat.M);
82  for(long i=0; i<newmat.m; i++){
83  for(long j=0; j<newmat.n; j++){
84  newmat(i,j) =std::conj(mat(j,i));
85  }
86  }
87 
88  mat.destroy();
89  return _(newmat);
90 }
91 
95 
96 //=============================================================================
99 inline void idamax(long& i, long& j, const _zgematrix& mat)
100 {
101 #ifdef CPPL_VERBOSE
102  std::cerr << "# [MARK] idamax(long&, long&, const _zgematrix&)"
103  << std::endl;
104 #endif//CPPL_VERBOSE
105 
106  long index( izamax_(mat.M*mat.N, mat.Array, 1) -1 );
107  i =index%mat.M;
108  j =index/mat.M;
109 
110  mat.destroy();
111 }
112 
113 //=============================================================================
115 inline std::complex<double> damax(const _zgematrix& mat)
116 {
117 #ifdef CPPL_VERBOSE
118  std::cerr << "# [MARK] damax(const _zgematrix&)"
119  << std::endl;
120 #endif//CPPL_VERBOSE
121 
122  std::complex<double> val( mat.Array[izamax_(mat.M*mat.N, mat.Array, 1) -1] );
123 
124  mat.destroy();
125  return val;
126 }
friend std::complex< double > damax(const _zrovector &)
Definition: _zrovector-calc.hpp:82
void shallow_copy(const _zgematrix &)
Definition: zgematrix-misc.hpp:103
long N
matrix column size
Definition: _zgematrix.hpp:8
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
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
void destroy() const
Definition: _zgematrix-misc.hpp:3
long zgesv(zgematrix &)
Definition: zgematrix-lapack.hpp:5
friend _zrovector conj(const _zrovector &)
Definition: _zrovector-calc.hpp:20
std::complex< double > * Array
1D Array to store matrix data
Definition: _zgematrix.hpp:9
long M
matrix row size
Definition: _zgematrix.hpp:7
friend _zcovector t(const _zrovector &)
Definition: _zrovector-calc.hpp:3
friend long idamax(const _zrovector &)
Definition: _zrovector-calc.hpp:68