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++){ for(long j=0; j<newmat.N; j++){
13  newmat(i,j) =mat(j,i);
14  }}
15 
16  return _(newmat);
17 }
18 
19 //=============================================================================
21 inline _zgematrix i(const zgematrix& mat)
22 {
23 #ifdef CPPL_VERBOSE
24  std::cerr << "# [MARK] i(const zgematrix&)"
25  << std::endl;
26 #endif//CPPL_VERBOSE
27 
28 #ifdef CPPL_DEBUG
29  if(mat.M!=mat.N){
30  std::cerr << "[ERROR] i(zgematrix&) " << std::endl
31  << "This matrix is not square and has no inverse matrix."
32  << std::endl
33  << "Your input was (" << mat.M << "x" << mat.N << ")."
34  << std::endl;
35  exit(1);
36  }
37 #endif//CPPL_DEBUG
38 
39  zgematrix mat_cp(mat), mat_inv(mat.M,mat.N);
40  mat_inv.identity();
41  mat_cp.zgesv(mat_inv);
42 
43  return _(mat_inv);
44 }
45 
49 
50 //=============================================================================
52 inline _zgematrix conj(const zgematrix& mat)
53 {
54 #ifdef CPPL_VERBOSE
55  std::cerr << "# [MARK] conj(const zgematrix&)"
56  << std::endl;
57 #endif//CPPL_VERBOSE
58 
59  zgematrix newmat(mat.M,mat.N);
60  for(long i=0; i<mat.M; i++){ for(long j=0; j<mat.N; j++){
61  newmat(i,j) =std::conj(mat(i,j));
62  }}
63 
64  return _(newmat);
65 }
66 
67 //=============================================================================
69 inline _zgematrix conjt(const zgematrix& mat)
70 {
71 #ifdef CPPL_VERBOSE
72  std::cerr << "# [MARK] conjt(const zgematrix&)"
73  << std::endl;
74 #endif//CPPL_VERBOSE
75 
76  zgematrix newmat(mat.N,mat.M);
77  for(long i=0; i<newmat.M; i++){ for(long j=0; j<newmat.N; j++){
78  newmat(i,j) =std::conj(mat(j,i));
79  }}
80 
81  return _(newmat);
82 }
83 
87 
88 //=============================================================================
91 inline void idamax(long& i, long& j, const zgematrix& mat)
92 {
93 #ifdef CPPL_VERBOSE
94  std::cerr << "# [MARK] idamax(long&, long&, const zgematrix&)"
95  << std::endl;
96 #endif//CPPL_VERBOSE
97 
98  long index( izamax_(mat.M*mat.N, mat.Array, 1) -1 );
99  i =index%mat.M;
100  j =index/mat.M;
101 }
102 
103 //=============================================================================
105 inline std::complex<double> damax(const zgematrix& mat)
106 {
107 #ifdef CPPL_VERBOSE
108  std::cerr << "# [MARK] damax(const zgematrix&)"
109  << std::endl;
110 #endif//CPPL_VERBOSE
111 
112  return mat.Array[izamax_(mat.M*mat.N, mat.Array, 1) -1];
113 }
friend std::complex< double > damax(const _zrovector &)
Definition: _zrovector-calc.hpp:82
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
friend _zrovector conj(const _zrovector &)
Definition: _zrovector-calc.hpp:20
friend _zcovector t(const _zrovector &)
Definition: _zrovector-calc.hpp:3
friend long idamax(const _zrovector &)
Definition: _zrovector-calc.hpp:68