CPPLapack
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Public Attributes | Friends | List of all members
dgsmatrix Class Reference

Real Double-precision General Sparse Matrix Class. More...

#include <dgsmatrix.hpp>

Public Member Functions

 dgsmatrix ()
 
 dgsmatrix (const dgsmatrix &)
 
 dgsmatrix (const _dgsmatrix &)
 
 dgsmatrix (const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0)
 
 dgsmatrix (const char *)
 
 ~dgsmatrix ()
 
_zgsmatrix to_zgsmatrix () const
 
_dgematrix to_dgematrix () const
 
dgrmatrix to_dgrmatrix () const
 
double operator() (const CPPL_INT &, const CPPL_INT &) const
 
double & operator() (const CPPL_INT &, const CPPL_INT &)
 
dgsmatrixput (const CPPL_INT &, const CPPL_INT &, const double &)
 
dgsmatrixdel (const CPPL_INT, const CPPL_INT)
 
dgsmatrixdel (const CPPL_INT)
 
void write (const char *) const
 
void read (const char *)
 
void clear ()
 
dgsmatrixzero ()
 
dgsmatrixidentity ()
 
void chsign ()
 
void copy (const dgsmatrix &)
 
void shallow_copy (const _dgsmatrix &)
 
dgsmatrixresize (const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
 
void stretch (const CPPL_INT &, const CPPL_INT &)
 
bool isListed (const CPPL_INT &, const CPPL_INT &) const
 
CPPL_INT number (const CPPL_INT &, const CPPL_INT &)
 
void diet (const double=DBL_MIN)
 
void checkup ()
 
_drovector row (const CPPL_INT &) const
 
_dcovector col (const CPPL_INT &) const
 
CPPL_INT pardiso (dcovector &) const
 
dgsmatrixoperator= (const dgsmatrix &)
 
dgsmatrixoperator= (const _dgsmatrix &)
 
dgsmatrixoperator+= (const dgsmatrix &)
 
dgsmatrixoperator+= (const _dgsmatrix &)
 
dgsmatrixoperator-= (const dgsmatrix &)
 
dgsmatrixoperator-= (const _dgsmatrix &)
 
dgsmatrixoperator*= (const dgsmatrix &)
 
dgsmatrixoperator*= (const _dgsmatrix &)
 
dgsmatrixoperator*= (const double &)
 
dgsmatrixoperator/= (const double &)
 

Public Attributes

CPPL_INT m
 matrix row size More...
 
CPPL_INT n
 matrix column size More...
 
std::vector< dcomponentdata
 matrix data More...
 
std::vector< std::vector
< CPPL_INT > > 
rows
 array of vector to store the entry information of component for each row More...
 
std::vector< std::vector
< CPPL_INT > > 
cols
 array of vector to store the entry information of component for each column More...
 

Friends

std::ostream & operator<< (std::ostream &, const dgsmatrix &)
 
void swap (dgsmatrix &, dgsmatrix &)
 
_dgsmatrix _ (dgsmatrix &)
 
_dgsmatrix t (const dgsmatrix &)
 
void idamax (CPPL_INT &, CPPL_INT &, const dgsmatrix &)
 
double damax (const dgsmatrix &)
 
const dgsmatrixoperator+ (const dgsmatrix &)
 
_dgsmatrix operator- (const dgsmatrix &)
 
_dgematrix operator+ (const dgsmatrix &, const dgematrix &)
 
_dgematrix operator+ (const dgsmatrix &, const _dgematrix &)
 
_dgematrix operator+ (const dgsmatrix &, const dsymatrix &)
 
_dgematrix operator+ (const dgsmatrix &, const _dsymatrix &)
 
_dgematrix operator+ (const dgsmatrix &, const dgbmatrix &)
 
_dgematrix operator+ (const dgsmatrix &, const _dgbmatrix &)
 
_dgsmatrix operator+ (const dgsmatrix &, const dgsmatrix &)
 
_dgsmatrix operator+ (const dgsmatrix &, const _dgsmatrix &)
 
_dgsmatrix operator+ (const dgsmatrix &, const dssmatrix &)
 
_dgsmatrix operator+ (const dgsmatrix &, const _dssmatrix &)
 
_dgematrix operator- (const dgsmatrix &, const dgematrix &)
 
_dgematrix operator- (const dgsmatrix &, const _dgematrix &)
 
_dgematrix operator- (const dgsmatrix &, const dsymatrix &)
 
_dgematrix operator- (const dgsmatrix &, const _dsymatrix &)
 
_dgematrix operator- (const dgsmatrix &, const dgbmatrix &)
 
_dgematrix operator- (const dgsmatrix &, const _dgbmatrix &)
 
_dgsmatrix operator- (const dgsmatrix &, const dgsmatrix &)
 
_dgsmatrix operator- (const dgsmatrix &, const _dgsmatrix &)
 
_dgsmatrix operator- (const dgsmatrix &, const dssmatrix &)
 
_dgsmatrix operator- (const dgsmatrix &, const _dssmatrix &)
 
_dcovector operator* (const dgsmatrix &, const dcovector &)
 
_dcovector operator* (const dgsmatrix &, const _dcovector &)
 
_dgematrix operator* (const dgsmatrix &, const dgematrix &)
 
_dgematrix operator* (const dgsmatrix &, const _dgematrix &)
 
_dgematrix operator* (const dgsmatrix &, const dsymatrix &)
 
_dgematrix operator* (const dgsmatrix &, const _dsymatrix &)
 
_dgematrix operator* (const dgsmatrix &, const dgbmatrix &)
 
_dgematrix operator* (const dgsmatrix &, const _dgbmatrix &)
 
_dgsmatrix operator* (const dgsmatrix &, const dgsmatrix &)
 
_dgsmatrix operator* (const dgsmatrix &, const _dgsmatrix &)
 
_dgsmatrix operator* (const dgsmatrix &, const dssmatrix &)
 
_dgsmatrix operator* (const dgsmatrix &, const _dssmatrix &)
 
_dgsmatrix operator* (const dgsmatrix &, const double &)
 
_dgsmatrix operator/ (const dgsmatrix &, const double &)
 
_dgsmatrix operator* (const double &, const dgsmatrix &)
 

Detailed Description

Real Double-precision General Sparse Matrix Class.

Definition at line 3 of file dgsmatrix.hpp.

Constructor & Destructor Documentation

dgsmatrix::dgsmatrix ( )
inline

dgsmatrix constructor without arguments

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

References cols, data, m, n, and rows.

4 {CPPL_VERBOSE_REPORT;
5  //////// initialize ////////
6  m =0;
7  n =0;
8  data.clear();
9  rows.clear();
10  cols.clear();
11 }
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
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
dgsmatrix::dgsmatrix ( const dgsmatrix mat)
inline

dgsmatrix copy constructor

Definition at line 19 of file dgsmatrix-constructor.hpp.

References cols, copy(), data, m, n, and rows.

20 {CPPL_VERBOSE_REPORT;
21  m =mat.m;
22  n =mat.n;
23  data.clear();
24  rows.clear();
25  cols.clear();
26  copy(mat);
27 }
void copy(const dgsmatrix &)
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
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
dgsmatrix::dgsmatrix ( const _dgsmatrix mat)
inline

dgsmatrix constructor to cast _dgsmatrix

Definition at line 31 of file dgsmatrix-constructor.hpp.

References cols, _dgsmatrix::cols, _dgsmatrix::data, data, m, _dgsmatrix::m, _dgsmatrix::n, n, _dgsmatrix::nullify(), rows, and _dgsmatrix::rows.

32 {CPPL_VERBOSE_REPORT;
33  m =mat.m;
34  n =mat.n;
35  data.clear();
36  rows.clear();
37  cols.clear();
38 
39  data.swap(mat.data);
40  rows.swap(mat.rows);
41  cols.swap(mat.cols);
42 
43  mat.nullify();
44 }
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< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
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 n
matrix column size
Definition: _dgsmatrix.hpp:10
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
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
void nullify() const
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
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
dgsmatrix::dgsmatrix ( const CPPL_INT &  _m,
const CPPL_INT &  _n,
const CPPL_INT  _c = 0 
)
inline

dgsmatrix constructor with size specification

Definition at line 52 of file dgsmatrix-constructor.hpp.

References cols, data, m, n, and rows.

53 {CPPL_VERBOSE_REPORT;
54 #ifdef CPPL_DEBUG
55  if( _m<0 || _n<0 || _c<0 ){
56  ERROR_REPORT;
57  std::cerr << "Matrix sizes and the length of arrays must be positive integers. " << std::endl
58  << "Your input was (" << _m << "," << _n << "," << _c << ")." << std::endl;
59  exit(1);
60  }
61 #endif//CPPL_DEBUG
62 
63  //////// initialize ////////
64  m =_m;
65  n =_n;
66  data.resize(0);
67  data.reserve(_c);
68  rows.resize(m);
69  cols.resize(n);
70 }
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
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
dgsmatrix::dgsmatrix ( const char *  filename)
inline

dgsmatrix constructor with filename

Definition at line 74 of file dgsmatrix-constructor.hpp.

References cols, data, read(), and rows.

75 {CPPL_VERBOSE_REPORT;
76  data.clear();
77  rows.clear();
78  cols.clear();
79 
80  //// read ////
81  read(filename);
82 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
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 read(const char *)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: dgsmatrix.hpp:12
dgsmatrix::~dgsmatrix ( )
inline

dgsmatrix destructor

Definition at line 90 of file dgsmatrix-constructor.hpp.

References cols, data, and rows.

91 {CPPL_VERBOSE_REPORT;
92  data.clear();
93  rows.clear();
94  cols.clear();
95 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
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

Member Function Documentation

_zgsmatrix dgsmatrix::to_zgsmatrix ( ) const
inline

cast to _zgsmatrix

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

References _, data, m, n, and zgsmatrix::put().

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 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix dgsmatrix::to_dgematrix ( ) const
inline

convert to _dgematrix

Definition at line 21 of file dgsmatrix-cast.hpp.

References _, data, m, n, and dgematrix::zero().

Referenced by operator+(), and operator-().

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 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
dgrmatrix dgsmatrix::to_dgrmatrix ( ) const
inline

convert to dgrmatrix

Definition at line 40 of file dgsmatrix-cast.hpp.

References dgrmatrix::a, data, i(), dgrmatrix::ia, dgrmatrix::ja, dgrmatrix::m, m, dgrmatrix::n, n, and rows.

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 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
std::vector< double > a
matrix component values
Definition: dgrmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
std::vector< CPPL_INT > ia
rowIndex (NOT zero-based BUT one-based indexing)
Definition: dgrmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dgrmatrix.hpp:10
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
double dgsmatrix::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

operator() for const object

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

References data, i(), m, n, and rows.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if( i<0 || j<0 || m<=i || n<=j ){
7  ERROR_REPORT;
8  std::cerr << "The required component is out of the matrix size." << std::endl
9  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  //// search (i,j) component ////
15  const std::vector<CPPL_INT>::const_iterator rows_i_end =rows[i].end();
16  for(std::vector<CPPL_INT>::const_iterator p=rows[i].begin(); p!=rows_i_end; p++){
17  if(data[*p].j==j){ return data[*p].v; }
18  }
19 
20  //// (i,j) component was not found ////
21  return 0.0;
22 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
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
double & dgsmatrix::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

operator() for const object

Definition at line 26 of file dgsmatrix-io.hpp.

References cols, data, i(), m, n, and rows.

27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if( i<0 || j<0 || m<=i || n<=j ){
30  ERROR_REPORT;
31  std::cerr << "The required component is out of the matrix size." << std::endl
32  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  //////// search (i,j) component ////////
38  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
39  for(std::vector<CPPL_INT>::iterator p=rows[i].begin(); p!=rows_i_end; p++){
40  if(data[*p].j==j){ return data[*p].v; }
41  }
42 
43  //////// (i,j) component not found ////////
44  rows[i].push_back(CPPL_INT(data.size()));
45  cols[j].push_back(CPPL_INT(data.size()));
46  data.push_back(dcomponent(i,j,0.));
47  return data.back().v;
48 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
Component Class for Real Double-precision Sparse Matrix Classes.
Definition: dcomponent.hpp:3
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
_dgematrix i(const _dgbmatrix &mat)
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
dgsmatrix & dgsmatrix::put ( const CPPL_INT &  i,
const CPPL_INT &  j,
const double &  v 
)
inline

put value with volume cheack without isListed check

Definition at line 56 of file dgsmatrix-io.hpp.

References cols, data, i(), m, n, and rows.

Referenced by identity(), read(), and _dssmatrix::to_dgsmatrix().

57 {CPPL_VERBOSE_REPORT;
58 #ifdef CPPL_DEBUG
59  if( i<0 || j<0 || m<=i || n<=j ){
60  ERROR_REPORT;
61  std::cerr << "The required component is out of the matrix size." << std::endl
62  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
63  exit(1);
64  }
65  const std::vector<dcomponent>::const_iterator data_end =data.end();
66  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
67  if( it->i==i && it->j==j ){
68  ERROR_REPORT;
69  std::cerr << "The required component is already listed." << std::endl
70  << "Your input was (" << i << "," << j << "," << v << ")." << std::endl;
71  exit(1);
72  }
73  }
74 #endif//CPPL_DEBUG
75 
76  //// push ////
77  rows[i].push_back(CPPL_INT(data.size()));
78  cols[j].push_back(CPPL_INT(data.size()));
79  data.push_back(dcomponent(i,j,v));
80 
81  return *this;
82 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
Component Class for Real Double-precision Sparse Matrix Classes.
Definition: dcomponent.hpp:3
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
_dgematrix i(const _dgbmatrix &mat)
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
dgsmatrix & dgsmatrix::del ( const CPPL_INT  i,
const CPPL_INT  j 
)
inline

delete the entry of a component

Definition at line 90 of file dgsmatrix-io.hpp.

References cols, data, i(), m, n, and rows.

Referenced by diet(), and stretch().

91 {CPPL_VERBOSE_REPORT;
92 #ifdef CPPL_DEBUG
93  if( i<0 || j<0 || m<=i || n<=j ){
94  ERROR_REPORT;
95  std::cerr << "The required component is out of the matrix size." << std::endl
96  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
97  exit(1);
98  }
99 #endif//CPPL_DEBUG
100 
101  //// search (i,j) component ////
102  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
103  for(std::vector<CPPL_INT>::iterator p=rows[i].begin(); p!=rows_i_end; p++){
104  if(data[*p].j==j){//exists
105  //// save position ////
106  CPPL_INT c =*p;
107  CPPL_INT C =CPPL_INT(data.size()-1);
108 
109  //// data translation ////
110  data[c]=data.back();
111  data.pop_back();
112 
113  //// remove from List ////
114  rows[i].erase(p);
115  const std::vector<CPPL_INT>::iterator cols_j_end =cols[j].end();
116  for(std::vector<CPPL_INT>::iterator q=cols[j].begin(); q!=cols_j_end; q++){
117  if(*q==c){ cols[j].erase(q); break; }
118  }
119 
120  //// modify the entry of translated component ////
121  CPPL_INT I(data[c].i), J(data[c].j);
122  const std::vector<CPPL_INT>::iterator rows_I_end =rows[I].end();
123  for(std::vector<CPPL_INT>::iterator q=rows[I].begin(); q!=rows_I_end; q++){
124  if(*q==C){ *q=c; break; }
125  }
126  const std::vector<CPPL_INT>::iterator cols_J_end =cols[J].end();
127  for(std::vector<CPPL_INT>::iterator q=cols[J].begin(); q!=cols_J_end; q++){
128  if(*q==C){ *q=c; break; }
129  }
130  return *this;
131  }
132  }
133 
134 #ifdef CPPL_DEBUG
135  std::cerr << "# [NOTE]@dgsmatrix::del(CPPL_INT&, CPPL_INT&): The required component was not listed. Your input was (" << i << "," << j << ")." << std::endl;
136 #endif//CPPL_DEBUG
137 
138  return *this;
139 }
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
_dgematrix i(const _dgbmatrix &mat)
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
dgsmatrix & dgsmatrix::del ( const CPPL_INT  c)
inline

delete the entry of an element

Definition at line 143 of file dgsmatrix-io.hpp.

References cols, data, i(), and rows.

144 {CPPL_VERBOSE_REPORT;
145  if( c==CPPL_INT(data.size()-1) ){//if c is the last element
146  CPPL_INT i(data[c].i), j(data[c].j);
147  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
148  for(std::vector<CPPL_INT>::iterator q=rows[i].begin(); q!=rows_i_end; q++){
149  if(*q==c){ rows[i].erase(q); break; }
150  }
151  const std::vector<CPPL_INT>::iterator cols_j_end =cols[j].end();
152  for(std::vector<CPPL_INT>::iterator q=cols[j].begin(); q!=cols_j_end; q++){
153  if(*q==c){ cols[j].erase(q); break; }
154  }
155  data.pop_back();
156  }
157 
158  else{//if c is NOT the last element
159  //// data translation ////
160  CPPL_INT C =CPPL_INT(data.size()-1);
161  CPPL_INT i(data[c].i), j(data[c].j), I(data.back().i), J(data.back().j);
162  data[c]=data.back();
163  //// remove entry of component ////
164  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
165  for(std::vector<CPPL_INT>::iterator q=rows[i].begin(); q!=rows_i_end; q++){
166  if(*q==c){ rows[i].erase(q); break; }
167  }
168  const std::vector<CPPL_INT>::iterator cols_j_end =cols[j].end();
169  for(std::vector<CPPL_INT>::iterator q=cols[j].begin(); q!=cols_j_end; q++){
170  if(*q==c){ cols[j].erase(q); break; }
171  }
172  //// modify the entry of translated component ////
173  const std::vector<CPPL_INT>::iterator rows_I_end =rows[I].end();
174  for(std::vector<CPPL_INT>::iterator q=rows[I].begin(); q!=rows_I_end; q++){
175  if(*q==C){ *q=c; break; }
176  }
177  const std::vector<CPPL_INT>::iterator cols_J_end =cols[J].end();
178  for(std::vector<CPPL_INT>::iterator q=cols[J].begin(); q!=cols_J_end; q++){
179  if(*q==C){ *q=c; break; }
180  }
181  //// pop_back ////
182  data.pop_back();
183  }
184 
185  return *this;
186 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: dgsmatrix.hpp:13
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: dgsmatrix.hpp:12
void dgsmatrix::write ( const char *  filename) const
inline

Definition at line 216 of file dgsmatrix-io.hpp.

References data, m, and n.

217 {CPPL_VERBOSE_REPORT;
218  std::ofstream ofs(filename, std::ios::trunc);
219  ofs.setf(std::cout.flags());
220  ofs.precision(std::cout.precision());
221  ofs.width(std::cout.width());
222  ofs.fill(std::cout.fill());
223 
224  ofs << "#dgsmatrix " << m << " " << n << " " << data.size() << std::endl;
225 
226  const std::vector<dcomponent>::const_iterator data_end =data.end();
227  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
228  ofs << it->i << " " << it->j << " " << it->v << std::endl;
229  }
230 
231  ofs.close();
232 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
void dgsmatrix::read ( const char *  filename)
inline

Definition at line 235 of file dgsmatrix-io.hpp.

References data, i(), m, n, put(), and resize().

Referenced by dgsmatrix().

236 {CPPL_VERBOSE_REPORT;
237  std::ifstream s( filename );
238  if(!s){
239  ERROR_REPORT;
240  std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
241  exit(1);
242  }
243 
244  //////// id ////////
245  std::string id;
246  s >> id;
247  if( id != "dgsmatrix" && id != "#dgsmatrix" ){
248  ERROR_REPORT;
249  std::cerr << "The type name of the file \"" << filename << "\" is not dgsmatrix." << std::endl
250  << "Its type name was " << id << " ." << std::endl;
251  exit(1);
252  }
253 
254  //////// m, n, size ////////
255  size_t size;
256  s >> m >> n >> size;
257  resize(m, n);
258  data.resize(size);
259 
260  //////// i, j, v ////////
261  CPPL_INT i, j;
262  double v;
263  for(size_t k=0; k<size; k++){
264  s >> i >> j >> v;
265  put(i,j, v);
266  }
267 
268  //////// check ////////
269  s >> i;
270  if(!s.eof()){
271  ERROR_REPORT;
272  std::cerr << "There is something is wrong with the file \"" << filename << " ." << std::endl
273  << "Most likely, there are too many data components over the context." << std::endl;
274  exit(1);
275  }
276  s.close();
277 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
dgsmatrix & put(const CPPL_INT &, const CPPL_INT &, const double &)
dgsmatrix & resize(const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
void dgsmatrix::clear ( )
inline

clear all the matrix data and set the sizes 0

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

References cols, data, m, n, and rows.

4 {CPPL_VERBOSE_REPORT;
5  m =0;
6  n =0;
7  data.clear();
8  rows.clear();
9  cols.clear();
10 }
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
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
dgsmatrix & dgsmatrix::zero ( )
inline

change the matrix into a zero matrix

Definition at line 14 of file dgsmatrix-misc.hpp.

References cols, data, i(), m, n, and rows.

Referenced by identity(), operator*=(), _dssmatrix::to_dgsmatrix(), and dssmatrix::to_dgsmatrix().

15 {CPPL_VERBOSE_REPORT;
16  data.resize(0);
17  for(CPPL_INT i=0; i<m; i++){ rows[i].resize(0); }
18  for(CPPL_INT j=0; j<n; j++){ cols[j].resize(0); }
19  return *this;
20 }
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
_dgematrix i(const _dgbmatrix &mat)
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
dgsmatrix & dgsmatrix::identity ( )
inline

change the matrix into an identity matrix

Definition at line 24 of file dgsmatrix-misc.hpp.

References i(), m, n, put(), and zero().

25 {CPPL_VERBOSE_REPORT;
26 #ifdef CPPL_DEBUG
27  if(m!=n){
28  ERROR_REPORT;
29  std::cerr << "Only square matrix can be a identity matrix." << std::endl
30  << "The matrix size was " << m << "x" << n << "." << std::endl;
31  exit(1);
32  }
33 #endif//CPPL_DEBUG
34 
35  zero();
36  for(CPPL_INT i=0; i<m; i++){
37  put(i,i,1.);
38  }
39  return *this;
40 }
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
dgsmatrix & zero()
dgsmatrix & put(const CPPL_INT &, const CPPL_INT &, const double &)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
void dgsmatrix::chsign ( )
inline

change sign(+/-) of the matrix

Definition at line 44 of file dgsmatrix-misc.hpp.

References data.

Referenced by operator-().

45 {CPPL_VERBOSE_REPORT;
46  const std::vector<dcomponent>::iterator data_end =data.end();
47  for(std::vector<dcomponent>::iterator it=data.begin(); it!=data_end; it++){
48  it->v =-it->v;
49  }
50 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
void dgsmatrix::copy ( const dgsmatrix mat)
inline

make a deep copy of the matrix

Definition at line 54 of file dgsmatrix-misc.hpp.

References cols, data, m, n, and rows.

Referenced by dgsmatrix(), and operator=().

55 {CPPL_VERBOSE_REPORT;
56  m =mat.m;
57  n =mat.n;
58  data =mat.data;
59  rows =mat.rows;
60  cols =mat.cols;
61 }
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
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 dgsmatrix::shallow_copy ( const _dgsmatrix mat)
inline

make a shallow copy of the matrix
This function is not designed to be used in project codes.

Definition at line 66 of file dgsmatrix-misc.hpp.

References cols, _dgsmatrix::cols, _dgsmatrix::data, data, m, _dgsmatrix::m, _dgsmatrix::n, n, _dgsmatrix::nullify(), rows, and _dgsmatrix::rows.

Referenced by operator=().

67 {CPPL_VERBOSE_REPORT;
68  data.clear();
69  rows.clear();
70  cols.clear();
71 
72  m =mat.m;
73  n =mat.n;
74  data.swap(mat.data);
75  rows.swap(mat.rows);
76  cols.swap(mat.cols);
77 
78  mat.nullify();
79 }
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< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
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 n
matrix column size
Definition: _dgsmatrix.hpp:10
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
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
void nullify() const
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
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
dgsmatrix & dgsmatrix::resize ( const CPPL_INT &  _m,
const CPPL_INT &  _n,
const CPPL_INT  _c = 0,
const CPPL_INT  _l = 0 
)
inline

resize the matrix

Definition at line 83 of file dgsmatrix-misc.hpp.

References cols, data, i(), m, n, and rows.

Referenced by read().

84 {CPPL_VERBOSE_REPORT;
85 #ifdef CPPL_DEBUG
86  if( _m<0 || _n<0 || _c<0 ){
87  ERROR_REPORT;
88  std::cerr << "Matrix sizes and the length of arrays must be positive integers. " << std::endl
89  << "Your input was (" << _m << "," << _n << "," << _c << "," << _l << ")." << std::endl;
90  exit(1);
91  }
92 #endif//CPPL_DEBUG
93 
94  m =_m;
95  n =_n;
96  data.resize(0);
97  data.reserve(_c);
98  rows.resize(m);
99  for(CPPL_INT i=0; i<m; i++){
100  rows[i].resize(0);
101  rows[i].reserve(_l);
102  }
103  cols.resize(n);
104  for(CPPL_INT i=0; i<n; i++){
105  cols[i].resize(0);
106  cols[i].reserve(_l);
107  }
108 
109  return *this;
110 }
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
_dgematrix i(const _dgbmatrix &mat)
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 dgsmatrix::stretch ( const CPPL_INT &  dm,
const CPPL_INT &  dn 
)
inline

stretch the matrix size

Definition at line 114 of file dgsmatrix-misc.hpp.

References cols, data, del(), i(), m, n, and rows.

115 {CPPL_VERBOSE_REPORT;
116 #ifdef CPPL_DEBUG
117  if( m+dm<0 || n+dn<0 ){
118  ERROR_REPORT;
119  std::cerr << "The new matrix size must be larger than zero. " << std::endl
120  << "Your input was (" << dm << ", " << dn << ")." << std::endl;
121  exit(1);
122  }
123 #endif//CPPL_DEBUG
124 
125  //////// zero ////////
126  if(dm==0 && dn==0){ return; }
127 
128  //////// non-zero ////////
129  m +=dm;
130  n +=dn;
131 
132  //// for rows ////
133  if(dm<0){
134  //// delete components over the new size ////
135  const std::vector<dcomponent>::reverse_iterator data_rend =data.rend();
136  for(std::vector<dcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
137  if( it->i>=m ){ del( CPPL_INT(data_rend-it-1) ); }
138  }
139  //// shrink rows ////
140  for(CPPL_INT i=0; i<-dm; i++){
141  rows.pop_back();
142  }
143  }
144  else{//dm>0
145  //// expand rows ////
146  for(CPPL_INT i=0; i<dm; i++){
147  rows.push_back( std::vector<CPPL_INT>(0) );
148  }
149  }
150 
151  //// for cols ////
152  if(dn<0){
153  //// delete components over the new size ////
154  const std::vector<dcomponent>::reverse_iterator data_rend =data.rend();
155  for(std::vector<dcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
156  if( it->j>=n ){ del( CPPL_INT(data_rend-it-1) ); }
157  }
158  for(CPPL_INT j=0; j<-dn; j++){
159  cols.pop_back();
160  }
161  }
162  else{//dn>0
163  //// expand cols ////
164  for(CPPL_INT j=0; j<dn; j++){
165  cols.push_back( std::vector<CPPL_INT>(0) );
166  }
167  }
168 }
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
_dgematrix i(const _dgbmatrix &mat)
dgsmatrix & del(const CPPL_INT, const CPPL_INT)
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
bool dgsmatrix::isListed ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

check if the component is listed

Definition at line 172 of file dgsmatrix-misc.hpp.

References data, i(), m, n, and rows.

173 {CPPL_VERBOSE_REPORT;
174 #ifdef CPPL_DEBUG
175  if( i<0 || j<0 || m<=i || n<=j ){
176  ERROR_REPORT;
177  std::cerr << "The required component is out of the matrix size." << std::endl
178  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
179  exit(1);
180  }
181 #endif//CPPL_DEBUG
182  const std::vector<CPPL_INT>::const_iterator rows_i_end =rows[i].end();
183  for(std::vector<CPPL_INT>::const_iterator p=rows[i].begin(); p!=rows_i_end; p++){
184  if(data[*p].j==j){ return 1; }
185  }
186 
187  return 0;
188 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
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
CPPL_INT dgsmatrix::number ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

return the element number of the component

Definition at line 193 of file dgsmatrix-misc.hpp.

References data, i(), m, n, and rows.

194 {CPPL_VERBOSE_REPORT;
195 #ifdef CPPL_DEBUG
196  if( i<0 || j<0 || m<=i || n<=j ){
197  ERROR_REPORT;
198  std::cerr << "The required component is out of the matrix size." << std::endl
199  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
200  exit(1);
201  }
202 #endif//CPPL_DEBUG
203  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
204  for(std::vector<CPPL_INT>::iterator p=rows[i].begin(); p!=rows_i_end; p++){
205  if(data[*p].j==j){ return *p; }
206  }
207 
208  return -1;
209 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
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 dgsmatrix::diet ( const double  eps = DBL_MIN)
inline

erase components less than DBL_MIN

Definition at line 265 of file dgsmatrix-misc.hpp.

References data, and del().

266 {CPPL_VERBOSE_REPORT;
267  const std::vector<dcomponent>::reverse_iterator data_rend =data.rend();
268  for(std::vector<dcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
269  if( fabs(it->v)<eps ){ del( CPPL_INT(data_rend-it-1) ); }
270  }
271 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
dgsmatrix & del(const CPPL_INT, const CPPL_INT)
void dgsmatrix::checkup ( )
inline

health checkup

Definition at line 279 of file dgsmatrix-misc.hpp.

References cols, data, i(), m, n, and rows.

280 {CPPL_VERBOSE_REPORT;
281  //////// write ////////
282  const std::vector<dcomponent>::const_iterator data_end =data.end();
283  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
284  std::cerr << "array[" << it-data.begin() << "] = (" << it->i << "," << it->j << ") = " << it->v << std::endl;
285  }
286  std::cerr << std::endl;
287 
288  for(CPPL_INT i=0; i<m; i++){
289  std::cerr << "rows[" << i << "] =" << std::flush;
290  const size_t rows_i_size =rows[i].size();
291  for(size_t k=0; k<rows_i_size; k++){
292  std::cerr << " " << rows[i][k] << std::flush;
293  }
294  std::cerr << std::endl;
295  }
296  std::cerr << std::endl;
297 
298  for(CPPL_INT j=0; j<n; j++){
299  std::cerr << "cols[" << j << "] =" << std::flush;
300  const size_t cols_j_size =cols[j].size();
301  for(size_t k=0; k<cols_j_size; k++){
302  std::cerr << " " << cols[j][k] << std::flush;
303  }
304  std::cerr << std::endl;
305  }
306 
307  //////// Elements ////////
308  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
309  //// m bound ////
310  if(it->i>=m){
311  ERROR_REPORT;
312  std::cerr << "The indx of the " << it-data.begin() << "th element is out of the matrix size." << std::endl
313  << "Its i index was " << it->i << "." << std::endl;
314  exit(1);
315  }
316 
317  //// n bound ////
318  if(it->j>=n){
319  ERROR_REPORT;
320  std::cerr << "The indx of the " << it-data.begin() << "th element is out of the matrix size." << std::endl
321  << "Its j index was " << it->j << "." << std::endl;
322  exit(1);
323  }
324 
325  //// double-listed ////
326  for(std::vector<dcomponent>::const_iterator IT=it+1; IT!=data_end; IT++){
327  if( it->i==IT->i && it->j==IT->j ){
328  ERROR_REPORT;
329  std::cerr << "The (" << it->i << ", " << it->j << ") component is double-listed at the " << it-data.begin() << "th and the" << IT-data.begin() << "the elements."<< std::endl;
330  exit(1);
331  }
332  }
333  }
334 
335  //////// ijc consistence ////////
336 
337 
338  //////// NOTE ////////
339  std::cerr << "# [NOTE]@dgsmatrix::checkup(): This sparse matrix is fine." << std::endl;
340 }
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
_dgematrix i(const _dgbmatrix &mat)
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
_drovector dgsmatrix::row ( const CPPL_INT &  _m) const
inline

get row of the matrix

Definition at line 217 of file dgsmatrix-misc.hpp.

References _, data, m, n, rows, and drovector::zero().

218 {CPPL_VERBOSE_REPORT;
219 #ifdef CPPL_DEBUG
220  if( _m<0 || _m>m ){
221  ERROR_REPORT;
222  std::cerr << "Input row number must be between 0 and " << m << "." << std::endl
223  << "Your input was " << _m << "." << std::endl;
224  exit(1);
225  }
226 #endif//CPPL_DEBUG
227 
228  drovector vec(n);
229  vec.zero();
230 
231  const std::vector<CPPL_INT>::const_iterator rows__m_end =rows[_m].end();
232  for(std::vector<CPPL_INT>::const_iterator p=rows[_m].begin(); p!=rows__m_end; p++){
233  vec(data[*p].j) =data[*p].v;
234  }
235 
236  return _(vec);
237 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision Row Vector Class.
Definition: drovector.hpp:3
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
_dcovector dgsmatrix::col ( const CPPL_INT &  _n) const
inline

get column of the matrix

Definition at line 241 of file dgsmatrix-misc.hpp.

References _, cols, data, i(), m, n, and dcovector::zero().

242 {CPPL_VERBOSE_REPORT;
243 #ifdef CPPL_DEBUG
244  if( _n<0 || _n>n ){
245  ERROR_REPORT;
246  std::cerr << "Input row number must be between 0 and " << n << "." << std::endl
247  << "Your input was " << _n << "." << std::endl;
248  exit(1);
249  }
250 #endif//CPPL_DEBUG
251 
252  dcovector vec(m);
253  vec.zero();
254 
255  const std::vector<CPPL_INT>::const_iterator cols__n_end =cols[_n].end();
256  for(std::vector<CPPL_INT>::const_iterator p=cols[_n].begin(); p!=cols__n_end; p++){
257  vec(data[*p].i) =data[*p].v;
258  }
259 
260  return _(vec);
261 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: dgsmatrix.hpp:13
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
CPPL_INT dgsmatrix::pardiso ( dcovector b) const
inline

solve A*x=b for real and unsymmetric matrix using Intel PARDISO.
The argument is dcovector b. b is overwritten and become the solution x. A is not overwritten.

Definition at line 7 of file dgsmatrix-pardiso.hpp.

References dcovector::array, data, i(), dcovector::l, m, n, rows, and swap.

8 {CPPL_VERBOSE_REPORT;
9 #ifndef __INTEL_COMPILER
10  ERROR_REPORT;
11  std::cerr << "dgsmatrix::pardiso is only for intel c++ compiler (icpc)." << std::endl;
12  std::cerr << "Recompile your code with icpc to use pardiso." << std::endl;
13  (void)b;
14  exit(1);
15 #else //__INTEL_COMPILER
16 
17 
18  //#ifdef CPPL_DEBUG
19  if(m!=n || m!=b.l){
20  ERROR_REPORT;
21  std::cerr << "These matrix and vector cannot be solved." << std::endl
22  << "Your input was (" << m << "x" << n << ") and (" << b.l << ")." << std::endl;
23  exit(1);
24  }
25  //#endif//CPPL_DEBUG
26 
27  //////// convert matrix storage into compressed sparse row format ////////
28  //std::cerr << "converting" << std::endl;
29  std::vector<double> a(data.size());
30  std::vector<MKL_INT> ja(data.size());
31  std::vector<MKL_INT> ia(m+1);
32  ia[0] =0;
33  MKL_INT k=0;
34  for(CPPL_INT i=0; i<m; i++){
35  //// make map ////
36  const std::vector<CPPL_INT>::const_iterator rows_i_end =rows[i].end();
37  std::map<CPPL_INT,CPPL_INT> jc;
38  for(std::vector<CPPL_INT>::const_iterator rit=rows[i].begin(); rit!=rows_i_end; rit++){
39  jc.insert( std::make_pair(data[*rit].j, *rit) );
40  }
41  //// assign ////
42  const std::map<CPPL_INT,CPPL_INT>::const_iterator jc_end =jc.end();
43  for(std::map<CPPL_INT,CPPL_INT>::const_iterator jcit=jc.begin(); jcit!=jc_end; jcit++){
44  a[k] =data[(*jcit).second].v;
45  ja[k] =MKL_INT((*jcit).first);
46  k++;
47  }
48  ia[i+1] =k;
49  }
50 
51  //////// pardisoinit ////////
52  //std::cerr << "initializing" << std::endl;
53  _MKL_DSS_HANDLE_t pt[64];
54  MKL_INT mtype =11;//real unsymmetric
55  MKL_INT iparm[64];
56  PARDISOINIT(pt, &mtype, iparm);
57  iparm[1] =3;//parallel fill-in reducing ordering
58  iparm[23] =1;//use two-level scheduling factorization algorithm
59  iparm[26] =0;//disable matrix checker
60  iparm[34] =-1;//use zero-base array index
61 
62  //////// pardiso ////////
63  //std::cerr << "solving" << std::endl;
64  MKL_INT maxfct =1;
65  MKL_INT mnum =1;
66  MKL_INT phase =13;
67  MKL_INT MKL_INT_n =MKL_INT(n);
68  std::vector<MKL_INT> perm(n);
69  MKL_INT nrhs =1;
70  MKL_INT msglvl =0;
71  dcovector x(b.l);
72  MKL_INT error =1;
73  PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &MKL_INT_n, &a[0], &ia[0], &ja[0], &perm[0], &nrhs, iparm, &msglvl, b.array, x.array, &error);
74  swap(b,x);//set b as x
75  if(error!=0){
76  WARNING_REPORT;
77  std::cerr << "Serious trouble happend. error = " << error << "." << std::endl;
78  }
79 
80  //////// release memory ////////
81  phase =-1;
82  MKL_INT error2 =1;
83  PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &MKL_INT_n, &a[0], &ia[0], &ja[0], &perm[0], &nrhs, iparm, &msglvl, b.array, x.array, &error2);
84 
85  return error;
86 #endif //__INTEL_COMPILER
87 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT l
vector size
Definition: dcovector.hpp:9
_dgematrix i(const _dgbmatrix &mat)
double * array
1D array to store vector data
Definition: dcovector.hpp:11
friend void swap(dgsmatrix &, dgsmatrix &)
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
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
dgsmatrix & dgsmatrix::operator= ( const dgsmatrix mat)
inline

dgsmatrix=dgsmatrix operator

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

References copy(), and data.

4 {CPPL_VERBOSE_REPORT;
5  if(&data!=&mat.data){ // if it is NOT self substitution
6  copy(mat);
7  }
8  return *this;
9 }
void copy(const dgsmatrix &)
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
dgsmatrix & dgsmatrix::operator= ( const _dgsmatrix mat)
inline

dgsmatrix=_dgsmatrix operator

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

References shallow_copy().

4 {CPPL_VERBOSE_REPORT;
5  shallow_copy(mat);
6  return *this;
7 }
void shallow_copy(const _dgsmatrix &)
dgsmatrix & dgsmatrix::operator+= ( const dgsmatrix mat)
inline

dgsmatrix+=dgsmatrix operator

Definition at line 17 of file dgsmatrix-dgsmatrix.hpp.

References data, m, and n.

18 {CPPL_VERBOSE_REPORT;
19 #ifdef CPPL_DEBUG
20  if(n!=mat.n || m!=mat.m){
21  ERROR_REPORT;
22  std::cerr << "These two matrises can not make a summation." << std::endl
23  << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
24  exit(1);
25  }
26 #endif//CPPL_DEBUG
27 
28  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
29  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
30  (*this)(it->i,it->j) +=it->v;
31  }
32 
33  return *this;
34 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
dgsmatrix & dgsmatrix::operator+= ( const _dgsmatrix mat)
inline

dgsmatrix+=_dgsmatrix operator

Definition at line 15 of file dgsmatrix-_dgsmatrix.hpp.

References _dgsmatrix::data, _dgsmatrix::destroy(), _dgsmatrix::m, m, n, and _dgsmatrix::n.

16 {CPPL_VERBOSE_REPORT;
17 #ifdef CPPL_DEBUG
18  if(n!=mat.n || m!=mat.m){
19  ERROR_REPORT;
20  std::cerr << "These two matrises can not make a summation." << std::endl
21  << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
22  exit(1);
23  }
24 #endif//CPPL_DEBUG
25 
26  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
27  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
28  (*this)(it->i,it->j) += it->v;
29  }
30 
31  mat.destroy();
32  return *this;
33 }
CPPL_INT n
matrix column size
Definition: _dgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
void destroy() const
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
dgsmatrix & dgsmatrix::operator-= ( const dgsmatrix mat)
inline

dgsmatrix-=dgsmatrix operator

Definition at line 38 of file dgsmatrix-dgsmatrix.hpp.

References data, m, and n.

39 {CPPL_VERBOSE_REPORT;
40 #ifdef CPPL_DEBUG
41  if(n!=mat.n || m!=mat.m){
42  ERROR_REPORT;
43  std::cerr << "These two matrises can not make a sutraction." << std::endl
44  << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
45  exit(1);
46  }
47 #endif//CPPL_DEBUG
48 
49  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
50  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
51  (*this)(it->i,it->j) -=it->v;
52  }
53  return *this;
54 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
dgsmatrix & dgsmatrix::operator-= ( const _dgsmatrix mat)
inline

dgsmatrix-=_dgsmatrix operator

Definition at line 37 of file dgsmatrix-_dgsmatrix.hpp.

References _dgsmatrix::data, _dgsmatrix::destroy(), _dgsmatrix::m, m, n, and _dgsmatrix::n.

38 {CPPL_VERBOSE_REPORT;
39 #ifdef CPPL_DEBUG
40  if(n!=mat.n || m!=mat.m){
41  ERROR_REPORT;
42  std::cerr << "These two matrises can not make a sutraction." << std::endl
43  << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
44  exit(1);
45  }
46 #endif//CPPL_DEBUG
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  (*this)(it->i,it->j) -= it->v;
51  }
52 
53  mat.destroy();
54  return *this;
55 }
CPPL_INT n
matrix column size
Definition: _dgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
void destroy() const
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
dgsmatrix & dgsmatrix::operator*= ( const dgsmatrix mat)
inline

dgsmatrix*=dgsmatrix operator

Definition at line 58 of file dgsmatrix-dgsmatrix.hpp.

References data, m, n, rows, swap, and zero().

59 {CPPL_VERBOSE_REPORT;
60 #ifdef CPPL_DEBUG
61  if(n!=mat.m){
62  ERROR_REPORT;
63  std::cerr << "These two matrises can not make a product." << std::endl
64  << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
65  exit(1);
66  }
67 #endif//CPPL_DEBUG
68 
69  dgsmatrix newmat(m, mat.n);
70  newmat.zero();
71 
72  const std::vector<dcomponent>::const_iterator data_end =data.end();
73  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
74  CPPL_INT k =it->j;
75  const std::vector<CPPL_INT>::const_iterator mat_rows_k_end =mat.rows[k].end();
76  for(std::vector<CPPL_INT>::const_iterator p=mat.rows[k].begin(); p!=mat_rows_k_end; p++){
77  newmat(it->i,mat.data[*p].j) +=it->v*mat.data[*p].v;
78  }
79  }
80 
81  swap(*this,newmat);
82  return *this;
83 }
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
friend void swap(dgsmatrix &, dgsmatrix &)
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
dgsmatrix & dgsmatrix::operator*= ( const _dgsmatrix mat)
inline

dgsmatrix*=_dgsmatrix operator

Definition at line 59 of file dgsmatrix-_dgsmatrix.hpp.

References data, _dgsmatrix::data, _dgsmatrix::destroy(), _dgsmatrix::m, m, n, _dgsmatrix::n, _dgsmatrix::rows, and swap.

60 {CPPL_VERBOSE_REPORT;
61 #ifdef CPPL_DEBUG
62  if(n!=mat.m){
63  ERROR_REPORT;
64  std::cerr << "These two matrises can not make a product." << std::endl
65  << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
66  exit(1);
67  }
68 #endif//CPPL_DEBUG
69 
70  dgsmatrix newmat(m, mat.n);
71 
72  const std::vector<dcomponent>::const_iterator data_end =data.end();
73  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
74  CPPL_INT k =it->j;
75  const std::vector<CPPL_INT>::const_iterator mat_rows_k_end =mat.rows[k].end();
76  for(std::vector<CPPL_INT>::const_iterator p=mat.rows[k].begin(); p!=mat_rows_k_end; p++){
77  newmat(it->i,mat.data[*p].j) += it->v*mat.data[*p].v;
78  }
79  }
80 
81  swap(*this,newmat);
82  mat.destroy();
83  return *this;
84 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
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 n
matrix column size
Definition: _dgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
void destroy() const
friend void swap(dgsmatrix &, dgsmatrix &)
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
dgsmatrix & dgsmatrix::operator*= ( const double &  d)
inline

dgsmatrix*=double operator

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

References data.

4 {CPPL_VERBOSE_REPORT;
5  const std::vector<dcomponent>::iterator data_end =data.end();
6  for(std::vector<dcomponent>::iterator it=data.begin(); it!=data_end; it++){
7  it->v *=d;
8  }
9 
10  return *this;
11 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
dgsmatrix & dgsmatrix::operator/= ( const double &  d)
inline

dgsmatrix/=double operator

Definition at line 15 of file dgsmatrix-double.hpp.

References data.

16 {CPPL_VERBOSE_REPORT;
17  const std::vector<dcomponent>::iterator data_end =data.end();
18  for(std::vector<dcomponent>::iterator it=data.begin(); it!=data_end; it++){
19  it->v /=d;
20  }
21 
22  return *this;
23 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const dgsmatrix mat 
)
friend

Definition at line 193 of file dgsmatrix-io.hpp.

194 {CPPL_VERBOSE_REPORT;
195  for(CPPL_INT i=0; i<mat.m; i++){
196  const std::vector<CPPL_INT>::const_iterator mat_rows_i_end =mat.rows[i].end();
197  for(CPPL_INT j=0; j<mat.n; j++){
198  std::vector<CPPL_INT>::const_iterator q;
199  for(q=mat.rows[i].begin(); q!=mat_rows_i_end; q++){
200  if(mat.data[*q].j==j){ break; }
201  }
202  if(q!=mat_rows_i_end){ s << " " << mat.data[*q].v; }
203  else{ s << " x"; }
204  }
205  s << std::endl;
206  }
207 
208  return s;
209 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
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 swap ( dgsmatrix A,
dgsmatrix B 
)
friend

swap two matrices

Definition at line 348 of file dgsmatrix-misc.hpp.

Referenced by operator*=(), and pardiso().

349 {CPPL_VERBOSE_REPORT;
350  std::swap(A.n,B.n);
351  std::swap(A.m,B.m);
352  std::swap(A.data,B.data);
353  std::swap(A.rows,B.rows);
354  std::swap(A.cols,B.cols);
355 }
void swap(dgsmatrix &A, dgsmatrix &B)
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
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
_dgsmatrix _ ( dgsmatrix mat)
friend

convert user object to smart-temporary object

Definition at line 359 of file dgsmatrix-misc.hpp.

Referenced by col(), row(), to_dgematrix(), and to_zgsmatrix().

360 {CPPL_VERBOSE_REPORT;
361  _dgsmatrix newmat;
362 
363  //////// shallow copy ////////
364  newmat.n =mat.n;
365  newmat.m =mat.m;
366  std::swap(newmat.data,mat.data);
367  std::swap(newmat.rows,mat.rows);
368  std::swap(newmat.cols,mat.cols);
369 
370  //////// nullify ////////
371  mat.m =0;
372  mat.n =0;
373 
374  return newmat;
375 }
void swap(dgsmatrix &A, dgsmatrix &B)
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< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
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 n
matrix column size
Definition: _dgsmatrix.hpp:10
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
(DO NOT USE) Smart-temporary Real Double-precision General Sparse Matrix Class
Definition: _dgsmatrix.hpp:3
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
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
_dgsmatrix t ( const dgsmatrix mat)
friend

return transposed dgsmatrix

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

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
friend _dgsmatrix _(dgsmatrix &)
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)
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 
)
friend

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

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

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)
friend

return its largest absolute value

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

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
const dgsmatrix& operator+ ( const dgsmatrix mat)
friend

+dgsmatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5  return mat;
6 }
_dgsmatrix operator- ( const dgsmatrix mat)
friend

-dgsmatrix operator

Definition at line 10 of file dgsmatrix-unary.hpp.

11 {CPPL_VERBOSE_REPORT;
12  dgsmatrix newmat(mat);
13 
14  const std::vector<dcomponent>::iterator newmat_data_end =newmat.data.end();
15  for(std::vector<dcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
16  it->v =-it->v;
17  }
18 
19  return _(newmat);
20 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
friend _dgsmatrix _(dgsmatrix &)
_dgematrix operator+ ( const dgsmatrix matA,
const dgematrix matB 
)
friend

dgsmatrix+dgematrix operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.m || matA.n!=matB.n){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dgematrix newmat(matB);
15 
16  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
17  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
18  newmat(it->i,it->j) += it->v;
19  }
20 
21  return _(newmat);
22 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT n
matrix column size
Definition: dgematrix.hpp:10
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator+ ( const dgsmatrix matA,
const _dgematrix matB 
)
friend

dgsmatrix+_dgematrix operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.m || matA.n!=matB.n){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
15  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
16  matB(it->i,it->j) += it->v;
17  }
18 
19  return matB;
20 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator+ ( const dgsmatrix matA,
const dsymatrix matB 
)
friend

dgsmatrix+dsymatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.n || matA.n!=matB.n){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dgematrix newmat( matB.to_dgematrix() );
15 
16  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
17  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
18  newmat(it->i,it->j) += it->v;
19  }
20 
21  return _(newmat);
22 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
_dgematrix to_dgematrix() const
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator+ ( const dgsmatrix matA,
const _dsymatrix matB 
)
friend

dgsmatrix+_dsymatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.m || matA.n!=matB.n){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dgematrix newmat( matB.to_dgematrix() );
15 
16  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
17  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
18  newmat(it->i,it->j) += it->v;
19  }
20 
21  matB.destroy();
22  return _(newmat);
23 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
void destroy() const
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
_dgematrix to_dgematrix() const
CPPL_INT n
matrix column size
Definition: _dsymatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
CPPL_INT const & m
matrix row size
Definition: _dsymatrix.hpp:10
_dgematrix operator+ ( const dgsmatrix matA,
const dgbmatrix matB 
)
friend

dgsmatrix+dgbmatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.n!=matB.n || matA.m!=matB.m){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dgematrix newmat( matA.to_dgematrix() );
15 
16  for(CPPL_INT i=0; i<matB.m; i++){
17  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
18  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
19  newmat(i,j)+=matB(i,j);
20  }
21  }
22 
23  return _(newmat);
24 }
CPPL_INT m
matrix row size
Definition: dgbmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT kl
lower band width
Definition: dgbmatrix.hpp:11
CPPL_INT ku
upper band width
Definition: dgbmatrix.hpp:12
_dgematrix to_dgematrix() const
CPPL_INT n
matrix column size
Definition: dgbmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator+ ( const dgsmatrix matA,
const _dgbmatrix matB 
)
friend

dgsmatrix+_dgbmatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.n!=matB.n || matA.m!=matB.m){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dgematrix newmat( matA.to_dgematrix() );
15 
16  for(CPPL_INT i=0; i<matB.m; i++){
17  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
18  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
19  newmat(i,j)+=matB(i,j);
20  }
21  }
22 
23  matB.destroy();
24  return _(newmat);
25 }
CPPL_INT ku
upper band width
Definition: _dgbmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
void destroy() const
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT kl
lower band width
Definition: _dgbmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dgbmatrix.hpp:10
_dgematrix to_dgematrix() const
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: _dgbmatrix.hpp:9
_dgsmatrix operator+ ( const dgsmatrix matA,
const dgsmatrix matB 
)
friend

