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

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

#include <dssmatrix.hpp>

Public Member Functions

 dssmatrix ()
 
 dssmatrix (const dssmatrix &)
 
 dssmatrix (const _dssmatrix &)
 
 dssmatrix (const CPPL_INT &, const CPPL_INT=0)
 
 dssmatrix (const char *)
 
 ~dssmatrix ()
 
_zhsmatrix to_zhsmatrix () const
 
_dgematrix to_dgematrix () const
 
_dsymatrix to_dsymatrix () const
 
_dgsmatrix to_dgsmatrix () const
 
double operator() (const CPPL_INT &, const CPPL_INT &) const
 
double & operator() (const CPPL_INT &, const CPPL_INT &)
 
dssmatrixput (const CPPL_INT &, const CPPL_INT &, const double &)
 
dssmatrixdel (const CPPL_INT, const CPPL_INT)
 
dssmatrixdel (const CPPL_INT)
 
void write (const char *) const
 
void read (const char *)
 
void clear ()
 
dssmatrixzero ()
 
dssmatrixidentity ()
 
void chsign ()
 
void copy (const dssmatrix &)
 
void shallow_copy (const _dssmatrix &)
 
dssmatrixresize (const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
 
void stretch (const CPPL_INT &)
 
bool isListed (const CPPL_INT &, const CPPL_INT &) const
 
CPPL_INT number (const CPPL_INT &, const CPPL_INT &) const
 
_drovector row (const CPPL_INT &) const
 
_dcovector col (const CPPL_INT &) const
 
void diet (const double=DBL_MIN)
 
CPPL_INT diag_front ()
 
void reorder (const bool=0)
 
void rebuild ()
 
void checkup ()
 
CPPL_INT pardiso_definite (dcovector &) const
 
CPPL_INT pardiso_indefinite (dcovector &) const
 
dssmatrixoperator= (const dssmatrix &)
 
dssmatrixoperator= (const _dssmatrix &)
 
dssmatrixoperator+= (const dssmatrix &)
 
dssmatrixoperator+= (const _dssmatrix &)
 
dssmatrixoperator-= (const dssmatrix &)
 
dssmatrixoperator-= (const _dssmatrix &)
 
dssmatrixoperator*= (const double &)
 
dssmatrixoperator/= (const double &)
 

Public Attributes

CPPL_INT const & m
 matrix row size More...
 
CPPL_INT n
 matrix column size More...
 
std::vector< dcomponentdata
 matrix data More...
 
std::vector< std::vector
< CPPL_INT > > 
line
 vector of vector to store the entry information of component for each row and column More...
 

Friends

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

Detailed Description

Real Double-precision Symmetric Sparse Matrix Class.

Definition at line 3 of file dssmatrix.hpp.

Constructor & Destructor Documentation

dssmatrix::dssmatrix ( )
inline

dssmatrix constructor without arguments

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

References data, line, and n.

4  : m(n)
5 {CPPL_VERBOSE_REPORT;
6  //////// initialize ////////
7  n =0;
8  data.clear();
9  line.clear();
10 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
dssmatrix::dssmatrix ( const dssmatrix mat)
inline

dssmatrix copy constructor

Definition at line 18 of file dssmatrix-constructor.hpp.

References copy(), data, and line.

19  : m(n)
20 {CPPL_VERBOSE_REPORT;
21  data.clear();
22  line.clear();
23  copy(mat);
24 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
void copy(const dssmatrix &)
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
dssmatrix::dssmatrix ( const _dssmatrix mat)
inline

dssmatrix constructor to cast _dssmatrix

Definition at line 28 of file dssmatrix-constructor.hpp.

References data, _dssmatrix::data, line, _dssmatrix::line, n, _dssmatrix::n, and _dssmatrix::nullify().

29  : m(n)
30 {CPPL_VERBOSE_REPORT;
31  n =mat.n;
32  data.clear();
33  line.clear();
34 
35  data.swap(mat.data);
36  line.swap(mat.line);
37 
38  mat.nullify();
39 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
std::vector< dcomponent > data
matrix data
Definition: _dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: _dssmatrix.hpp:13
void nullify() const
dssmatrix::dssmatrix ( const CPPL_INT &  _n,
const CPPL_INT  _c = 0 
)
inline

dssmatrix constructor with size specification

Definition at line 47 of file dssmatrix-constructor.hpp.

References data, line, and n.

48  : m(n)
49 {CPPL_VERBOSE_REPORT;
50 #ifdef CPPL_DEBUG
51  if( _n<0 || _c<0 ){
52  ERROR_REPORT;
53  std::cerr << "Matrix sizes and the length of arrays must be positive integers. " << std::endl
54  << "Your input was (" << _n << "," << _c << ")." << std::endl;
55  exit(1);
56  }
57 #endif//CPPL_DEBUG
58 
59  //////// initialize ////////
60  n =_n;
61  data.resize(0);
62  data.reserve(_c);
63  line.resize(n);
64 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
dssmatrix::dssmatrix ( const char *  filename)
inline

dssmatrix constructor with filename

Definition at line 68 of file dssmatrix-constructor.hpp.

References data, line, and read().

69  : m(n)
70 {CPPL_VERBOSE_REPORT;
71  data.clear();
72  line.clear();
73 
74  //// read ////
75  read(filename);
76 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
void read(const char *)
dssmatrix::~dssmatrix ( )
inline

dssmatrix destructor

Definition at line 84 of file dssmatrix-constructor.hpp.

References data, and line.

85 {CPPL_VERBOSE_REPORT;
86  data.clear();
87  line.clear();
88 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12

Member Function Documentation

_zhsmatrix dssmatrix::to_zhsmatrix ( ) const
inline

cast to _zhsmatrix

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

References _, data, n, and zhsmatrix::put().

4 {CPPL_VERBOSE_REPORT;
5  zhsmatrix newmat(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.0));
10  }
11 
12  return _(newmat);
13 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
Complex Double-precision Hermitian Sparse Matrix Class.
Definition: zhsmatrix.hpp:3
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dgematrix dssmatrix::to_dgematrix ( ) const
inline

convert to _dgematrix

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

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

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  newmat(it->j, it->i) =it->v;
30  }
31 
32  return _(newmat);
33 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
_dsymatrix dssmatrix::to_dsymatrix ( ) const
inline

convert to _dsymatrix

Definition at line 37 of file dssmatrix-cast.hpp.

References _, data, n, and dsymatrix::zero().

38 {CPPL_VERBOSE_REPORT;
39  dsymatrix newmat(n);
40  newmat.zero();
41 
42  const std::vector<dcomponent>::const_iterator data_end =data.end();
43  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
44  newmat(it->i, it->j) =it->v;
45  }
46 
47  return _(newmat);
48 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].
Definition: dsymatrix.hpp:3
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dgsmatrix dssmatrix::to_dgsmatrix ( ) const
inline

convert to _dgsmatrix

Definition at line 52 of file dssmatrix-cast.hpp.

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

53 {CPPL_VERBOSE_REPORT;
54  dgsmatrix newmat( dgsmatrix(m,n,CPPL_INT(data.size()*2)) );
55  newmat.zero();
56 
57  const std::vector<dcomponent>::const_iterator data_end =data.end();
58  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
59  newmat.put(it->i, it->j, it->v);
60  if(it->i!=it->j){
61  newmat.put(it->j, it->i, it->v);
62  }
63  }
64 
65  return _(newmat);
66 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
Real Double-precision General Sparse Matrix Class.
Definition: dgsmatrix.hpp:3
dgsmatrix & zero()
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
double dssmatrix::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

operator() for const object

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

References data, line, and n.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if( i<0 || j<0 || n<=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 " << n << "x" << n << "." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  //// search (i,j) component ////
15  const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
16 
17  const std::vector<CPPL_INT>::const_iterator line_ii_end =line[ii].end();
18  for(std::vector<CPPL_INT>::const_iterator p=line[ii].begin(); p!=line_ii_end; p++){
19  if(data[*p].i==ii && data[*p].j==jj){
20  return data[*p].v;
21  }
22  }
23 
24  //// (i,j) component was not found ////
25  return 0.0;
26 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
double & dssmatrix::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

operator() for const object

Definition at line 30 of file dssmatrix-io.hpp.

References data, line, and n.

31 {CPPL_VERBOSE_REPORT;
32 #ifdef CPPL_DEBUG
33  if( i<0 || j<0 || n<=i || n<=j ){
34  ERROR_REPORT;
35  std::cerr << "The required component is out of the matrix size." << std::endl
36  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << n << "x" << n << "." << std::endl;
37  exit(1);
38  }
39 #endif//CPPL_DEBUG
40 
41  //////// search (i,j) component ////////
42  const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
43 
44  const std::vector<CPPL_INT>::iterator line_ii_end =line[ii].end();
45  for(std::vector<CPPL_INT>::iterator p=line[ii].begin(); p!=line_ii_end; p++){
46  if(data[*p].i==ii && data[*p].j==jj){
47  return data[*p].v;
48  }
49  }
50 
51  //////// (i,j) component not found ////////
52  line[ii].push_back(CPPL_INT(data.size()));
53  if(i!=j){//off-diagonal
54  line[jj].push_back(CPPL_INT(data.size()));
55  }
56  data.push_back(dcomponent(ii,jj,0.));
57  return data.back().v;
58 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
Component Class for Real Double-precision Sparse Matrix Classes.
Definition: dcomponent.hpp:3
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
dssmatrix & dssmatrix::put ( const CPPL_INT &  i,
const CPPL_INT &  j,
const double &  v 
)
inline

put value with volume cheack without isListed check

Definition at line 66 of file dssmatrix-io.hpp.

References data, isListed(), line, and n.

Referenced by identity(), and read().

67 {CPPL_VERBOSE_REPORT;
68 #ifdef CPPL_DEBUG
69  if( i<0 || j<0 || n<=i || n<=j ){
70  ERROR_REPORT;
71  std::cerr << "The required component is out of the matrix size." << std::endl
72  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << n << "x" << n << "." << std::endl;
73  exit(1);
74  }
75 
76  if( isListed(i,j) ){
77  ERROR_REPORT;
78  std::cerr << "The required component is already listed." << std::endl
79  << "Your input was (" << i << "," << j << ")." << std::endl;
80  exit(1);
81  }
82 #endif//CPPL_DEBUG
83 
84  //// push ////
85  const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
86  line[ii].push_back(CPPL_INT(data.size()));
87  if(i!=j){//off-diagonal
88  line[jj].push_back(CPPL_INT(data.size()));
89  }
90  data.push_back(dcomponent(ii,jj,v));
91  return *this;
92 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
Component Class for Real Double-precision Sparse Matrix Classes.
Definition: dcomponent.hpp:3
bool isListed(const CPPL_INT &, const CPPL_INT &) const
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
dssmatrix & dssmatrix::del ( const CPPL_INT  i,
const CPPL_INT  j 
)
inline

delete the entry of a component

Definition at line 100 of file dssmatrix-io.hpp.

References data, line, and n.

Referenced by diet(), and stretch().

101 {CPPL_VERBOSE_REPORT;
102 #ifdef CPPL_DEBUG
103  if( i<0 || j<0 || n<=i || n<=j ){
104  ERROR_REPORT;
105  std::cerr << "The required component is out of the matrix size." << std::endl
106  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << n << "x" << n << "." << std::endl;
107  exit(1);
108  }
109 #endif//CPPL_DEBUG
110 
111  const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
112 
113  //////// search (i,j) component ////////
114  const std::vector<CPPL_INT>::iterator line_ii_end =line[ii].end();
115  for(std::vector<CPPL_INT>::iterator p=line[ii].begin(); p!=line_ii_end; p++){
116  if(data[*p].i==ii && data[*p].j==jj){//exists
117  //// save position ////
118  CPPL_INT c =*p;
119  CPPL_INT C =CPPL_INT(data.size()-1);
120 
121  //// data translation ////
122  data[c]=data.back();
123  data.pop_back();
124 
125  //// remove from List ////
126  line[ii].erase(p);
127  if(i!=j){//off-diagonal
128  const std::vector<CPPL_INT>::iterator line_jj_end =line[jj].end();
129  for(std::vector<CPPL_INT>::iterator pj=line[jj].begin(); pj!=line_jj_end; pj++){
130  if(*pj==c){ line[jj].erase(pj); break; }
131  }
132  }
133 
134  //// modify the entry of translated component ////
135  CPPL_INT I(data[c].i), J(data[c].j);
136  const std::vector<CPPL_INT>::iterator line_I_end =line[I].end();
137  for(std::vector<CPPL_INT>::iterator q=line[I].begin(); q!=line_I_end; q++){
138  if(*q==C){ *q=c; break; }
139  }
140  if(I!=J){//off-diagonal
141  const std::vector<CPPL_INT>::iterator line_J_end =line[J].end();
142  for(std::vector<CPPL_INT>::iterator q=line[J].begin(); q!=line_J_end; q++){
143  if(*q==C){ *q=c; break; }
144  }
145  }
146  return *this;
147  }
148  }
149 
150 #ifdef CPPL_DEBUG
151  std::cerr << "# [NOTE]@dssmatrix::del(CPPL_INT&, CPPL_INT&): The required component was not listed. Your input was (" << i << "," << j << ")." << std::endl;
152 #endif//CPPL_DEBUG
153 
154  return *this;
155 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
dssmatrix & dssmatrix::del ( const CPPL_INT  c)
inline

delete the entry of an element

Definition at line 159 of file dssmatrix-io.hpp.

References data, i(), and line.

160 {CPPL_VERBOSE_REPORT;
161 #ifdef CPPL_DEBUG
162  if( c<0 || c>=CPPL_INT(data.size()) ){
163  ERROR_REPORT;
164  std::cerr << "The required element is out of the matrix volume." << std::endl
165  << "Your input was (" << c << ")." << std::endl;
166  exit(1);
167  }
168 #endif//CPPL_DEBUG
169 
170  if( c==CPPL_INT(data.size()-1) ){//if c is the last element
171  CPPL_INT i(data[c].i), j(data[c].j);
172  const std::vector<CPPL_INT>::iterator line_i_end =line[i].end();
173  for(std::vector<CPPL_INT>::iterator q=line[i].begin(); q!=line_i_end; q++){
174  if(*q==c){ line[i].erase(q); break; }
175  }
176  if(i!=j){//off-diagonal
177  const std::vector<CPPL_INT>::iterator line_j_end =line[j].end();
178  for(std::vector<CPPL_INT>::iterator q=line[j].begin(); q!=line_j_end; q++){
179  if(*q==c){ line[j].erase(q); break; }
180  }
181  }
182  data.pop_back();
183  }
184 
185  else{//c is NOT the last element
186  //// data translation ////
187  CPPL_INT C =CPPL_INT(data.size()-1);
188  CPPL_INT i(data[c].i), j(data[c].j), I(data.back().i), J(data.back().j);
189  data[c]=data.back();
190  //std::cerr << "c=" << c << " i=" << i << " j=" << j << " C=" << vol << " I=" << I << " J=" << J << std::endl;
191 
192  //// remove entry of component ////
193  const std::vector<CPPL_INT>::iterator line_i_end =line[i].end();
194  for(std::vector<CPPL_INT>::iterator q=line[i].begin(); q!=line_i_end; q++){
195  if(*q==c){ line[i].erase(q); break; }
196  }
197  if(i!=j){//off-diagonal
198  const std::vector<CPPL_INT>::iterator line_j_end =line[j].end();
199  for(std::vector<CPPL_INT>::iterator q=line[j].begin(); q!=line_j_end; q++){
200  if(*q==c){ line[j].erase(q); break; }
201  }
202  }
203 
204  //// modify the entry of translated component ////
205  const std::vector<CPPL_INT>::iterator line_I_end =line[I].end();
206  for(std::vector<CPPL_INT>::iterator q=line[I].begin(); q!=line_I_end; q++){
207  if(*q==C){ *q=c; break; }
208  }
209  if(I!=J){//off-diagonal
210  const std::vector<CPPL_INT>::iterator line_J_end =line[J].end();
211  for(std::vector<CPPL_INT>::iterator q=line[J].begin(); q!=line_J_end; q++){
212  if(*q==C){ *q=c; break; }
213  }
214  }
215 
216  //// pop_back ////
217  data.pop_back();
218  }
219 
220  return *this;
221 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
void dssmatrix::write ( const char *  filename) const
inline

Definition at line 262 of file dssmatrix-io.hpp.

References data, and n.

263 {CPPL_VERBOSE_REPORT;
264  std::ofstream ofs(filename, std::ios::trunc);
265  ofs.setf(std::cout.flags());
266  ofs.precision(std::cout.precision());
267  ofs.width(std::cout.width());
268  ofs.fill(std::cout.fill());
269 
270  ofs << "#dssmatrix " << n << " " << data.size() << std::endl;
271 
272  const std::vector<dcomponent>::const_iterator data_end =data.end();
273  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
274  ofs << it->i << " " << it->j << " " << it->v << std::endl;
275  }
276 
277  ofs.close();
278 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void dssmatrix::read ( const char *  filename)
inline

Definition at line 281 of file dssmatrix-io.hpp.

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

Referenced by dssmatrix().

282 {CPPL_VERBOSE_REPORT;
283  std::ifstream s( filename );
284  if(!s){
285  ERROR_REPORT;
286  std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
287  exit(1);
288  }
289 
290  //////// id ////////
291  std::string id;
292  s >> id;
293  if( id != "dssmatrix" && id != "#dssmatrix" ){
294  ERROR_REPORT;
295  std::cerr << "The type name of the file \"" << filename << "\" is not dssmatrix." << std::endl
296  << "Its type name was " << id << " ." << std::endl;
297  exit(1);
298  }
299 
300  //////// n ////////
301  size_t size;
302  s >> n >> size;
303  resize(n);
304  data.reserve(size);
305 
306  //////// i, j, v ////////
307  CPPL_INT i, j;
308  double v;
309  for(size_t k=0; k<size; k++){
310  s >> i >> j >> v;
311  put(i,j, v);
312  }
313 
314  //////// check ////////
315  s >> i;
316  if(!s.eof()){
317  ERROR_REPORT;
318  std::cerr << "There is something is wrong with the file \"" << filename << " ." << std::endl
319  << "Most likely, there are too many data components over the context." << std::endl;
320  exit(1);
321  }
322  s.close();
323 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
dssmatrix & resize(const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
dssmatrix & put(const CPPL_INT &, const CPPL_INT &, const double &)
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void dssmatrix::clear ( )
inline

clear all the matrix data and set the sizes 0

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

References data, line, and n.

4 {CPPL_VERBOSE_REPORT;
5  n =0;
6  data.clear();
7  line.clear();
8 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
dssmatrix & dssmatrix::zero ( )
inline

change the matrix into a zero matrix

Definition at line 12 of file dssmatrix-misc.hpp.

References data, i(), line, and n.

Referenced by identity().

13 {CPPL_VERBOSE_REPORT;
14  data.resize(0);
15  for(CPPL_INT i=0; i<n; i++){ line[i].resize(0); }
16  return *this;
17 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
dssmatrix & dssmatrix::identity ( )
inline

change the matrix into an identity matrix

Definition at line 21 of file dssmatrix-misc.hpp.

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

22 {CPPL_VERBOSE_REPORT;
23  zero();
24  for(CPPL_INT i=0; i<n; i++){
25  put(i,i,1.);
26  }
27  return *this;
28 }
dssmatrix & put(const CPPL_INT &, const CPPL_INT &, const double &)
_dgematrix i(const _dgbmatrix &mat)
dssmatrix & zero()
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void dssmatrix::chsign ( )
inline

change sign(+/-) of the matrix

Definition at line 32 of file dssmatrix-misc.hpp.

References data.

33 {CPPL_VERBOSE_REPORT;
34  const std::vector<dcomponent>::iterator data_end =data.end();
35  for(std::vector<dcomponent>::iterator it=data.begin(); it!=data_end; it++){
36  it->v =-it->v;
37  }
38 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
void dssmatrix::copy ( const dssmatrix mat)
inline

make a deep copy of the matrix

Definition at line 42 of file dssmatrix-misc.hpp.

References data, line, and n.

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

43 {CPPL_VERBOSE_REPORT;
44  n =mat.n;
45  data =mat.data;
46  line =mat.line;
47 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void dssmatrix::shallow_copy ( const _dssmatrix mat)
inline

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

Definition at line 52 of file dssmatrix-misc.hpp.

References data, _dssmatrix::data, line, _dssmatrix::line, n, _dssmatrix::n, and _dssmatrix::nullify().

Referenced by operator=().

53 {CPPL_VERBOSE_REPORT;
54  data.clear();
55  line.clear();
56 
57  n =mat.n;
58  data.swap(mat.data);
59  line.swap(mat.line);
60 
61  mat.nullify();
62 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
std::vector< dcomponent > data
matrix data
Definition: _dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: _dssmatrix.hpp:13
void nullify() const
dssmatrix & dssmatrix::resize ( const CPPL_INT &  _n,
const CPPL_INT  _c = 0,
const CPPL_INT  _l = 0 
)
inline

resize the matrix

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

References data, i(), line, and n.

Referenced by read().

67 {CPPL_VERBOSE_REPORT;
68 #ifdef CPPL_DEBUG
69  if( _n<0 || _c<0 || _l<0 ){
70  ERROR_REPORT;
71  std::cerr << "Matrix sizes, the length of arrays, and line size must be positive integers. " << std::endl
72  << "Your input was (" << _n << "," << _c << "," << _l << ")." << std::endl;
73  exit(1);
74  }
75 #endif//CPPL_DEBUG
76 
77  n =_n;
78  data.resize(0);
79  data.reserve(_c);
80  line.resize(n);
81  for(CPPL_INT i=0; i<n; i++){
82  line[i].resize(0);
83  line[i].reserve(_l);
84  }
85 
86  return *this;
87 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void dssmatrix::stretch ( const CPPL_INT &  dn)
inline

stretch the matrix size

Definition at line 91 of file dssmatrix-misc.hpp.

References data, del(), i(), line, and n.

92 {CPPL_VERBOSE_REPORT;
93 #ifdef CPPL_DEBUG
94  if( n+dn<0 ){
95  ERROR_REPORT;
96  std::cerr << "The new matrix size must be larger than zero." << std::endl
97  << "Your input was (" << dn << ")." << std::endl;
98  exit(1);
99  }
100 #endif//CPPL_DEBUG
101 
102  //////// zero ////////
103  if(dn==0){ return; }
104 
105  //////// non-zero ////////
106  n +=dn;
107 
108  if(dn<0){
109  //// delete components over the new size ////
110  const std::vector<dcomponent>::reverse_iterator data_rend =data.rend();
111  for(std::vector<dcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
112  if( it->i>=n ){ del( CPPL_INT(data_rend-it-1) ); }
113  }
114  //// shrink line ////
115  for(CPPL_INT i=0; i<-dn; i++){
116  line.pop_back();
117  }
118  }
119  else{//dn>0
120  //// expand line ////
121  for(CPPL_INT i=0; i<dn; i++){
122  line.push_back( std::vector<CPPL_INT>(0) );
123  }
124  }
125 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
dssmatrix & del(const CPPL_INT, const CPPL_INT)
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
bool dssmatrix::isListed ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

check if the component is listed

Definition at line 129 of file dssmatrix-misc.hpp.

References data, line, and n.

Referenced by put().

130 {CPPL_VERBOSE_REPORT;
131 #ifdef CPPL_DEBUG
132  if( i<0 || j<0 || n<=i || n<=j ){
133  ERROR_REPORT;
134  std::cerr << "The required component is out of the matrix size." << std::endl
135  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << n << "x" << n << "." << std::endl;
136  exit(1);
137  }
138 #endif//CPPL_DEBUG
139 
140  const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
141 
142  const std::vector<CPPL_INT>::const_iterator line_ii_end =line[ii].end();
143  for(std::vector<CPPL_INT>::const_iterator p=line[ii].begin(); p!=line_ii_end; p++){
144  if(data[*p].i==ii && data[*p].j==jj){ return 1; }
145  }
146 
147  return 0;
148 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT dssmatrix::number ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

return the element number of the component

Definition at line 152 of file dssmatrix-misc.hpp.

References data, line, and n.

Referenced by operator<<().

153 {CPPL_VERBOSE_REPORT;
154 #ifdef CPPL_DEBUG
155  if( i<0 || j<0 || n<=i || n<=j ){
156  ERROR_REPORT;
157  std::cerr << "The required component is out of the matrix size." << std::endl
158  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << n << "x" << n << "." << std::endl;
159  exit(1);
160  }
161 #endif//CPPL_DEBUG
162 
163  const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
164 
165  const std::vector<CPPL_INT>::const_iterator line_ii_end =line[ii].end();
166  for(std::vector<CPPL_INT>::const_iterator p=line[ii].begin(); p!=line_ii_end; p++){
167  if(data[*p].i==ii && data[*p].j==jj){ return *p; }
168  }
169 
170  return -1;
171 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_drovector dssmatrix::row ( const CPPL_INT &  _m) const
inline

get row of the matrix

Definition at line 179 of file dssmatrix-misc.hpp.

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

180 {CPPL_VERBOSE_REPORT;
181 #ifdef CPPL_DEBUG
182  if( _m<0 || _m>m ){
183  ERROR_REPORT;
184  std::cerr << "Input row number must be between 0 and " << m << "." << std::endl
185  << "Your input was " << _m << "." << std::endl;
186  exit(1);
187  }
188 #endif//CPPL_DEBUG
189 
190  drovector vec(n);
191  vec.zero();
192 
193  const std::vector<CPPL_INT>::const_iterator line__m_end =line[_m].end();
194  for(std::vector<CPPL_INT>::const_iterator p=line[_m].begin(); p!=line__m_end; p++){
195  if(data[*p].i==_m){
196  vec(data[*p].j) =data[*p].v;
197  }
198  else{
199  vec(data[*p].i) =data[*p].v;
200  }
201  }
202  return _(vec);
203 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision Row Vector Class.
Definition: drovector.hpp:3
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
_dcovector dssmatrix::col ( const CPPL_INT &  _n) const
inline

get column of the matrix

Definition at line 207 of file dssmatrix-misc.hpp.

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

208 {CPPL_VERBOSE_REPORT;
209 #ifdef CPPL_DEBUG
210  if( _n<0 || _n>n ){
211  ERROR_REPORT;
212  std::cerr << "Input row number must be between 0 and " << n << "." << std::endl
213  << "Your input was " << _n << "." << std::endl;
214  exit(1);
215  }
216 #endif//CPPL_DEBUG
217 
218  dcovector vec(m);
219  vec.zero();
220 
221  const std::vector<CPPL_INT>::const_iterator line__n_end =line[_n].end();
222  for(std::vector<CPPL_INT>::const_iterator p=line[_n].begin(); p!=line__n_end; p++){
223  if(data[*p].i==_n){
224  vec(data[*p].j) =data[*p].v;
225  }
226  else{
227  vec(data[*p].i) =data[*p].v;
228  }
229  }
230  return _(vec);
231 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
void dssmatrix::diet ( const double  eps = DBL_MIN)
inline

erase components less than DBL_MIN

Definition at line 239 of file dssmatrix-misc.hpp.

References data, and del().

240 {CPPL_VERBOSE_REPORT;
241  const std::vector<dcomponent>::reverse_iterator data_rend =data.rend();
242  for(std::vector<dcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
243  if( fabs(it->v)<eps ){ del( CPPL_INT(data_rend-it-1) ); }
244  }
245 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
dssmatrix & del(const CPPL_INT, const CPPL_INT)
CPPL_INT dssmatrix::diag_front ( )
inline
void dssmatrix::reorder ( const bool  mode = 0)
inline

reorder components so that all diagonal componets are placed in front

reorder components

Definition at line 295 of file dssmatrix-misc.hpp.

References data, dcomponent::ilt(), dcomponent::jlt(), and rebuild().

296 {CPPL_VERBOSE_REPORT;
297  //// sort data ////
298  if(mode==0){
299  std::sort(data.begin(), data.end(), dcomponent::ilt);
300  }
301  else{
302  std::sort(data.begin(), data.end(), dcomponent::jlt);
303  }
304  //// rebuild line ////
305  rebuild();
306 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
static bool jlt(const dcomponent &, const dcomponent &)
Definition: dcomponent.hpp:47
static bool ilt(const dcomponent &, const dcomponent &)
Definition: dcomponent.hpp:40
void dssmatrix::rebuild ( )
inline

rebuild line

Definition at line 310 of file dssmatrix-misc.hpp.

References data, i(), line, and n.

Referenced by reorder().

311 {CPPL_VERBOSE_REPORT;
312  //// clear line ////
313  for(CPPL_INT i=0; i<n; i++){ line[i].resize(0); }
314 
315  //// build line ////
316  CPPL_INT c(0);
317  const std::vector<dcomponent>::iterator data_end =data.end();
318  for(std::vector<dcomponent>::iterator it=data.begin(); it!=data_end; it++){
319  line[it->i].push_back(c);
320  if( (it->i) != (it->j) ){
321  line[it->j].push_back(c);
322  }
323  c++;
324  }
325 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void dssmatrix::checkup ( )
inline

health checkup

Definition at line 333 of file dssmatrix-misc.hpp.

References data, i(), line, and n.

334 {CPPL_VERBOSE_REPORT;
335  //////// write ////////
336  const std::vector<dcomponent>::const_iterator data_end =data.end();
337  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
338  std::cerr << "array[" << it-data.begin() << "] = (" << it->i << "," << it->j << ") = " << it->v << std::endl;
339  }
340  std::cerr << std::endl;
341 
342  for(CPPL_INT i=0; i<n; i++){
343  std::cerr << "line[" << i << "] =" << std::flush;
344  const size_t line_i_size =line[i].size();
345  for(size_t k=0; k<line_i_size; k++){
346  std::cerr << " " << line[i][k] << std::flush;
347  }
348  std::cerr << std::endl;
349  }
350  std::cerr << std::endl;
351 
352  //////// Elements ////////
353  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
354  //// m bound ////
355  if(it->i>=n){
356  ERROR_REPORT;
357  std::cerr << "The indx of the " << it-data.begin() << "th element is out of the matrix size." << std::endl
358  << "Its i index was " << it->i << "." << std::endl;
359  exit(1);
360  }
361 
362  //// n bound ////
363  if(it->j>=n){
364  ERROR_REPORT;
365  std::cerr << "The jndx of the " << it-data.begin() << "th element is out of the matrix size." << std::endl
366  << "Its j index was " << it->j << "." << std::endl;
367  exit(1);
368  }
369 
370  //// double-listed ////
371  for(std::vector<dcomponent>::const_iterator IT=it+1; IT!=data_end; IT++){
372  if( it->i==IT->i && it->j==IT->j ){
373  ERROR_REPORT;
374  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;
375  exit(1);
376  }
377  }
378  }
379 
380  //////// NOTE ////////
381  std::cerr << "# [NOTE]@dssmatrix::checkup(): This symmetric sparse matrix is fine." << std::endl;
382 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT dssmatrix::pardiso_definite ( dcovector b) const
inline

solve A*x=b for real and symmetric positive definite 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 dssmatrix-pardiso.hpp.

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

8 {CPPL_VERBOSE_REPORT;
9 #ifndef __INTEL_COMPILER
10  ERROR_REPORT;
11  std::cerr << "dssmatrix::pardiso_definite 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!=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 line_i_end =line[i].end();
37  std::map<CPPL_INT,CPPL_INT> jc;
38  for(std::vector<CPPL_INT>::const_iterator lit=line[i].begin(); lit!=line_i_end; lit++){
39  if(data[*lit].j==i){//pardiso needs upper triangle part.
40  jc.insert( std::make_pair(data[*lit].i, *lit) );
41  }
42  }
43  //// assign ////
44  const std::map<CPPL_INT,CPPL_INT>::const_iterator jc_end =jc.end();
45  for(std::map<CPPL_INT,CPPL_INT>::const_iterator jcit=jc.begin(); jcit!=jc_end; jcit++){
46  a[k] =data[(*jcit).second].v;
47  ja[k] =MKL_INT((*jcit).first);
48  k++;
49  }
50  ia[i+1] =k;
51  }
52 
53  //////// pardisoinit ////////
54  //std::cerr << "initializing" << std::endl;
55  _MKL_DSS_HANDLE_t pt[64];
56  MKL_INT mtype =2;//real and symmetric positive definite
57  MKL_INT iparm[64];
58  PARDISOINIT(pt, &mtype, iparm);
59  iparm[1] =3;//parallel fill-in reducing ordering
60  iparm[23] =1;//use two-level scheduling factorization algorithm
61  iparm[26] =0;//disable matrix checker
62  iparm[34] =-1;//use zero-base array index
63 
64  //////// pardiso ////////
65  //std::cerr << "solving" << std::endl;
66  MKL_INT maxfct =1;
67  MKL_INT mnum =1;
68  MKL_INT phase =13;
69  MKL_INT MKL_INT_n =MKL_INT(n);
70  std::vector<MKL_INT> perm(n);
71  MKL_INT nrhs =1;
72  MKL_INT msglvl =0;
73  dcovector x(b.l);
74  MKL_INT error =1;
75  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);
76  swap(b,x);//set b as x
77  if(error!=0){
78  WARNING_REPORT;
79  std::cerr << "Serious trouble happend. error = " << error << "." << std::endl;
80  }
81 
82  //////// release memory ////////
83  phase =-1;
84  MKL_INT error2 =1;
85  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);
86 
87  return error;
88 #endif //__INTEL_COMPILER
89 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
friend void swap(dssmatrix &, dssmatrix &)
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
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
CPPL_INT dssmatrix::pardiso_indefinite ( dcovector b) const
inline

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

Definition at line 101 of file dssmatrix-pardiso.hpp.

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

102 {CPPL_VERBOSE_REPORT;
103 #ifndef __INTEL_COMPILER
104  ERROR_REPORT;
105  std::cerr << "dssmatrix::pardiso_indefinite is only for intel c++ compiler (icpc)." << std::endl;
106  std::cerr << "Recompile your code with icpc to use pardiso." << std::endl;
107  (void)b;
108  exit(1);
109 #else //__INTEL_COMPILER
110 
111 
112  //#ifdef CPPL_DEBUG
113  if(m!=b.l){
114  ERROR_REPORT;
115  std::cerr << "These matrix and vector cannot be solved." << std::endl
116  << "Your input was (" << m << "x" << n << ") and (" << b.l << ")." << std::endl;
117  exit(1);
118  }
119  //#endif//CPPL_DEBUG
120 
121  //////// convert matrix storage into compressed sparse row format ////////
122  //std::cerr << "converting" << std::endl;
123  std::vector<double> a(data.size());
124  std::vector<MKL_INT> ja(data.size());
125  std::vector<MKL_INT> ia(m+1);
126  ia[0] =0;
127  MKL_INT k=0;
128  for(CPPL_INT i=0; i<m; i++){
129  //// make map ////
130  const std::vector<CPPL_INT>::const_iterator line_i_end =line[i].end();
131  std::map<CPPL_INT,CPPL_INT> jc;
132  for(std::vector<CPPL_INT>::const_iterator lit=line[i].begin(); lit!=line_i_end; lit++){
133  if(data[*lit].j==i){//pardiso needs upper triangle part.
134  jc.insert( std::make_pair(data[*lit].i, *lit) );
135  }
136  }
137  //// assign ////
138  const std::map<CPPL_INT,CPPL_INT>::const_iterator jc_end =jc.end();
139  for(std::map<CPPL_INT,CPPL_INT>::const_iterator jcit=jc.begin(); jcit!=jc_end; jcit++){
140  a[k] =data[(*jcit).second].v;
141  ja[k] =MKL_INT((*jcit).first);
142  k++;
143  }
144  ia[i+1] =k;
145  }
146 
147  //////// pardisoinit ////////
148  //std::cerr << "initializing" << std::endl;
149  _MKL_DSS_HANDLE_t pt[64];
150  MKL_INT mtype =-2;//real and symmetric indefinite
151  MKL_INT iparm[64];
152  PARDISOINIT(pt, &mtype, iparm);
153  iparm[1] =3;//parallel fill-in reducing ordering
154  iparm[23] =1;//use two-level scheduling factorization algorithm
155  iparm[26] =0;//disable matrix checker
156  iparm[34] =-1;//use zero-base array index
157 
158  //////// pardiso ////////
159  //std::cerr << "solving" << std::endl;
160  MKL_INT maxfct =1;
161  MKL_INT mnum =1;
162  MKL_INT phase =13;
163  MKL_INT MKL_INT_n =MKL_INT(n);
164  std::vector<MKL_INT> perm(n);
165  MKL_INT nrhs =1;
166  MKL_INT msglvl =0;
167  dcovector x(b.l);
168  MKL_INT error =1;
169  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);
170  swap(b,x);//set b as x
171  if(error!=0){
172  WARNING_REPORT;
173  std::cerr << "Serious trouble happend. error = " << error << "." << std::endl;
174  }
175 
176  //////// release memory ////////
177  phase =-1;
178  MKL_INT error2 =1;
179  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);
180 
181  return error;
182 #endif //__INTEL_COMPILER
183 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
friend void swap(dssmatrix &, dssmatrix &)
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
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
CPPL_INT const & m
matrix row size
Definition: dssmatrix.hpp:9
dssmatrix & dssmatrix::operator= ( const dssmatrix mat)
inline

dssmatrix=dssmatrix operator

Definition at line 3 of file dssmatrix-dssmatrix.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 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
void copy(const dssmatrix &)
dssmatrix & dssmatrix::operator= ( const _dssmatrix mat)
inline

dssmatrix=_dssmatrix operator

Definition at line 3 of file dssmatrix-_dssmatrix.hpp.

References shallow_copy().

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

dssmatrix+=dssmatrix operator

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

References data, and n.

18 {CPPL_VERBOSE_REPORT;
19 #ifdef CPPL_DEBUG
20  if(n!=mat.n){
21  ERROR_REPORT;
22  std::cerr << "These two matrises can not make a summation." << std::endl
23  << "Your input was (" << n << "x" << n << ") += (" << mat.n << "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: dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
dssmatrix & dssmatrix::operator+= ( const _dssmatrix mat)
inline

dssmatrix+=_dssmatrix operator

Definition at line 15 of file dssmatrix-_dssmatrix.hpp.

References _dssmatrix::data, _dssmatrix::destroy(), n, and _dssmatrix::n.

16 {CPPL_VERBOSE_REPORT;
17 #ifdef CPPL_DEBUG
18  if(n!=mat.n){
19  ERROR_REPORT;
20  std::cerr << "These two matrises can not make a summation." << std::endl
21  << "Your input was (" << n << "x" << n << ") += (" << mat.n << "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 }
std::vector< dcomponent > data
matrix data
Definition: _dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void destroy() const
dssmatrix & dssmatrix::operator-= ( const dssmatrix mat)
inline

dssmatrix-=dssmatrix operator

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

References data, and n.

39 {CPPL_VERBOSE_REPORT;
40 #ifdef CPPL_DEBUG
41  if(n!=mat.n){
42  ERROR_REPORT;
43  std::cerr << "These two matrises can not make a sutraction." << std::endl
44  << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "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 
54  return *this;
55 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
dssmatrix & dssmatrix::operator-= ( const _dssmatrix mat)
inline

dssmatrix-=_dssmatrix operator

Definition at line 37 of file dssmatrix-_dssmatrix.hpp.

References _dssmatrix::data, _dssmatrix::destroy(), n, and _dssmatrix::n.

38 {CPPL_VERBOSE_REPORT;
39 #ifdef CPPL_DEBUG
40  if(n!=mat.n){
41  ERROR_REPORT;
42  std::cerr << "These two matrises can not make a sutraction." << std::endl
43  << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "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 }
std::vector< dcomponent > data
matrix data
Definition: _dssmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void destroy() const
dssmatrix & dssmatrix::operator*= ( const double &  d)
inline

dssmatrix*=double operator

Definition at line 3 of file dssmatrix-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: dssmatrix.hpp:11
dssmatrix & dssmatrix::operator/= ( const double &  d)
inline

dssmatrix/=double operator

Definition at line 15 of file dssmatrix-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: dssmatrix.hpp:11

Friends And Related Function Documentation

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

Definition at line 228 of file dssmatrix-io.hpp.

229 {CPPL_VERBOSE_REPORT;
230  for(CPPL_INT i=0; i<mat.n; i++){
231  for(CPPL_INT j=0; j<mat.n; j++){
232  if( i >= j ){
233  CPPL_INT c =mat.number(i,j);
234  if(c<0){
235  s << " x ";
236  }
237  else{
238  s << " " << mat.data[c].v << " ";
239  }
240  }
241  else{//i<j
242  CPPL_INT c =mat.number(i,j);
243  if(c<0){
244  s << "{x}";
245  }
246  else{
247  s << "{" << mat.data[c].v << "}";
248  }
249  }
250  }
251  s << std::endl;
252  }
253 
254  return s;
255 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
CPPL_INT number(const CPPL_INT &, const CPPL_INT &) const
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
void swap ( dssmatrix A,
dssmatrix B 
)
friend

swap two matrices

Definition at line 390 of file dssmatrix-misc.hpp.

Referenced by pardiso_definite(), and pardiso_indefinite().

391 {CPPL_VERBOSE_REPORT;
392  std::swap(A.n,B.n);
393  std::swap(A.data,B.data);
394  std::swap(A.line,B.line);
395 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
void swap(dssmatrix &A, dssmatrix &B)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dssmatrix _ ( dssmatrix mat)
friend

convert user object to smart-temporary object

Definition at line 399 of file dssmatrix-misc.hpp.

Referenced by col(), row(), to_dgematrix(), to_dgsmatrix(), to_dsymatrix(), and to_zhsmatrix().

400 {CPPL_VERBOSE_REPORT;
401  _dssmatrix newmat;
402 
403  //////// shallow copy ////////
404  newmat.n =mat.n;
405  std::swap(newmat.data,mat.data);
406  std::swap(newmat.line,mat.line);
407 
408  //////// nullify ////////
409  mat.n =0;
410 
411  return newmat;
412 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: dssmatrix.hpp:12
std::vector< dcomponent > data
matrix data
Definition: _dssmatrix.hpp:12
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Sparse Matrix Class
Definition: _dssmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
void swap(dssmatrix &A, dssmatrix &B)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
Definition: _dssmatrix.hpp:13
_dssmatrix t ( const dssmatrix mat)
friend

return transposed dssmatrix

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

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  WARNING_REPORT;
7  std::cerr << "This function call has no effect since the matrix is symmetric." << std::endl;
8 #endif//CPPL_DEBUG
9 
10  dssmatrix newmat(mat);
11  return _(newmat);
12 }
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
void idamax ( CPPL_INT &  i,
CPPL_INT &  j,
const dssmatrix mat 
)
friend

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

Definition at line 21 of file dssmatrix-calc.hpp.

22 {CPPL_VERBOSE_REPORT;
23  std::vector<dcomponent>::const_iterator itx(mat.data.begin());
24  double vmax =0.;
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  if( vmax < fabs(it->v) ){
29  vmax =fabs(it->v);
30  itx =it;
31  }
32  }
33 
34  i =itx->i;
35  j =itx->j;
36 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
_dgematrix i(const _dgbmatrix &mat)
friend _dgematrix i(const _dgematrix &)
double damax ( const dssmatrix mat)
friend

return its largest absolute value

Definition at line 40 of file dssmatrix-calc.hpp.

41 {CPPL_VERBOSE_REPORT;
42  std::vector<dcomponent>::const_iterator itx(mat.data.begin());
43  double vmax =0.;
44 
45  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
46  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
47  if( vmax < fabs(it->v) ){
48  vmax =fabs(it->v);
49  itx =it;
50  }
51  }
52 
53  return itx->v;
54 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
const dssmatrix& operator+ ( const dssmatrix mat)
friend

+dssmatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5  return mat;
6 }
_dssmatrix operator- ( const dssmatrix mat)
friend

-dssmatrix operator

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

11 {CPPL_VERBOSE_REPORT;
12  dssmatrix 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 }
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
_dgematrix operator+ ( const dssmatrix ,
const dgematrix  
)
friend
_dgematrix operator+ ( const dssmatrix ,
const _dgematrix  
)
friend
_dgematrix operator+ ( const dssmatrix ,
const dsymatrix  
)
friend
_dgematrix operator+ ( const dssmatrix ,
const _dsymatrix  
)
friend
_dgematrix operator+ ( const dssmatrix ,
const dgbmatrix  
)
friend
_dgematrix operator+ ( const dssmatrix ,
const _dgbmatrix  
)
friend
_dgsmatrix operator+ ( const dssmatrix ,
const dgsmatrix  
)
friend
_dgsmatrix operator+ ( const dssmatrix ,
const _dgsmatrix  
)
friend
_dssmatrix operator+ ( const dssmatrix matA,
const dssmatrix matB 
)
friend

dssmatrix+dssmatrix operator

Definition at line 63 of file dssmatrix-dssmatrix.hpp.

64 {CPPL_VERBOSE_REPORT;
65 #ifdef CPPL_DEBUG
66  if(matA.n!=matB.n){
67  ERROR_REPORT;
68  std::cerr << "These two matrises can not make a summation." << std::endl
69  << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
70  exit(1);
71  }
72 #endif//CPPL_DEBUG
73 
74  dssmatrix newmat(matA);
75 
76  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
77  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
78  newmat(it->i,it->j) +=it->v;
79  }
80 
81  return _(newmat);
82 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dssmatrix operator+ ( const dssmatrix matA,
const _dssmatrix matB 
)
friend

dssmatrix+_dssmatrix operator

Definition at line 63 of file dssmatrix-_dssmatrix.hpp.

64 {CPPL_VERBOSE_REPORT;
65 #ifdef CPPL_DEBUG
66  if(matA.n!=matB.n){
67  ERROR_REPORT;
68  std::cerr << "These two matrises can not make a summation." << std::endl
69  << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
70  exit(1);
71  }
72 #endif//CPPL_DEBUG
73 
74  dssmatrix newmat(matB);
75 
76  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
77  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
78  newmat(it->i,it->j) +=it->v;
79  }
80 
81  return _(newmat);
82 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dgematrix operator- ( const dssmatrix ,
const dgematrix  
)
friend
_dgematrix operator- ( const dssmatrix ,
const _dgematrix  
)
friend
_dgematrix operator- ( const dssmatrix ,
const dsymatrix  
)
friend
_dgematrix operator- ( const dssmatrix ,
const _dsymatrix  
)
friend
_dgematrix operator- ( const dssmatrix ,
const dgbmatrix  
)
friend
_dgematrix operator- ( const dssmatrix ,
const _dgbmatrix  
)
friend
_dgsmatrix operator- ( const dssmatrix ,
const dgsmatrix  
)
friend
_dgsmatrix operator- ( const dssmatrix ,
const _dgsmatrix  
)
friend
_dssmatrix operator- ( const dssmatrix matA,
const dssmatrix matB 
)
friend

dssmatrix-dssmatrix operator

Definition at line 86 of file dssmatrix-dssmatrix.hpp.

87 {CPPL_VERBOSE_REPORT;
88 #ifdef CPPL_DEBUG
89  if(matA.n!=matB.n){
90  ERROR_REPORT;
91  std::cerr << "These two matrises can not make a subtraction." << std::endl
92  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
93  exit(1);
94  }
95 #endif//CPPL_DEBUG
96 
97  dssmatrix newmat(matA);
98 
99  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
100  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
101  newmat(it->i,it->j) -=it->v;
102  }
103 
104  return _(newmat);
105 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dssmatrix operator- ( const dssmatrix matA,
const _dssmatrix matB 
)
friend

dssmatrix-_dssmatrix operator

Definition at line 86 of file dssmatrix-_dssmatrix.hpp.

87 {CPPL_VERBOSE_REPORT;
88 #ifdef CPPL_DEBUG
89  if(matA.n!=matB.n){
90  ERROR_REPORT;
91  std::cerr << "These two matrises can not make a subtraction." << std::endl
92  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
93  exit(1);
94  }
95 #endif//CPPL_DEBUG
96 
97  dssmatrix newmat(matB);
98 
99  const std::vector<dcomponent>::const_iterator matA_data_end =matA.data.end();
100  for(std::vector<dcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
101  newmat(it->i,it->j) -=it->v;
102  }
103 
104  return _(newmat);
105 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dssmatrix.hpp:11
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dcovector operator* ( const dssmatrix mat,
const dcovector vec 
)
friend

dssmatrix*dcovector operator

Definition at line 3 of file dssmatrix-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.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dcovector newvec(mat.n);
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  if(it->i!=it->j){
21  newvec(it->j) +=it->v*vec(it->i);
22  }
23  }
24 
25  return _(newvec);
26 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
CPPL_INT l
vector size
Definition: dcovector.hpp:9
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dcovector operator* ( const dssmatrix mat,
const _dcovector vec 
)
friend

dssmatrix*_dcovector operator

Definition at line 3 of file dssmatrix-_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.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  dcovector newvec(dcovector(mat.n));
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  if(it->i!=it->j){
21  newvec(it->j) +=it->v*vec(it->i);
22  }
23  }
24 
25  vec.destroy();
26  return _(newvec);
27 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
CPPL_INT l
vector size
Definition: _dcovector.hpp:9
void destroy() const
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
friend _dssmatrix _(dssmatrix &)
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dgematrix operator* ( const dssmatrix ,
const dgematrix  
)
friend
_dgematrix operator* ( const dssmatrix ,
const _dgematrix  
)
friend
_dgematrix operator* ( const dssmatrix ,
const dsymatrix  
)
friend
_dgematrix operator* ( const dssmatrix ,
const _dsymatrix  
)
friend
_dgematrix operator* ( const dssmatrix ,
const dgbmatrix  
)
friend
_dgematrix operator* ( const dssmatrix ,
const _dgbmatrix  
)
friend
_dgsmatrix operator* ( const dssmatrix ,
const dgsmatrix  
)
friend
_dgsmatrix operator* ( const dssmatrix ,
const _dgsmatrix  
)
friend
_dgsmatrix operator* ( const dssmatrix ,
const dssmatrix  
)
friend
_dgsmatrix operator* ( const dssmatrix ,
const _dssmatrix  
)
friend
_dssmatrix operator* ( const dssmatrix mat,
const double &  d 
)
friend

dssmatrix*double operator

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

32 {CPPL_VERBOSE_REPORT;
33  dssmatrix 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 }
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
_dssmatrix operator/ ( const dssmatrix mat,
const double &  d 
)
friend

dssmatrix/double operator

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

46 {CPPL_VERBOSE_REPORT;
47  dssmatrix 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 }
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
_dssmatrix operator* ( const double &  d,
const dssmatrix mat 
)
friend

double*dssmatrix operator

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

4 {CPPL_VERBOSE_REPORT;
5  dssmatrix 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 }
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
friend _dssmatrix _(dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3

Member Data Documentation

CPPL_INT const& dssmatrix::m

matrix row size

Definition at line 9 of file dssmatrix.hpp.

Referenced by col(), operator*(), pardiso_definite(), pardiso_indefinite(), row(), to_dgematrix(), and to_dgsmatrix().

CPPL_INT dssmatrix::n
std::vector<dcomponent> dssmatrix::data
std::vector< std::vector<CPPL_INT> > dssmatrix::line

vector of vector to store the entry information of component for each row and column

Definition at line 12 of file dssmatrix.hpp.

Referenced by _(), checkup(), clear(), col(), copy(), del(), dssmatrix(), isListed(), number(), operator()(), pardiso_definite(), pardiso_indefinite(), put(), rebuild(), resize(), row(), shallow_copy(), stretch(), swap(), zero(), and ~dssmatrix().


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