CPPLapack
 All Classes Files Functions Variables Friends Pages
Functions
dsymatrix-calc.hpp File Reference

Go to the source code of this file.

Functions

_dsymatrix t (const dsymatrix &mat)
 
_dsymatrix i (const dsymatrix &mat)
 
void idamax (CPPL_INT &i, CPPL_INT &j, const dsymatrix &mat)
 
double damax (const dsymatrix &mat)
 

Function Documentation

_dsymatrix t ( const dsymatrix mat)
inline

return transposed dgematrix

Definition at line 3 of file dsymatrix-calc.hpp.

References _().

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  dsymatrix newmat(mat);
11  return _(newmat);
12 }
Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].
Definition: dsymatrix.hpp:3
_dcovector _(dcovector &vec)
_dsymatrix i ( const dsymatrix mat)
inline

return its inverse matrix

Definition at line 16 of file dsymatrix-calc.hpp.

References _(), dsymatrix::array, dsymatrix::complete(), dsymatrix::identity(), and dsymatrix::n.

Referenced by damax().

17 {CPPL_VERBOSE_REPORT;
18  dsymatrix mat_cp =mat;
19  dsymatrix mat_inv(mat.n);
20  mat_inv.identity();
21  mat_inv.complete();
22 
23  char UPLO('l');
24  CPPL_INT NRHS(mat.n), LDA(mat.n), *IPIV(new CPPL_INT[mat.n]), LDB(mat.n), LWORK(-1), INFO(1);
25  double *WORK( new double[1] );
26  dsysv_(&UPLO, &mat.n, &NRHS, mat_cp.array, &LDA, IPIV, mat_inv.array, &LDB, WORK, &LWORK, &INFO);
27 
28  LWORK = CPPL_INT(WORK[0]);
29  delete [] WORK;
30  WORK = new double[LWORK];
31  dsysv_(&UPLO, &mat.n, &NRHS, mat_cp.array, &LDA, IPIV, mat_inv.array, &LDB, WORK, &LWORK, &INFO);
32 
33  delete [] WORK;
34  delete [] IPIV;
35  if(INFO!=0){
36  WARNING_REPORT;
37  std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
38  }
39 
40  return _(mat_inv);
41 }
Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].
Definition: dsymatrix.hpp:3
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
double * array
1D array to store matrix data
Definition: dsymatrix.hpp:11
_dcovector _(dcovector &vec)
void idamax ( CPPL_INT &  i,
CPPL_INT &  j,
const dsymatrix mat 
)
inline

search the index of element having the largest absolute value in 0-based numbering system

Definition at line 49 of file dsymatrix-calc.hpp.

References dsymatrix::darray, and dsymatrix::n.

Referenced by damax().

50 {CPPL_VERBOSE_REPORT;
51  i=j=0;
52  double val =0.;
53 
54  for(CPPL_INT J=0; J<mat.n; J++){
55  for(CPPL_INT I=J; I<mat.n; I++){
56  if(val<fabs(mat.darray[J][I]) ){
57  val =fabs(mat.darray[J][I]);
58  i=I;
59  j=J;
60  }
61  }
62  }
63 }
_dsymatrix i(const dsymatrix &mat)
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
double ** darray
array of pointers of column head addresses
Definition: dsymatrix.hpp:12
double damax ( const dsymatrix mat)
inline

return its largest absolute value

Definition at line 67 of file dsymatrix-calc.hpp.

References i(), and idamax().

68 {CPPL_VERBOSE_REPORT;
69  CPPL_INT i,j;
70  idamax(i, j, mat);
71  return mat(i,j);
72 }
_dsymatrix i(const dsymatrix &mat)
void idamax(CPPL_INT &i, CPPL_INT &j, const dsymatrix &mat)