dgsmatrix+dgsmatrix operator

Definition at line 91 of file dgsmatrix-dgsmatrix.hpp.

92 {CPPL_VERBOSE_REPORT;
93 #ifdef CPPL_DEBUG
94  if(matA.n!=matB.n || matA.m!=matB.m){
95  ERROR_REPORT;
96  std::cerr << "These two matrises can not make a summation." << std::endl
97  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
98  exit(1);
99  }
100 #endif//CPPL_DEBUG
101 
102  dgsmatrix newmat(matA);
103 
104  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
105  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
106  newmat(it->i, it->j) +=it->v;
107  }
108 
109  return _(newmat);
110 }
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
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgsmatrix operator+ ( const dgsmatrix matA,
const _dgsmatrix matB 
)
friend

dgsmatrix+_dgsmatrix operator

Definition at line 92 of file dgsmatrix-_dgsmatrix.hpp.

93 {CPPL_VERBOSE_REPORT;
94 #ifdef CPPL_DEBUG
95  if(matA.n!=matB.n || matA.m!=matB.m){
96  ERROR_REPORT;
97  std::cerr << "These two matrises can not make a summation." << std::endl
98  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
99  exit(1);
100  }
101 #endif//CPPL_DEBUG
102 
103  dgsmatrix newmat(matB);
104 
105  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
106  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
107  newmat(it->i,it->j) += it->v;
108  }
109 
110  return _(newmat);
111 }
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
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgsmatrix operator+ ( const dgsmatrix ,
const dssmatrix  
)
friend
_dgsmatrix operator+ ( const dgsmatrix ,
const _dssmatrix  
)
friend
_dgematrix operator- ( const dgsmatrix matA,
const dgematrix matB 
)
friend

