CPPLapack
 All Classes Files Functions Variables Friends Pages
_dsymatrix-calc.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! return transposed _dsymatrix */
3 inline _dsymatrix t(const _dsymatrix& mat)
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  WARNING_REPORT;
7  std::cerr << "This function call has no effect since the matrix is symmetric." << std::endl;
8 #endif//CPPL_DEBUG
9 
10  return mat;
11 }
12 
13 //=============================================================================
14 /*! return its inverse matrix */
15 inline _dsymatrix i(const _dsymatrix& mat)
16 {CPPL_VERBOSE_REPORT;
17  dsymatrix mat_cp(mat);
18  dsymatrix mat_inv(mat_cp.n);
19  mat_inv.identity();
20 
21  char UPLO('l');
22  CPPL_INT NRHS(mat.n), LDA(mat.n), *IPIV(new CPPL_INT[mat.n]), LDB(mat.n), LWORK(-1), INFO(1);
23  double *WORK( new double[1] );
24  dsysv_(&UPLO, &mat_cp.n, &NRHS, mat_cp.array, &LDA, IPIV, mat_inv.array, &LDB, WORK, &LWORK, &INFO);
25 
26  LWORK = CPPL_INT(WORK[0]);
27  delete [] WORK;
28  WORK = new double[LWORK];
29  dsysv_(&UPLO, &mat_cp.n, &NRHS, mat_cp.array, &LDA, IPIV, mat_inv.array, &LDB, WORK, &LWORK, &INFO);
30  delete [] WORK;
31  delete [] IPIV;
32 
33  if(INFO!=0){
34  WARNING_REPORT;
35  std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
36  }
37 
38  return _(mat_inv);
39 }
40 
41 ///////////////////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////////////////////////
43 ///////////////////////////////////////////////////////////////////////////////
44 
45 //=============================================================================
46 /*! search the index of element having the largest absolute value
47  in 0-based numbering system */
48 inline void idamax(CPPL_INT& i, CPPL_INT& j, const _dsymatrix& mat)
49 {CPPL_VERBOSE_REPORT;
50  dsymatrix newmat =mat;
51  idamax(i, j, newmat);
52 }
53 
54 //=============================================================================
55 /*! return its largest absolute value */
56 inline double damax(const _dsymatrix& mat)
57 {CPPL_VERBOSE_REPORT;
58  dsymatrix newmat =mat;
59  return damax(newmat);
60 }
_dsymatrix t(const _dsymatrix &mat)
_dsymatrix i(const _dsymatrix &mat)
Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].
Definition: dsymatrix.hpp:3
dsymatrix & identity()
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
void idamax(CPPL_INT &i, CPPL_INT &j, const _dsymatrix &mat)
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Matrix Class
Definition: _dsymatrix.hpp:3
double * array
1D array to store matrix data
Definition: dsymatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dsymatrix.hpp:11
double damax(const _dsymatrix &mat)
_dcovector _(dcovector &vec)