00001
00003 inline void zgbmatrix::clear()
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] zgbmatrix::clear()"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 std::cerr << "# [NOTE] zgbmatrix::clear() "
00012 << " An array at " << Array
00013 << " is going to be cleared." << std::endl;
00014 #endif//CPPL_DEBUG
00015
00016 M =0;
00017 N =0;
00018 KL =0;
00019 KU =0;
00020 delete [] Array;
00021 Array =NULL;
00022 delete [] Darray;
00023 Darray =NULL;
00024 }
00025
00026
00027
00029 inline void zgbmatrix::zero()
00030 {
00031 #ifdef CPPL_VERBOSE
00032 std::cerr << "# [MARK] zgbmatrix::zero()"
00033 << std::endl;
00034 #endif//CPPL_VERBOSE
00035
00036 for(long i=0; i<(KL+KU+1)*N; i++){ Array[i] =std::complex<double>(0.0,0.0); }
00037 }
00038
00039
00041 inline void zgbmatrix::identity()
00042 {
00043 #ifdef CPPL_VERBOSE
00044 std::cerr << "# [MARK] zgbmatrix::identity()"
00045 << std::endl;
00046 #endif//CPPL_VERBOSE
00047
00048 #ifdef CPPL_DEBUG
00049 if(M!=N){
00050 std::cerr << "[ERROR] zgbmatrix::identity()" << std::endl
00051 << "Only square matrix can be a identity matrix." << std::endl
00052 << "The matrix size was " << M << "x" << N << "." << std::endl;
00053 exit(1);
00054 }
00055 #endif//CPPL_DEBUG
00056
00057 for(long i=0; i<(KL+KU+1)*N; i++){ Array[i] =std::complex<double>(0.0,0.0); }
00058 for(long i=0; i<M; i++){ operator()(i,i) =std::complex<double>(1.0,0.0); }
00059 }
00060
00061
00063 inline void zgbmatrix::chsign()
00064 {
00065 #ifdef CPPL_VERBOSE
00066 std::cerr << "# [MARK] zgbmatrix::chsign()"
00067 << std::endl;
00068 #endif//CPPL_VERBOSE
00069
00070 for(long i=0; i<(KL+KU+1)*N; i++){ Array[i] =-Array[i]; }
00071 }
00072
00074 inline void zgbmatrix::copy(const zgbmatrix& mat)
00075 {
00076 #ifdef CPPL_VERBOSE
00077 std::cerr << "# [MARK] zgbmatrix::copy(const zgbmatrix&)"
00078 << std::endl;
00079 #endif//CPPL_VERBOSE
00080
00081 #ifdef CPPL_DEBUG
00082 std::cerr << "# [NOTE] zgbmatrix::copy(const zgbmatrix&) "
00083 << "A zgbmatrix at " << Array << " is going to be deleted. ";
00084 #endif//CPPL_DEBUG
00085
00086 M =mat.M;
00087 N =mat.N;
00088 KL =mat.KL;
00089 KU =mat.KU;
00090 delete [] Array;
00091 Array =new std::complex<double>[(mat.KL+mat.KU+1)*mat.N];
00092 delete [] Darray;
00093 Darray =new std::complex<double>*[N];
00094 for(int i=0; i<N; i++){ Darray[i] =&Array[i*(KL+KU+1)]; }
00095
00096 zcopy_((mat.KL+mat.KU+1)*mat.N, mat.Array, 1, Array, 1);
00097
00098 #ifdef CPPL_DEBUG
00099 std::cerr << "Then, a COPY of a zgbmatrix has been cleated at "
00100 << Array << "." << std::endl;
00101 #endif//CPPL_DEBUG
00102 }
00103
00104
00107 inline void zgbmatrix::shallow_copy(const _zgbmatrix& mat)
00108 {
00109 #ifdef CPPL_VERBOSE
00110 std::cerr << "# [MARK] zgbmatrix::shallow_copy(const _zgbmatrix&)"
00111 << std::endl;
00112 #endif//CPPL_VERBOSE
00113
00114 #ifdef CPPL_DEBUG
00115 std::cerr << "# [NOTE] zgbmatrix::shallow_copy(const zgbmatrix&) "
00116 << "A zgbmatrix at " << Array << " is going to be deleted "
00117 << "and point at " << mat.Array << " instead." << std::endl;
00118 #endif//CPPL_DEBUG
00119
00120 M =mat.M;
00121 N =mat.N;
00122 KL =mat.KL;
00123 KU =mat.KU;
00124 delete [] Array;
00125 Array =mat.Array;
00126 delete [] Darray;
00127 Darray =mat.Darray;
00128 }
00129
00130
00132 inline void zgbmatrix::resize(const long& _m, const long& _n,
00133 const long& _kl, const long& _ku)
00134 {
00135 #ifdef CPPL_VERBOSE
00136 std::cerr << "# [MARK] zgbmatrix::resize(const long&, const long&, const long&, const long&)"
00137 << std::endl;
00138 #endif//CPPL_VERBOSE
00139
00140 #ifdef CPPL_DEBUG
00141 if( _m<0 || _n<0 || _kl<0 || _ku<0 || _m<_kl || _n<_ku ){
00142 std::cerr << "[ERROR] zgbmatrix::resize"
00143 << "(const long&, const long&, const long&, const long&)"
00144 << std::endl
00145 << "It is impossible to make a matrix you ordered. "
00146 << std::endl
00147 << "Your input was ("
00148 << _m << "," << _n << ","<< _ku << "," << _kl << ")."
00149 << std::endl;
00150 exit(1);
00151 }
00152 #endif//CPPL_DEBUG
00153
00154 M =_m;
00155 N =_n;
00156 KL =_kl;
00157 KU =_ku;
00158 delete [] Array;
00159 Array =new std::complex<double>[(KL+KU+1)*N];
00160 delete [] Darray;
00161 Darray =new std::complex<double>*[N];
00162 for(int i=0; i<N; i++){ Darray[i] =&Array[i*(KL+KU+1)]; }
00163 }
00164
00165
00167 inline void swap(zgbmatrix& A, zgbmatrix& B)
00168 {
00169 #ifdef CPPL_VERBOSE
00170 std::cerr << "# [MARK] swap(zgbmatrix&, zgbmatrix&)"
00171 << std::endl;
00172 #endif//CPPL_VERBOSE
00173
00174 long A_m(A.M), A_n(A.N), A_kl(A.KL), A_ku(A.KU);
00175 std::complex<double>* A_array(A.Array);
00176 std::complex<double>** A_darray = A.Darray;
00177 A.M=B.M; A.N=B.N; A.KL=B.KL; A.KU=B.KU; A.Array=B.Array; A.Darray=B.Darray;
00178 B.M=A_m; B.N=A_n; B.KL=A_kl; B.KU=A_ku; B.Array=A_array; B.Darray=A_darray;
00179 }
00180
00181
00183 inline _zgbmatrix _(zgbmatrix& mat)
00184 {
00185 #ifdef CPPL_VERBOSE
00186 std::cerr << "# [MARK] _(zgbmatrix&)"
00187 << std::endl;
00188 #endif//CPPL_VERBOSE
00189
00190 _zgbmatrix newmat;
00191
00192 newmat.M =mat.M;
00193 newmat.N =mat.N;
00194 newmat.KL =mat.KL;
00195 newmat.KU =mat.KU;
00196 newmat.Array =mat.Array;
00197 newmat.Darray =mat.Darray;
00198
00199 mat.M =0;
00200 mat.N =0;
00201 mat.KL =0;
00202 mat.KU =0;
00203 mat.Array =NULL;
00204 mat.Darray =NULL;
00205
00206 return newmat;
00207 }