dgsmatrix-dgematrix operator

Definition at line 26 of file dgsmatrix-dgematrix.hpp.

27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if(matA.m!=matB.m || matA.n!=matB.n){
30  ERROR_REPORT;
31  std::cerr << "These two matrises can not make a subtraction." << std::endl
32  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  dgematrix newmat(-matB);
38 
39  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
40  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
41  newmat(it->i,it->j) += it->v;
42  }
43 
44  return _(newmat);
45 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT n
matrix column size
Definition: dgematrix.hpp:10
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator- ( const dgsmatrix matA,
const _dgematrix matB 
)
friend

dgsmatrix-_dgematrix operator

Definition at line 24 of file dgsmatrix-_dgematrix.hpp.

25 {CPPL_VERBOSE_REPORT;
26 #ifdef CPPL_DEBUG
27  if(matA.m!=matB.m || matA.n!=matB.n){
28  ERROR_REPORT;
29  std::cerr << "These two matrises can not make a subtraction." << std::endl
30  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
31  exit(1);
32  }
33 #endif//CPPL_DEBUG
34 
35  //// change sign ////
36  for(CPPL_INT i=0; i<matB.m*matB.n; i++){
37  matB.array[i]=-matB.array[i];
38  }
39 
40  //// add ////
41  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
42  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
43  matB(it->i,it->j) += it->v;
44  }
45 
46  return matB;
47 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
double * array
1D array to store matrix data
Definition: _dgematrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator- ( const dgsmatrix matA,
const dsymatrix matB 
)
friend

