00001
00003 inline void zssmatrix::clear()
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] zssmatrix::clear()"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 std::cerr << "# [NOTE] zssmatrix::clear() "
00012 << " An array at " << Array
00013 << " is going to be cleared." << std::endl;
00014 #endif//CPPL_DEBUG
00015
00016 M =N =CAP =VOL=0;
00017 delete [] Array; Array =NULL;
00018 delete [] Indx; Indx =NULL;
00019 delete [] Jndx; Jndx =NULL;
00020 }
00021
00022
00024 inline void zssmatrix::zero()
00025 {
00026 #ifdef CPPL_VERBOSE
00027 std::cerr << "# [MARK] zssmatrix::zero()"
00028 << std::endl;
00029 #endif//CPPL_VERBOSE
00030
00031 VOL =0;
00032 }
00033
00034
00036 inline void zssmatrix::chsign()
00037 {
00038 #ifdef CPPL_VERBOSE
00039 std::cerr << "# [MARK] zssmatrix::chsign()"
00040 << std::endl;
00041 #endif//CPPL_VERBOSE
00042
00043 for(long i=0; i<VOL; i++){ Array[i] =-Array[i]; }
00044 }
00045
00046
00048 inline void zssmatrix::copy(const zssmatrix& mat)
00049 {
00050 #ifdef CPPL_VERBOSE
00051 std::cerr << "# [MARK] zssmatrix::copy(const zssmatrix&)"
00052 << std::endl;
00053 #endif//CPPL_VERBOSE
00054
00055 #ifdef CPPL_DEBUG
00056 std::cerr << "# [NOTE] zssmatrix::copy(const zssmatrix&) "
00057 << "A zssmatrix at " << Array << " is going to be deleted.";
00058 #endif//CPPL_DEBUG
00059
00060 resize(mat.M, mat.N, mat.CAP);
00061 VOL =mat.VOL;
00062 zcopy_(VOL, mat.Array, 1, Array, 1);
00063 for(long i=0; i<VOL; i++){
00064 Indx[i] =mat.Indx[i];
00065 Jndx[i] =mat.Jndx[i];
00066 }
00067
00068 #ifdef CPPL_DEBUG
00069 std::cerr << " Then, a COPY of a zssmatrix has been cleated at "
00070 << Array << "." << std::endl;
00071 #endif//CPPL_DEBUG
00072 }
00073
00074
00077 inline void zssmatrix::shallow_copy(const _zssmatrix& mat)
00078 {
00079 #ifdef CPPL_VERBOSE
00080 std::cerr << "# [MARK] zssmatrix::shallow_copy(const _zssmatrix&)"
00081 << std::endl;
00082 #endif//CPPL_VERBOSE
00083
00084 #ifdef CPPL_DEBUG
00085 std::cerr << "# [NOTE] zssmatrix:shallow_copy(const _zssmatrix&) "
00086 << "A zssmatrix at " << Array << " is going to be deleted, "
00087 << "and point at " << mat.Array << " instead." << std::endl;
00088 #endif//CPPL_DEBUG
00089
00090 delete [] Array;
00091 delete [] Indx;
00092 delete [] Jndx;
00093 M =mat.M;
00094 N =mat.N;
00095 CAP =mat.CAP;
00096 VOL =mat.VOL;
00097 Array =mat.Array;
00098 Indx =mat.Indx;
00099 Jndx =mat.Jndx;
00100 }
00101
00102
00104 inline void zssmatrix::resize(const long& _m, const long& _n, const long& _c)
00105 {
00106 #ifdef CPPL_VERBOSE
00107 std::cerr << "# [MARK] zssmatrix::resize(const long&, const long&, const long&)"
00108 << std::endl;
00109 #endif//CPPL_VERBOSE
00110
00111 #ifdef CPPL_DEBUG
00112 if( _m<0 || _n<0 || _c<0 ){
00113 std::cerr << "[ERROR] zssmatrix::resize"
00114 << "(const long&, const long&, const long&)"
00115 << std::endl
00116 << "Matrix sizes and the length of arrays "
00117 << "must be positive integers. " << std::endl
00118 << "Your input was (" << _m << "," << _n << "," << _c << ")."
00119 << std::endl;
00120 exit(1);
00121 }
00122 #endif//CPPL_DEBUG
00123
00124 delete [] Array;
00125 M =_m;
00126 N =_n;
00127 CAP =_c;
00128 VOL =0;
00129 Array =new std::complex<double>[CAP];
00130 Indx =new long[CAP];
00131 Jndx =new long[CAP];
00132 }
00133
00134
00136 inline void zssmatrix::expand(const long& dc)
00137 {
00138 #ifdef CPPL_VERBOSE
00139 std::cerr << "# [MARK] zssmatrix::expand(const long&)"
00140 << std::endl;
00141 #endif//CPPL_VERBOSE
00142
00143 #ifdef CPPL_DEBUG
00144 if( dc<0 ){
00145 std::cerr << "[ERROR] zssmatrix::expand(const long&)" << std::endl
00146 << "The argument must be a positive integer. " << std::endl
00147 << "Your input was (" << dc << ")." << std::endl;
00148 exit(1);
00149 }
00150 #endif//CPPL_DEBUG
00151
00152 CAP+=dc;
00153 std::complex<double>* newArray(new std::complex<double>[CAP]);
00154 long *newIndx(new long[CAP]), *newJndx(new long[CAP]);
00155
00156 for(int c=0; c<VOL; c++){
00157 newArray[c] =Array[c];
00158 newIndx[c] =Indx[c];
00159 newJndx[c] =Jndx[c];
00160 }
00161
00162 delete [] Array;
00163 delete [] Indx;
00164 delete [] Jndx;
00165 Array =newArray;
00166 Indx =newIndx;
00167 Jndx =newJndx;
00168 }
00169
00170
00172 inline bool zssmatrix::isListed(const long& i, const long& j)
00173 {
00174 #ifdef CPPL_VERBOSE
00175 std::cerr << "# [MARK] zssmatrix::isListed(const long&, const long&)"
00176 << std::endl;
00177 #endif//CPPL_VERBOSE
00178
00179 #ifdef CPPL_DEBUG
00180 if( i<0 || j<0 || M<=i || N<=j ){
00181 std::cerr << "[ERROR] zssmatrix::isListed(const long&, const long&)"
00182 << std::endl
00183 << "The required component is out of the matrix size."
00184 << std::endl
00185 << "Your input was (" << i << "," << j << ")." << std::endl;
00186 exit(1);
00187 }
00188 #endif//CPPL_DEBUG
00189
00190 for(int c=0; c<VOL; c++){
00191 if(Indx[c]==i && Jndx[c]==j){ return 1; }
00192 }
00193
00194 return 0;
00195 }
00196
00197
00198
00200 inline long zssmatrix::number(const long& i, const long& j)
00201 {
00202 #ifdef CPPL_VERBOSE
00203 std::cerr << "# [MARK] zssmatrix::number(const long&, const long&)"
00204 << std::endl;
00205 #endif//CPPL_VERBOSE
00206
00207 #ifdef CPPL_DEBUG
00208 if( i<0 || j<0 || M<=i || N<=j ){
00209 std::cerr << "[ERROR] zssmatrix::number(const long&, const long&)"
00210 << std::endl
00211 << "The required component is out of the matrix size."
00212 << std::endl
00213 << "Your input was (" << i << "," << j << ")." << std::endl;
00214 exit(1);
00215 }
00216 #endif//CPPL_DEBUG
00217
00218 for(long c=0; c<VOL; c++){
00219 if(Indx[c]==i && Jndx[c]==j){ return c; }
00220 }
00221
00222 return -1;
00223 }
00224
00225
00226
00228 inline void swap(zssmatrix& A, zssmatrix& B)
00229 {
00230 #ifdef CPPL_VERBOSE
00231 std::cerr << "# [MARK] swap(zssmatrix&, zssmatrix&)"
00232 << std::endl;
00233 #endif//CPPL_VERBOSE
00234
00235 long A_M(A.M), A_N(A.N), A_CAP(A.CAP), A_VOL(A.VOL);
00236 std::complex<double>* A_Array(A.Array);
00237 long *A_Indx(A.Indx), *A_Jndx(A.Jndx);
00238 A.M=B.M; A.N=B.N; A.CAP=B.CAP; A.VOL=B.VOL;
00239 A.Array=B.Array; A.Indx=B.Indx; A.Jndx=B.Jndx;
00240 B.M=A_M; B.N=A_N; B.CAP=A_CAP; B.VOL=A_VOL;
00241 B.Array=A_Array; B.Indx=A_Indx; B.Jndx=A_Jndx;
00242 }
00243
00244
00246 inline _zssmatrix _(zssmatrix& mat)
00247 {
00248 #ifdef CPPL_VERBOSE
00249 std::cerr << "# [MARK] _(zssmatrix&)"
00250 << std::endl;
00251 #endif//CPPL_VERBOSE
00252
00253 _zssmatrix newmat;
00254
00255 newmat.M =mat.M;
00256 newmat.N =mat.N;
00257 newmat.CAP =mat.CAP;
00258 newmat.VOL =mat.VOL;
00259 newmat.Array =mat.Array;
00260 newmat.Indx =mat.Indx;
00261 newmat.Jndx =mat.Jndx;
00262
00263 mat.M =0;
00264 mat.N =0;
00265 mat.CAP =0;
00266 mat.VOL =0;
00267 mat.Array =NULL;
00268 mat.Indx =NULL;
00269 mat.Jndx =NULL;
00270
00271 return newmat;
00272 }
00273
00277
00278
00280 inline void zssmatrix::checkup()
00281 {
00282 #ifdef CPPL_VERBOSE
00283 std::cerr << "# [MARK] zssmatrix::checkup()"
00284 << std::endl;
00285 #endif//CPPL_VERBOSE
00286
00288 if(CAP<0){
00289 std::cerr << "[ERROR] zssmatrix::checkup()" << std::endl
00290 << "The cap is not valid." << std::endl
00291 << "CAP was " << CAP << "." << std::endl;
00292 exit(1);
00293 }
00294
00296 if(VOL<0 || VOL==CAP){
00297 std::cerr << "[ERROR] zssmatrix::checkup()" << std::endl
00298 << "The vol is not valid." << std::endl
00299 << "VOL was " << VOL << "while CAP is " << CAP << "."
00300 << std::endl;
00301 exit(1);
00302 }
00303
00305 for(long c=0; c<VOL; c++){
00307 if(Indx[c]<0 || Indx[c]>=M){
00308 std::cerr << "[ERROR] zssmatrix::checkup()" << std::endl
00309 << "The indx of the " << c
00310 << "th element is out of the matrix size." << std::endl
00311 << "Indx[" << c << "] was " << Indx[c] << "." << std::endl;
00312 exit(1);
00313 }
00314
00316 if(Jndx[c]<0 || Jndx[c]>=N){
00317 std::cerr << "[ERROR] zssmatrix::checkup()" << std::endl
00318 << "The jndx of the " << c
00319 << "th element is out of the matrix size." << std::endl
00320 << "Jndx[" << c << "] was " << Jndx[c] << "." << std::endl;
00321 exit(1);
00322 }
00323
00325 for(long C=c+1; C<VOL; C++){
00326 if(Indx[c]==Indx[C] && Jndx[c]==Jndx[C]){
00327 std::cerr << "[ERROR] zssmatrix::checkup()" << std::endl
00328 << "The (" << Indx[c] << ", " << Jndx[c]
00329 << ") component is std::complex<double>-listed at the "
00330 << c << "th and the" << C << "the elements."<< std::endl;
00331 exit(1);
00332 }
00333 }
00334 }
00335
00337 std::cerr << "# [NOTE] zssmatrix::checkup() "
00338 << "This sparse matrix is fine." << std::endl;
00339 }