6 std::cerr <<
"# [MARK] zssmatrix::operator()(const long&, const long&) const"
11 if( i<0 || j<0 || M<=i || N<=j ){
12 std::cerr <<
"[ERROR] zssmatrix::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] zssmatrix::operator()(long, long)" << std::endl
26 <<
"The required component is out of the matrix size."
28 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
38 inline void zssmatrix::put(
const long& i,
const long& j,
const std::complex<double>& v)
41 std::cerr <<
"# [MARK] zssmatrix::put(const long&, const long&, const std::complex<double>&)"
46 if( i<0 || j<0 || M<=i || N<=j ){
47 std::cerr <<
"[ERROR] zssmatrix::put(long&, long&, std::complex<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] zssmatrix::put(long&, long&, std::complex<double>&) "
65 <<
"The matrix volume was automatically expanded." << std::endl;
69 Indx[VOL]=i; Jndx[VOL]=j;
Array[VOL]=v;
75 inline void zssmatrix::fput(
const long& i,
const long& j,
const std::complex<double>& v)
78 std::cerr <<
"# [MARK] zssmatrix::fput(const long&, const long&, const std::complex<double>&)"
83 if( i<0 || j<0 || M<=i || N<=j ){
84 std::cerr <<
"[ERROR] zssmatrix::fput"
85 <<
"(const long&, lconst ong&, const std::complex<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] zssmatrix::fput"
94 <<
"(const long&, const long&, const std::complex<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] zssmatrix::fput"
102 <<
"(const long&, const long&, const std::complex<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;
120 inline void zssmatrix::add(
const long& i,
const long& j,
const std::complex<double>& v)
123 std::cerr <<
"# [MARK] zssmatrix::add(const long&, const long&, const std::complex<double>&)"
128 if( i<0 || j<0 || M<=i || N<=j ){
129 std::cerr <<
"[ERROR] zssmatrix::add(long&, long&, std::complex<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] zssmatrix::add(long&, long&, std::complex<double>&) "
147 <<
"The matrix volume was automatically expanded." << std::endl;
151 Indx[VOL]=i; Jndx[VOL]=j;
Array[VOL]=v;
157 inline void zssmatrix::sub(
const long& i,
const long& j,
const std::complex<double>& v)
160 std::cerr <<
"# [MARK] zssmatrix::sub(const long&, const long&, const std::complex<double>&)"
165 if( i<0 || j<0 || M<=i || N<=j ){
166 std::cerr <<
"[ERROR] zssmatrix::sub(long&, long&, std::complex<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] zssmatrix::sub(long&, long&, std::complex<double>&) "
184 <<
"The matrix volume was automatically expanded." << std::endl;
188 Indx[VOL]=i; Jndx[VOL]=j;
Array[VOL]=-v;
194 inline void zssmatrix::mult(
const long& i,
const long& j,
const std::complex<double>& v)
197 std::cerr <<
"# [MARK] zssmatrix::mult(const long&, const long&, const std::complex<double>&)"
202 if( i<0 || j<0 || M<=i || N<=j ){
203 std::cerr <<
"[ERROR] zssmatrix::mult(long&, long&, std::complex<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; }
222 inline void zssmatrix::div(
const long& i,
const long& j,
const std::complex<double>& v)
225 std::cerr <<
"# [MARK] zssmatrix::div(const long&, const long&, const std::complex<double>&)"
230 if( i<0 || j<0 || M<=i || N<=j ){
231 std::cerr <<
"[ERROR] zssmatrix::div(long&, long&, std::complex<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] zssmatrix::del(const long&, const long&)"
262 if( i<0 || j<0 || M<=i || N<=j ){
263 std::cerr <<
"[ERROR] zssmatrix::del(long&, long&, std::complex<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] zssmatrix::del(long&, long&, std::complex<double>&) "
280 <<
"The required component was not listed. "
281 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
289 std::cerr <<
"# [MARK] zssmatrix::fdel(const long&)"
295 std::cerr <<
"[ERROR] zssmatrix::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] zssmatrix::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 zssmatrix& mat)
319 std::cerr <<
"# [MARK] operator<<(std::ostream&, const zssmatrix&)"
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 zssmatrix::write(
const char* filename)
const
348 std::cerr <<
"# [MARK] zssmatrix::write(const char*) const"
352 std::ofstream s(filename, std::ios::trunc);
354 s <<
"zssmatrix" <<
" " << 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 zssmatrix::read(
const char *filename)
365 std::cerr <<
"# [MARK] zssmatrix::read(const char*)"
369 std::ifstream s( filename );
371 std::cerr <<
"[ERROR] zssmatrix::read(const char*) " << std::endl
372 <<
"The file \"" << filename <<
"\" can not be opened."
379 if(
id !=
"zssmatrix" ){
380 std::cerr <<
"[ERROR] zssmatrix::read(const char*) " << std::endl
381 <<
"The type name of the file \"" << filename
382 <<
"\" is not zssmatrix." << 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] zssmatrix::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;
void fdel(const long &)
Definition: zssmatrix-io.hpp:286
void fput(const long &, const long &, const std::complex< double > &)
Definition: zssmatrix-io.hpp:75
void expand(const long &)
Definition: zssmatrix-misc.hpp:136
void add(const long &, const long &, const std::complex< double > &)
Definition: zssmatrix-io.hpp:120
void mult(const long &, const long &, const std::complex< double > &)
Definition: zssmatrix-io.hpp:194
void sub(const long &, const long &, const std::complex< double > &)
Definition: zssmatrix-io.hpp:157
std::complex< double > operator()(const long &, const long &) const
Definition: zssmatrix-io.hpp:3
void resize(const long &, const long &, const long &)
Definition: zssmatrix-misc.hpp:104
std::complex< double > * Array
1D Array to store vector data
Definition: _zrovector.hpp:8
void div(const long &, const long &, const std::complex< double > &)
Definition: zssmatrix-io.hpp:222
Complex Double-precision Sparse Matrix Class.
Definition: zssmatrix.hpp:3
void put(const long &, const long &, const std::complex< double > &)
Definition: zssmatrix-io.hpp:38
void del(const long &, const long &)
Definition: zssmatrix-io.hpp:254