dgsmatrix-dsymatrix operator

Definition at line 26 of file dgsmatrix-dsymatrix.hpp.

27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if(matA.m!=matB.n || matA.n!=matB.n){
30  ERROR_REPORT;
31  std::cerr << "These two matrises can not make a subtraction." << std::endl
32  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  //// shallow copy to dgematrix ////
38  dgematrix newmat( (-matB).to_dgematrix() );
39 
40  //// add ////
41  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
42  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
43  newmat(it->i,it->j) += it->v;
44  }
45 
46  return _(newmat);
47 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
_dgematrix to_dgematrix() const
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator- ( const dgsmatrix matA,
const _dsymatrix matB 
)
friend

dgsmatrix-_dsymatrix operator

Definition at line 27 of file dgsmatrix-_dsymatrix.hpp.

28 {CPPL_VERBOSE_REPORT;
29 #ifdef CPPL_DEBUG
30  if(matA.m!=matB.m || matA.n!=matB.n){
31  ERROR_REPORT;
32  std::cerr << "These two matrises can not make a subtraction." << std::endl
33  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
34  exit(1);
35  }
36 #endif//CPPL_DEBUG
37 
38  dgematrix newmat( (-matB).to_dgematrix() );
39 
40  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
41  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
42  newmat(it->i,it->j) += it->v;
43  }
44 
45  matB.destroy();
46  return _(newmat);
47 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
void destroy() const
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
_dgematrix to_dgematrix() const
CPPL_INT n
matrix column size
Definition: _dsymatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
CPPL_INT const & m
matrix row size
Definition: _dsymatrix.hpp:10
_dgematrix operator- ( const dgsmatrix matA,
const dgbmatrix matB 
)
friend

