00001
00003 inline std::complex<double> _zssmatrix::operator()(const long& i, const long& j) const
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] _zssmatrix::operator()(const long&, const long&) const"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 if( i<0 || j<0 || M<=i || N<=j ){
00012 std::cerr << "[ERROR] _zssmatrix::operator()(long, long)" << std::endl
00013 << "The required component is out of the matrix size."
00014 << std::endl
00015 << "Your input was (" << i << "," << j << ")." << std::endl;
00016 exit(1);
00017 }
00018 #endif//CPPL_DEBUG
00019
00020 for(long c=0; c<VOL; c++){
00021 if(Indx[c]==i && Jndx[c]==j){ return Array[c]; }
00022 }
00023
00024 return std::complex<double>(0.0,0.0);
00025 }
00026
00030
00031
00032 inline std::ostream& operator<<(std::ostream& s, const _zssmatrix& mat)
00033 {
00034 #ifdef CPPL_VERBOSE
00035 std::cerr << "# [MARK] operator<<(std::ostream&, const _zssmatrix&)"
00036 << std::endl;
00037 #endif//CPPL_VERBOSE
00038
00039 long c;
00040 for(long i=0; i<mat.M; i++){
00041 for(long j=0; j<mat.N; j++){
00042 c=0;
00043 while(c<mat.VOL){
00044 if(mat.Indx[c]==i && mat.Jndx[c]==j){ break; }
00045 c++;
00046 }
00047 if(c!=mat.VOL){ s << mat.Array[c] << " "; }
00048 else{ s << "x "; }
00049 }
00050 s << std::endl;
00051 }
00052
00053 mat.destroy();
00054 return s;
00055 }
00056
00060
00061
00062 inline void _zssmatrix::write(const char* filename) const
00063 {
00064 #ifdef CPPL_VERBOSE
00065 std::cerr << "# [MARK] _zssmatrix::write(const char*) const"
00066 << std::endl;
00067 #endif//CPPL_VERBOSE
00068
00069 std::ofstream s(filename, std::ios::trunc);
00070
00071 s << "_zssmatrix" << " " << M << " " << N << " " << CAP << std::endl;
00072 for(long c=0; c<VOL; c++){
00073 s << Indx[c] << " " << Jndx[c] << " " << Array[c] << std::endl;
00074 }
00075
00076 s.close();
00077 destroy();
00078 }