CPPLapack
 All Classes Files Functions Variables Friends Pages
dgsmatrix-cast.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! cast to _zgsmatrix */
4 {CPPL_VERBOSE_REPORT;
5  zgsmatrix newmat(m,n,CPPL_INT(data.size()));
6 
7  const std::vector<dcomponent>::const_iterator data_end =data.end();
8  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
9  newmat.put(it->i, it->j, comple(it->v,0.));
10  }
11 
12  return _(newmat);
13 }
14 
15 ///////////////////////////////////////////////////////////////////////////////
16 ///////////////////////////////////////////////////////////////////////////////
17 ///////////////////////////////////////////////////////////////////////////////
18 
19 //=============================================================================
20 /*! convert to _dgematrix */
22 {CPPL_VERBOSE_REPORT;
23  dgematrix newmat(m,n);
24  newmat.zero();
25 
26  const std::vector<dcomponent>::const_iterator data_end =data.end();
27  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
28  newmat(it->i,it->j) = it->v;
29  }
30 
31  return _(newmat);
32 }
33 
34 ///////////////////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////////////////
37 
38 //=============================================================================
39 /*! convert to dgrmatrix */
41 {CPPL_VERBOSE_REPORT;
42  //////// resize ////////
43  dgrmatrix newmat;
44  newmat.m =m;
45  newmat.n =n;
46  newmat.a.resize(data.size());
47  newmat.ia.resize(m+1);
48  newmat.ja.resize(data.size());
49 
50  //////// copy ////////
51  newmat.ia[0] =1;//one-based
52  CPPL_INT k=0;
53  for(CPPL_INT i=0; i<m; i++){
54  //// make map ////
55  const std::vector<CPPL_INT>::const_iterator rows_i_end =rows[i].end();
56  std::map<CPPL_INT,CPPL_INT> jc;
57  for(std::vector<CPPL_INT>::const_iterator rit=rows[i].begin(); rit!=rows_i_end; rit++){
58  jc.insert( std::make_pair(data[*rit].j, *rit) );
59  }
60  //// assign ////
61  const std::map<CPPL_INT,CPPL_INT>::const_iterator jc_end =jc.end();
62  for(std::map<CPPL_INT,CPPL_INT>::const_iterator jcit=jc.begin(); jcit!=jc_end; jcit++){
63  newmat.a[k] =data[(*jcit).second].v;
64  newmat.ja[k] =CPPL_INT((*jcit).first)+1;//one-based
65  k++;
66  }
67  newmat.ia[i+1] =k+1;//one-based
68  }
69 
70  return newmat;
71 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
std::vector< double > a
matrix component values
Definition: dgrmatrix.hpp:11
dgrmatrix to_dgrmatrix() const
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
std::vector< CPPL_INT > ia
rowIndex (NOT zero-based BUT one-based indexing)
Definition: dgrmatrix.hpp:12
dgematrix & zero()
_zgsmatrix to_zgsmatrix() const
_dgematrix i(const _dgbmatrix &mat)
(DO NOT USE) Smart-temporary Real Double-precision General Sparse Matrix Class
Definition: _zgsmatrix.hpp:3
zgsmatrix & put(const CPPL_INT &, const CPPL_INT &, const comple &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT n
matrix column size
Definition: dgrmatrix.hpp:10
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
_dgematrix to_dgematrix() const
CPPL_INT m
matrix row size
Definition: dgrmatrix.hpp:9
std::vector< CPPL_INT > ja
columns (NOT zero-based BUT one-based indexing)
Definition: dgrmatrix.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
Real Double-precision General Compressed Sparse Row (CSR) Matrix Class.
Definition: dgrmatrix.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9