dgsmatrix-dgbmatrix operator

Definition at line 28 of file dgsmatrix-dgbmatrix.hpp.

29 {CPPL_VERBOSE_REPORT;
30 #ifdef CPPL_DEBUG
31  if(matA.n!=matB.n || matA.m!=matB.m){
32  ERROR_REPORT;
33  std::cerr << "These two matrises can not make a summation." << std::endl
34  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
35  exit(1);
36  }
37 #endif//CPPL_DEBUG
38 
39  dgematrix newmat( matA.to_dgematrix() );
40 
41  for(CPPL_INT i=0; i<matB.m; i++){
42  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
43  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
44  newmat(i,j)-=matB(i,j);
45  }
46  }
47 
48  return _(newmat);
49 }
CPPL_INT m
matrix row size
Definition: dgbmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT kl
lower band width
Definition: dgbmatrix.hpp:11
CPPL_INT ku
upper band width
Definition: dgbmatrix.hpp:12
_dgematrix to_dgematrix() const
CPPL_INT n
matrix column size
Definition: dgbmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator- ( const dgsmatrix matA,
const _dgbmatrix matB 
)
friend

dgsmatrix-_dgbmatrix operator

Definition at line 29 of file dgsmatrix-_dgbmatrix.hpp.

30 {CPPL_VERBOSE_REPORT;
31 #ifdef CPPL_DEBUG
32  if(matA.n!=matB.n || matA.m!=matB.m){
33  ERROR_REPORT;
34  std::cerr << "These two matrises can not make a summation." << std::endl
35  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
36  exit(1);
37  }
38 #endif//CPPL_DEBUG
39 
40  dgematrix newmat( matA.to_dgematrix() );
41 
42  for(CPPL_INT i=0; i<matB.m; i++){
43  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
44  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
45  newmat(i,j)-=matB(i,j);
46  }
47  }
48 
49  matB.destroy();
50  return _(newmat);
51 }
CPPL_INT ku
upper band width
Definition: _dgbmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
void destroy() const
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT kl
lower band width
Definition: _dgbmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dgbmatrix.hpp:10
_dgematrix to_dgematrix() const
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: _dgbmatrix.hpp:9
_dgsmatrix operator- ( const dgsmatrix matA,
const dgsmatrix matB 
)
friend

