00001
00003 inline __zhecomplex _zhematrix::operator()(const long& i, const long& j) const
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] _zhematrix::operator()(const long&, const long&) const"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 if( i<0 || j<0 || N<=i || N<=j ){
00012 std::cerr << "[ERROR] _zhematrix::operator()(long, long) const"
00013 << std::endl
00014 << "The required component is out of the matrix size."
00015 << std::endl
00016 << "Your input was (" << i << "," << j << ")." << std::endl;
00017 exit(1);
00018 }
00019 #endif//CPPL_DEBUG
00020
00021
00022
00023 if(i>=j){ return __zhecomplex( Darray[j][i], i, j ); }
00024 else { return __zhecomplex( Darray[i][j], i, j ); }
00025 }
00026
00030
00031
00032 inline std::ostream& operator<<(std::ostream& s, const _zhematrix& mat)
00033 {
00034 #ifdef CPPL_VERBOSE
00035 std::cerr << "# [MARK] operator<<(std::ostream&, const _zhematrix&)"
00036 << std::endl;
00037 #endif//CPPL_VERBOSE
00038
00039 for(long i=0; i<mat.N; i++){
00040 for(long j=0; j<mat.N; j++){
00041 if(i>j){ s << " " << mat(i,j) << " "; }
00042 else if(i==j){ s << " " << std::real(mat(i,i)) << " "; }
00043 else{ s << "{" << std::conj(mat(j,i)) << "} "; }
00044 }
00045 s << std::endl;
00046
00047 #ifdef CPPL_DEBUG
00048 if(std::fabs(std::imag(mat(i,i))) > CPPL_EPS){
00049 std::cerr << "[WARNING] operator<<(std::ostream&, const _zhematrix&)"
00050 << std::endl
00051 << "The " << i << "th diagonal component of the zhematrix"
00052 << "is not a real number." << std::endl;
00053 }
00054 #endif//CPPL_DEBUG
00055 }
00056
00057 mat.destroy();
00058 return s;
00059 }
00060
00064
00065
00066 inline void _zhematrix::write(const char* filename) const
00067 {
00068 #ifdef CPPL_VERBOSE
00069 std::cerr << "# [MARK] _zhematrix::write(const char*) const"
00070 << std::endl;
00071 #endif//CPPL_VERBOSE
00072
00073 std::ofstream s(filename, std::ios::trunc);
00074
00075 s << "zhematrix" << " " << N << std::endl;
00076 for(long i=0; i<N; i++){
00077 for(long j=0; j<=i; j++ ){
00078 s << operator()(i,j) << " ";
00079 }
00080 s << std::endl;
00081
00082 #ifdef CPPL_DEBUG
00083 if(std::fabs(std::imag(operator()(i,i))) > CPPL_EPS){
00084 std::cerr << "[WARNING] _zhematrix::write(const char*)" << std::endl
00085 << "The " << i << "th diagonal component of the zhematrix"
00086 << "is not a real number." << std::endl;
00087 }
00088 #endif//CPPL_DEBUG
00089 }
00090
00091 s.close();
00092 destroy();
00093 }