6 std::cerr <<
"# [MARK] dssmatrix::operator()(const long&, const long&) const"
11 if( i<0 || j<0 || M<=i || N<=j ){
12 std::cerr <<
"[ERROR] dssmatrix::operator()(long, long)" << std::endl
13 <<
"The required component is out of the matrix size."
15 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
20 for(
long c=0; c<VOL; c++){
21 if(Indx[c]==i && Jndx[c]==j){
return Array[c]; }
25 std::cerr <<
"[ERROR] dssmatrix::operator()(long, long)" << std::endl
26 <<
"The required component is out of the matrix size."
28 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
41 std::cerr <<
"# [MARK] dssmatrix::put(const long&, const long&, const double&)"
46 if( i<0 || j<0 || M<=i || N<=j ){
47 std::cerr <<
"[ERROR] dssmatrix::put(long&, long&, double&)" << std::endl
48 <<
"The required component is out of the matrix size."
50 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
56 for(
long c=0; c<VOL; c++){
57 if(Indx[c]==i && Jndx[c]==j){
Array[c]=v;
return; }
64 std::cerr <<
"[NOTE] dssmatrix::put(long&, long&, double&) "
65 <<
"The matrix volume was automatically expanded." << std::endl;
69 Indx[VOL]=i; Jndx[VOL]=j;
Array[VOL]=v;
78 std::cerr <<
"# [MARK] dssmatrix::fput(const long&, const long&, const double&)"
83 if( i<0 || j<0 || M<=i || N<=j ){
84 std::cerr <<
"[ERROR] dssmatrix::fput"
85 <<
"(const long&, lconst ong&, const double&)" << std::endl
86 <<
"The required component is out of the matrix size."
88 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
93 std::cerr <<
"[ERROR] dssmatrix::fput"
94 <<
"(const long&, const long&, const double&)" << std::endl
95 <<
"There is no free space to set a new entry." << std::endl;
99 for(
long c=0; c<VOL; c++){
100 if(Indx[c]==i && Jndx[c]==j){
101 std::cerr <<
"[ERROR] dssmatrix::fput"
102 <<
"(const long&, const long&, const double&)" << std::endl
103 <<
"The required component is already listed." << std::endl
104 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
110 Indx[VOL]=i; Jndx[VOL]=j;
Array[VOL]=v;
123 std::cerr <<
"# [MARK] dssmatrix::add(const long&, const long&, const double&)"
128 if( i<0 || j<0 || M<=i || N<=j ){
129 std::cerr <<
"[ERROR] dssmatrix::add(long&, long&, double&)" << std::endl
130 <<
"The required component is out of the matrix size."
132 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
138 for(
long c=0; c<VOL; c++){
139 if(Indx[c]==i && Jndx[c]==j){
Array[c]+=v;
return; }
146 std::cerr <<
"[NOTE] dssmatrix::add(long&, long&, double&) "
147 <<
"The matrix volume was automatically expanded." << std::endl;
151 Indx[VOL]=i; Jndx[VOL]=j;
Array[VOL]=v;
160 std::cerr <<
"# [MARK] dssmatrix::sub(const long&, const long&, const double&)"
165 if( i<0 || j<0 || M<=i || N<=j ){
166 std::cerr <<
"[ERROR] dssmatrix::sub(long&, long&, double&)" << std::endl
167 <<
"The required component is out of the matrix size."
169 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
175 for(
long c=0; c<VOL; c++){
176 if(Indx[c]==i && Jndx[c]==j){
Array[c]-=v;
return; }
183 std::cerr <<
"[NOTE] dssmatrix::sub(long&, long&, double&) "
184 <<
"The matrix volume was automatically expanded." << std::endl;
188 Indx[VOL]=i; Jndx[VOL]=j;
Array[VOL]=-v;
197 std::cerr <<
"# [MARK] dssmatrix::mult(const long&, const long&, const double&)"
202 if( i<0 || j<0 || M<=i || N<=j ){
203 std::cerr <<
"[ERROR] dssmatrix::mult(long&, long&, double&)" << std::endl
204 <<
"The required component is out of the matrix size."
206 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
212 for(
long c=0; c<VOL; c++){
213 if(Indx[c]==i && Jndx[c]==j){
Array[c]*=v;
return; }
225 std::cerr <<
"# [MARK] dssmatrix::div(const long&, const long&, const double&)"
230 if( i<0 || j<0 || M<=i || N<=j ){
231 std::cerr <<
"[ERROR] dssmatrix::div(long&, long&, double&)" << std::endl
232 <<
"The required component is out of the matrix size."
234 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
240 for(
long c=0; c<VOL; c++){
241 if(Indx[c]==i && Jndx[c]==j){
Array[c]/=v;
return; }
257 std::cerr <<
"# [MARK] dssmatrix::del(const long&, const long&)"
262 if( i<0 || j<0 || M<=i || N<=j ){
263 std::cerr <<
"[ERROR] dssmatrix::del(long&, long&, double&)" << std::endl
264 <<
"The required component is out of the matrix size."
266 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
271 for(
long c=0; c<VOL; c++){
272 if(Indx[c]==i && Jndx[c]==j){
274 Indx[c]=Indx[VOL]; Jndx[c]=Jndx[VOL];
Array[c]=
Array[VOL];
279 std::cerr <<
"[WARNING] dssmatrix::del(long&, long&, double&) "
280 <<
"The required component was not listed. "
281 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
289 std::cerr <<
"# [MARK] dssmatrix::fdel(const long&)"
295 std::cerr <<
"[ERROR] dssmatrix::fdel(const long&)" << std::endl
296 <<
"The required element is out of the matrix volume."
298 <<
"Your input was (" << c <<
")." << std::endl;
302 std::cerr <<
"# [NOTE] dssmatrix::fdel(const long&) "
303 <<
"The (" << Indx[c] <<
"," << Jndx[c]
304 <<
") component is going to be deleted." << std::endl;
308 Indx[c]=Indx[VOL]; Jndx[c]=Jndx[VOL];
Array[c]=
Array[VOL];
316 inline std::ostream& operator<<(std::ostream& s,
const dssmatrix& mat)
319 std::cerr <<
"# [MARK] operator<<(std::ostream&, const dssmatrix&)"
324 for(
long i=0; i<mat.M; i++){
325 for(
long j=0; j<mat.N; j++){
328 if(mat.Indx[c]==i && mat.Jndx[c]==j){
break; }
331 if(c!=mat.VOL){ s << mat.Array[c] <<
" "; }
345 inline void dssmatrix::write(
const char* filename)
const
348 std::cerr <<
"# [MARK] dssmatrix::write(const char*) const"
352 std::ofstream s(filename, std::ios::trunc);
354 s <<
"dssmatrix" <<
" " << M <<
" " << N <<
" " << CAP << std::endl;
355 for(
long c=0; c<VOL; c++){
356 s << Indx[c] <<
" " << Jndx[c] <<
" " <<
Array[c] << std::endl;
362 inline void dssmatrix::read(
const char* filename)
365 std::cerr <<
"# [MARK] dssmatrix::read(const char*)"
369 std::ifstream s( filename );
371 std::cerr <<
"[ERROR] dssmatrix::read(const char*) " << std::endl
372 <<
"The file \"" << filename <<
"\" can not be opened."
379 if(
id !=
"dssmatrix" ){
380 std::cerr <<
"[ERROR] dssmatrix::read(const char*) " << std::endl
381 <<
"The type name of the file \"" << filename
382 <<
"\" is not dssmatrix." << std::endl
383 <<
"Its type name was " <<
id <<
" ." << std::endl;
391 while(!s.eof() && VOL<CAP){
392 s >> Indx[VOL] >> Jndx[VOL] >>
Array[VOL];
393 pos =s.tellg(); s >> tmp; s.seekg(pos);
398 std::cerr <<
"[ERROR] dssmatrix::read(const char*) " << std::endl
399 <<
"There is something is wrong with the file \""
400 << filename <<
" ." << std::endl
401 <<
"Most likely, there are too many data components "
402 <<
"over the context." << std::endl;
double operator()(const long &, const long &) const
Definition: dssmatrix-io.hpp:3
void div(const long &, const long &, const double &)
Definition: dssmatrix-io.hpp:222
void del(const long &, const long &)
Definition: dssmatrix-io.hpp:254
void sub(const long &, const long &, const double &)
Definition: dssmatrix-io.hpp:157
void mult(const long &, const long &, const double &)
Definition: dssmatrix-io.hpp:194
void add(const long &, const long &, const double &)
Definition: dssmatrix-io.hpp:120
Real Double-precision Sparse Matrix Class.
Definition: dssmatrix.hpp:3
double * Array
1D Array to store vector data
Definition: _drovector.hpp:8
void fdel(const long &)
Definition: dssmatrix-io.hpp:286
void fput(const long &, const long &, const double &)
Definition: dssmatrix-io.hpp:75
void resize(const long &, const long &, const long &)
Definition: dssmatrix-misc.hpp:104
void put(const long &, const long &, const double &)
Definition: dssmatrix-io.hpp:38
void expand(const long &)
Definition: dssmatrix-misc.hpp:136