dgsmatrix-dgsmatrix operator

Definition at line 114 of file dgsmatrix-dgsmatrix.hpp.

115 {CPPL_VERBOSE_REPORT;
116 #ifdef CPPL_DEBUG
117  if(matA.n!=matB.n || matA.m!=matB.m){
118  ERROR_REPORT;
119  std::cerr << "These two matrises can not make a subtraction." << std::endl
120  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
121  exit(1);
122  }
123 #endif//CPPL_DEBUG
124 
125  dgsmatrix newmat(matA);
126 
127  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
128  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
129  newmat(it->i, it->j) -=it->v;
130  }
131 
132  return _(newmat);
133 }
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
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgsmatrix operator- ( const dgsmatrix matA,
const _dgsmatrix matB 
)
friend

dgsmatrix-_dgsmatrix operator

Definition at line 115 of file dgsmatrix-_dgsmatrix.hpp.

116 {CPPL_VERBOSE_REPORT;
117 #ifdef CPPL_DEBUG
118  if(matA.n!=matB.n || matA.m!=matB.m){
119  ERROR_REPORT;
120  std::cerr << "These two matrises can not make a subtraction." << std::endl
121  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
122  exit(1);
123  }
124 #endif//CPPL_DEBUG
125 
126  dgsmatrix newmat(matB);
127  newmat.chsign();
128 
129  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
130  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
131  newmat(it->i,it->j) += it->v;
132  }
133 
134  return _(newmat);
135 }
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
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgsmatrix operator- ( const dgsmatrix ,
const dssmatrix  
)
friend
_dgsmatrix operator- ( const dgsmatrix ,
const _dssmatrix  
)
friend
_dcovector operator* ( const dgsmatrix mat,
const dcovector vec 
)
friend

