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