CPPLapack
 All Classes Files Functions Variables Friends Pages
_zgematrix-calc.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! return transposed zgematrix */
3 inline _zgematrix t(const _zgematrix& mat)
4 {CPPL_VERBOSE_REPORT;
5  zgematrix newmat(mat.n,mat.m);
6 
7  for(CPPL_INT i=0; i<newmat.m; i++){
8  for(CPPL_INT j=0; j<newmat.n; j++){
9  newmat(i,j) =mat(j,i);
10  }
11  }
12 
13  mat.destroy();
14  return _(newmat);
15 }
16 
17 //=============================================================================
18 /*! return its inverse matrix */
19 inline _zgematrix i(const _zgematrix& mat)
20 {CPPL_VERBOSE_REPORT;
21 #ifdef CPPL_DEBUG
22  if(mat.m!=mat.n){
23  ERROR_REPORT;
24  std::cerr << "This matrix is not square and has no inverse matrix." << std::endl
25  << "Your input was (" << mat.m << "x" << mat.n << ")." << std::endl;
26  exit(1);
27  }
28 #endif//CPPL_DEBUG
29 
30  zgematrix mat_cp(mat);
31  zgematrix mat_inv(mat_cp.m,mat_cp.n);
32  mat_inv.identity();
33  mat_cp.zgesv(mat_inv);
34 
35  return _(mat_inv);
36 }
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////
41 
42 //=============================================================================
43 /*! return its conjugate matrix */
44 inline _zgematrix conj(const _zgematrix& mat)
45 {CPPL_VERBOSE_REPORT;
46  for(CPPL_INT i=0; i<mat.m; i++){
47  for(CPPL_INT j=0; j<mat.n; j++){
48  mat(i,j) =std::conj(mat(i,j));
49  }
50  }
51 
52  return mat;
53 }
54 
55 //=============================================================================
56 /*! return its conjugate transposed matrix */
57 inline _zgematrix conjt(const _zgematrix& mat)
58 {CPPL_VERBOSE_REPORT;
59  zgematrix newmat(mat.n,mat.m);
60 
61  for(CPPL_INT i=0; i<newmat.m; i++){
62  for(CPPL_INT j=0; j<newmat.n; j++){
63  newmat(i,j) =std::conj(mat(j,i));
64  }
65  }
66 
67  mat.destroy();
68  return _(newmat);
69 }
70 
71 ///////////////////////////////////////////////////////////////////////////////
72 ///////////////////////////////////////////////////////////////////////////////
73 ///////////////////////////////////////////////////////////////////////////////
74 
75 //=============================================================================
76 /*! search the index of element having the largest absolute value
77  in 0-based numbering system */
78 inline void idamax(CPPL_INT& i, CPPL_INT& j, const _zgematrix& mat)
79 {CPPL_VERBOSE_REPORT;
80  CPPL_INT size =mat.m*mat.n;
81  CPPL_INT inc =1;
82  CPPL_INT index =izamax_(&size, mat.array, &inc) -1;
83  i =index%mat.m;
84  j =index/mat.m;
85 
86  mat.destroy();
87 }
88 
89 //=============================================================================
90 /*! return its largest absolute value */
91 inline comple damax(const _zgematrix& mat)
92 {CPPL_VERBOSE_REPORT;
93  CPPL_INT size =mat.m*mat.n;
94  CPPL_INT inc =1;
95  comple val =mat.array[izamax_(&size, mat.array, &inc) -1];
96 
97  mat.destroy();
98  return val;
99 }
_zgematrix conj(const _zgematrix &mat)
CPPL_INT m
matrix row size
Definition: _zgematrix.hpp:9
_zgematrix i(const _zgematrix &mat)
zgematrix & identity()
CPPL_INT n
matrix column size
Definition: zgematrix.hpp:10
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
_zgematrix t(const _zgematrix &mat)
void destroy() const
comple * array
1D array to store matrix data
Definition: _zgematrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
_zgematrix conjt(const _zgematrix &mat)
comple damax(const _zgematrix &mat)
void idamax(CPPL_INT &i, CPPL_INT &j, const _zgematrix &mat)
_dcovector _(dcovector &vec)
CPPL_INT zgesv(zgematrix &)
CPPL_INT n
matrix column size
Definition: _zgematrix.hpp:10