dgsmatrix*dcovector operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(mat.n!=vec.l){
7  ERROR_REPORT;
8  std::cerr << "These matrix and vector can not make a product." << std::endl
9  << "Your input was (" << mat.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dcovector newvec(mat.m);
15  newvec.zero();
16 
17  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
18  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
19  newvec(it->i) += it->v*vec(it->j);
20  }
21 
22  return _(newvec);
23 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT l
vector size
Definition: dcovector.hpp:9
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dcovector operator* ( const dgsmatrix mat,
const _dcovector vec 
)
friend

dgsmatrix*_dcovector operator

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(mat.n!=vec.l){
7  ERROR_REPORT;
8  std::cerr << "These matrix and vector can not make a product." << std::endl
9  << "Your input was (" << mat.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dcovector newvec(mat.m);
15  newvec.zero();
16 
17  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
18  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
19  newvec(it->i) += it->v * vec(it->j);
20  }
21 
22  vec.destroy();
23  return _(newvec);
24 }
CPPL_INT l
vector size
Definition: _dcovector.hpp:9
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
void destroy() const
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator* ( const dgsmatrix matA,
const dgematrix matB 
)
friend

dgsmatrix*dgematrix operator

Definition at line 49 of file dgsmatrix-dgematrix.hpp.

50 {CPPL_VERBOSE_REPORT;
51 #ifdef CPPL_DEBUG
52  if(matA.n!=matB.m){
53  ERROR_REPORT;
54  std::cerr << "These two matrises can not make a product." << std::endl
55  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
56  exit(1);
57  }
58 #endif//CPPL_DEBUG
59 
60  dgematrix newmat(matA.m, matB.n);
61  newmat.zero();
62 
63  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
64  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
65  for(CPPL_INT j=0; j<matB.n; j++){
66  newmat(it->i,j) += it->v*matB(it->j,j);
67  }
68  }
69 
70  return _(newmat);
71 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT n
matrix column size
Definition: dgematrix.hpp:10
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator* ( const dgsmatrix matA,
const _dgematrix matB 
)
friend

dgsmatrix*_dgematrix operator

Definition at line 51 of file dgsmatrix-_dgematrix.hpp.

52 {CPPL_VERBOSE_REPORT;
53 #ifdef CPPL_DEBUG
54  if(matA.n!=matB.m){
55  ERROR_REPORT;
56  std::cerr << "These two matrises can not make a product." << std::endl
57  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
58  exit(1);
59  }
60 #endif//CPPL_DEBUG
61 
62  dgematrix newmat(matA.m, matB.n);
63  newmat.zero();
64 
65  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
66  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
67  for(CPPL_INT j=0; j<matB.n; j++){
68  newmat(it->i,j) += it->v *matB(it->j,j);
69  }
70  }
71 
72  matB.destroy();
73  return _(newmat);
74 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
void destroy() const
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator* ( const dgsmatrix matA,
const dsymatrix matB 
)
friend

