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

Go to the source code of this file.

Functions

_dgsmatrix t (const dgsmatrix &mat)
 
void idamax (CPPL_INT &i, CPPL_INT &j, const dgsmatrix &mat)
 
double damax (const dgsmatrix &mat)
 

Function Documentation

_dgsmatrix t ( const dgsmatrix mat)
inline

return transposed dgsmatrix

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

References _(), dgsmatrix::cols, dgsmatrix::data, dgsmatrix::m, dgsmatrix::n, dgsmatrix::rows, and swap().

4 {CPPL_VERBOSE_REPORT;
5  dgsmatrix newmat =mat;
6 
7  std::swap(newmat.m,newmat.n);
8  std::swap(newmat.rows,newmat.cols);
9  const std::vector<dcomponent>::iterator newmat_data_end =newmat.data.end();
10  for(std::vector<dcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
11  std::swap(it->i,it->j);
12  }
13 
14  return _(newmat);
15 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: dgsmatrix.hpp:13
void swap(dcovector &u, dcovector &v)
_dcovector _(dcovector &vec)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: dgsmatrix.hpp:12
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
void idamax ( CPPL_INT &  i,
CPPL_INT &  j,
const dgsmatrix mat 
)
inline

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

Definition at line 23 of file dgsmatrix-calc.hpp.

References dgsmatrix::data.

24 {CPPL_VERBOSE_REPORT;
25  //////// exception ////////
26  if(mat.data.size()==0){
27  WARNING_REPORT;
28  std::cerr << "The dgsmatrix is a zero matrix." << std::endl;
29  return;
30  }
31 
32  //////// find ////////
33  std::vector<dcomponent>::const_iterator itx(mat.data.begin());
34  double vmax =0.;
35 
36  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
37  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
38  if( vmax < fabs(it->v) ){
39  vmax =fabs(it->v);
40  itx =it;
41  }
42  }
43 
44  i =itx->i;
45  j =itx->j;
46 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
_dgematrix i(const _dgbmatrix &mat)
friend _dgematrix i(const _dgematrix &)
double damax ( const dgsmatrix mat)
inline

return its largest absolute value

Definition at line 50 of file dgsmatrix-calc.hpp.

References dgsmatrix::data.

51 {CPPL_VERBOSE_REPORT;
52  //////// exception ////////
53  if(mat.data.size()==0){
54  return 0.;
55  }
56 
57  //////// find ////////
58  std::vector<dcomponent>::const_iterator itx(mat.data.begin());
59  double vmax =0.;
60 
61  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
62  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
63  if( vmax < fabs(it->v) ){
64  vmax =fabs(it->v);
65  itx =it;
66  }
67  }
68 
69  return itx->v;
70 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11