CPPLapack
 All Classes Files Functions Variables Friends Pages
_dgsmatrix-calc.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! return transposed _dgsmatrix */
3 inline _dgsmatrix t(const _dgsmatrix& mat)
4 {CPPL_VERBOSE_REPORT;
5  const std::vector<dcomponent>::iterator mat_data_end =mat.data.end();
6  for(std::vector<dcomponent>::iterator it=mat.data.begin(); it!=mat_data_end; it++){
7  std::swap(it->i,it->j);
8  }
9 
10  std::swap(mat.rows,mat.cols);
11 
12  return mat;
13 }
14 
15 ///////////////////////////////////////////////////////////////////////////////
16 ///////////////////////////////////////////////////////////////////////////////
17 ///////////////////////////////////////////////////////////////////////////////
18 
19 //=============================================================================
20 /*! search the index of element having the largest absolute value
21  in 0-based numbering system */
22 inline void idamax(CPPL_INT& i, CPPL_INT& j, const _dgsmatrix& mat)
23 {CPPL_VERBOSE_REPORT;
24  std::vector<dcomponent>::const_iterator itx(mat.data.begin());
25  double vmax(0);
26 
27  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
28  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
29  if(vmax < it->v){
30  vmax=fabs(it->v);
31  itx=it;
32  }
33  }
34 
35  i=itx->i;
36  j=itx->j;
37 
38  mat.destroy();
39 }
40 
41 //=============================================================================
42 /*! return its largest absolute value */
43 inline double damax(const _dgsmatrix& mat)
44 {CPPL_VERBOSE_REPORT;
45  std::vector<dcomponent>::const_iterator itx(mat.data.begin());
46  double vmax(0);
47 
48  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
49  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
50  if(vmax < it->v){
51  vmax=fabs(it->v);
52  itx=it;
53  }
54  }
55 
56  mat.destroy();
57  return itx->v;
58 }
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: _dgsmatrix.hpp:13
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _dgsmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
(DO NOT USE) Smart-temporary Real Double-precision General Sparse Matrix Class
Definition: _dgsmatrix.hpp:3
void swap(dcovector &u, dcovector &v)
void destroy() const
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
void idamax(CPPL_INT &i, CPPL_INT &j, const _dgsmatrix &mat)
double damax(const _dgsmatrix &mat)
_dgsmatrix t(const _dgsmatrix &mat)