dgsmatrix*dsymatrix operator

Definition at line 51 of file dgsmatrix-dsymatrix.hpp.

52 {CPPL_VERBOSE_REPORT;
53 #ifdef CPPL_DEBUG
54  if(matA.n!=matB.n){
55  ERROR_REPORT;
56  std::cerr << "These two matrises can not make a product." << std::endl
57  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
58  exit(1);
59  }
60 #endif//CPPL_DEBUG
61 
62  dgematrix newmat(matA.m, matB.n);
63  newmat.zero();
64 
65  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
66  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
67  for(CPPL_INT i=0; i<matB.n; i++){
68  newmat(it->i,i) += it->v*matB(it->j,i);
69  }
70  }
71 
72  return _(newmat);
73 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator* ( const dgsmatrix matA,
const _dsymatrix matB 
)
friend

dgsmatrix*_dsymatrix operator

Definition at line 51 of file dgsmatrix-_dsymatrix.hpp.

52 {CPPL_VERBOSE_REPORT;
53 #ifdef CPPL_DEBUG
54  if(matA.n!=matB.m){
55  ERROR_REPORT;
56  std::cerr << "These two matrises can not make a product." << std::endl
57  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
58  exit(1);
59  }
60 #endif//CPPL_DEBUG
61 
62  dgematrix newmat(matA.m, matB.n);
63  newmat.zero();
64 
65  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
66  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
67  for(CPPL_INT i=0; i<matB.n; i++){
68  newmat(it->i,i) += it->v*matB(it->j,i);
69  }
70  }
71 
72  matB.destroy();
73  return _(newmat);
74 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
void destroy() const
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT n
matrix column size
Definition: _dsymatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
CPPL_INT const & m
matrix row size
Definition: _dsymatrix.hpp:10
_dgematrix operator* ( const dgsmatrix matA,
const dgbmatrix matB 
)
friend

dgsmatrix*dgbmatrix operator

Definition at line 53 of file dgsmatrix-dgbmatrix.hpp.

54 {CPPL_VERBOSE_REPORT;
55 #ifdef CPPL_DEBUG
56  if(matA.n!=matB.m){
57  ERROR_REPORT;
58  std::cerr << "These two matrises can not make a product." << std::endl
59  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
60  exit(1);
61  }
62 #endif//CPPL_DEBUG
63 
64  dgematrix newmat( matA.m, matB.n );
65  newmat.zero();
66 
67  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
68  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
69  const CPPL_INT jmax =std::min(matB.n,it->j+matB.ku+1);
70  for(CPPL_INT j=std::max(CPPL_INT(0),it->j-matB.kl); j<jmax; j++){
71  newmat(it->i,j) += it->v*matB(it->j,j);
72  }
73  }
74 
75  return _(newmat);
76 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgbmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT kl
lower band width
Definition: dgbmatrix.hpp:11
CPPL_INT ku
upper band width
Definition: dgbmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dgbmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator* ( const dgsmatrix matA,
const _dgbmatrix matB 
)
friend

dgsmatrix*_dgbmatrix operator

Definition at line 55 of file dgsmatrix-_dgbmatrix.hpp.

56 {CPPL_VERBOSE_REPORT;
57 #ifdef CPPL_DEBUG
58  if(matA.n!=matB.m){
59  ERROR_REPORT;
60  std::cerr << "These two matrises can not make a product." << std::endl
61  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
62  exit(1);
63  }
64 #endif//CPPL_DEBUG
65 
66  dgematrix newmat( matA.m, matB.n );
67  newmat.zero();
68 
69  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
70  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
71  const CPPL_INT jmax =std::min(matB.n,it->j+matB.ku+1);
72  for(CPPL_INT j=std::max(CPPL_INT(0),it->j-matB.kl); j<jmax; j++){
73  newmat(it->i,j) += it->v*matB(it->j,j);
74  }
75  }
76 
77  matB.destroy();
78  return _(newmat);
79 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT ku
upper band width
Definition: _dgbmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
void destroy() const
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT kl
lower band width
Definition: _dgbmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dgbmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: _dgbmatrix.hpp:9
_dgsmatrix operator* ( const dgsmatrix matA,
const dgsmatrix matB 
)
friend

dgsmatrix*dgsmatrix operator

Definition at line 137 of file dgsmatrix-dgsmatrix.hpp.

138 {CPPL_VERBOSE_REPORT;
139 #ifdef CPPL_DEBUG
140  if(matA.n!=matB.m){
141  ERROR_REPORT;
142  std::cerr << "These two matrises can not make a product." << std::endl
143  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
144  exit(1);
145  }
146 #endif//CPPL_DEBUG
147 
148  dgsmatrix newmat( matA.m, matB.n );
149 
150  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
151  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
152  CPPL_INT k =it->j;
153  const std::vector<CPPL_INT>::const_iterator matB_rows_k_end =matB.rows[k].end();
154  for(std::vector<CPPL_INT>::const_iterator p=matB.rows[k].begin(); p!=matB_rows_k_end; p++){
155  newmat(it->i,matB.data[*p].j) +=it->v*matB.data[*p].v;
156  }
157  }
158 
159  return _(newmat);
160 }
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
friend _dgsmatrix _(dgsmatrix &)
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
_dgsmatrix operator* ( const dgsmatrix matA,
const _dgsmatrix matB 
)
friend

dgsmatrix*_dgsmatrix operator

Definition at line 139 of file dgsmatrix-_dgsmatrix.hpp.

140 {CPPL_VERBOSE_REPORT;
141 #ifdef CPPL_DEBUG
142  if(matA.n!=matB.m){
143  ERROR_REPORT;
144  std::cerr << "These two matrises can not make a product." << std::endl
145  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
146  exit(1);
147  }
148 #endif//CPPL_DEBUG
149 
150  dgsmatrix newmat(matA.m, matB.n);
151 
152  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
153  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
154  CPPL_INT k =it->j;
155  const std::vector<CPPL_INT>::iterator matB_rows_k_end =matB.rows[k].end();
156  for(std::vector<CPPL_INT>::iterator p=matB.rows[k].begin(); p!=matB_rows_k_end; p++){
157  newmat(it->i,matB.data[*p].j) += it->v*matB.data[*p].v;
158  }
159  }
160 
161  matB.destroy();
162  return _(newmat);
163 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
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 n
matrix column size
Definition: _dgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
friend _dgsmatrix _(dgsmatrix &)
CPPL_INT m
matrix row size
Definition: _dgsmatrix.hpp:9
void destroy() const
std::vector< dcomponent > data
matrix data
Definition: _dgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgsmatrix operator* ( const dgsmatrix ,
const dssmatrix  
)
friend
_dgsmatrix operator* ( const dgsmatrix ,
const _dssmatrix  
)
friend
_dgsmatrix operator* ( const dgsmatrix mat,
const double &  d 
)
friend

dgsmatrix*double operator

Definition at line 31 of file dgsmatrix-double.hpp.

32 {CPPL_VERBOSE_REPORT;
33  dgsmatrix newmat(mat);
34 
35  const std::vector<dcomponent>::iterator newmat_data_end =newmat.data.end();
36  for(std::vector<dcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
37  it->v *=d;
38  }
39 
40  return _(newmat);
41 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
friend _dgsmatrix _(dgsmatrix &)
_dgsmatrix operator/ ( const dgsmatrix mat,
const double &  d 
)
friend

dgsmatrix/double operator

Definition at line 45 of file dgsmatrix-double.hpp.

46 {CPPL_VERBOSE_REPORT;
47  dgsmatrix newmat(mat);
48 
49  const std::vector<dcomponent>::iterator newmat_data_end =newmat.data.end();
50  for(std::vector<dcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
51  it->v /=d;
52  }
53 
54  return _(newmat);
55 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
friend _dgsmatrix _(dgsmatrix &)
_dgsmatrix operator* ( const double &  d,
const dgsmatrix mat 
)
friend

double*dgsmatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5  dgsmatrix newmat =mat;
6 
7  const std::vector<dcomponent>::iterator newmat_data_end =newmat.data.end();
8  for(std::vector<dcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
9  it->v *= d;
10  }
11 
12  return _(newmat);
13 }
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
friend _dgsmatrix _(dgsmatrix &)

Member Data Documentation

CPPL_INT dgsmatrix::m
CPPL_INT dgsmatrix::n
std::vector<dcomponent> dgsmatrix::data
std::vector< std::vector<CPPL_INT> > dgsmatrix::rows

array of vector to store the entry information of component for each row

Definition at line 12 of file dgsmatrix.hpp.

Referenced by _(), checkup(), clear(), copy(), del(), dgsmatrix(), isListed(), number(), operator()(), operator*(), operator*=(), operator<<(), pardiso(), put(), resize(), row(), shallow_copy(), stretch(), swap(), t(), to_dgrmatrix(), zero(), and ~dgsmatrix().

std::vector< std::vector<CPPL_INT> > dgsmatrix::cols

array of vector to store the entry information of component for each column

Definition at line 13 of file dgsmatrix.hpp.

Referenced by _(), checkup(), clear(), col(), copy(), del(), dgsmatrix(), operator()(), put(), resize(), shallow_copy(), stretch(), swap(), t(), zero(), and ~dgsmatrix().


The documentation for this class was generated from the following files: