Go to the documentation of this file.00001
00002
00003 inline zhecomplex _zhematrix::operator()(const long& i, const long& j) const
00004 {VERBOSE_REPORT;
00005 #ifdef CPPL_DEBUG
00006 if( i<0 || j<0 || n<=i || n<=j ){
00007 ERROR_REPORT;
00008 std::cerr << "The required component is out of the matrix size." << std::endl
00009 << "Your input was (" << i << "," << j << ")." << std::endl;
00010 exit(1);
00011 }
00012 #endif//CPPL_DEBUG
00013
00014 if(i>=j){ return zhecomplex(i,j, darray[j][i]); }
00015 else { return zhecomplex(i,j, darray[i][j]); }
00016 }
00017
00018
00019
00020
00021
00022
00023 inline std::ostream& operator<<(std::ostream& s, const _zhematrix& mat)
00024 {VERBOSE_REPORT;
00025 for(long i=0; i<mat.n; i++){
00026 for(long j=0; j<mat.n; j++){
00027 if(i>j){ s << " " << mat(i,j) << " "; }
00028 else if(i==j){ s << " " << std::real(mat(i,i)) << " "; }
00029 else{ s << "{" << std::conj(mat.darray[i][j]) << "} "; }
00030 }
00031 s << std::endl;
00032
00033 #ifdef CPPL_DEBUG
00034 if(std::fabs(std::imag(mat(i,i))) > DBL_MIN){
00035 WARNING_REPORT;
00036 std::cerr << "The " << i << "th diagonal component of the zhematrix is not a real number." << std::endl;
00037 }
00038 #endif//CPPL_DEBUG
00039 }
00040
00041 mat.destroy();
00042 return s;
00043 }
00044
00045
00046
00047
00048
00049
00050 inline void _zhematrix::write(const char* filename) const
00051 {VERBOSE_REPORT;
00052 std::ofstream ofs(filename, std::ios::trunc);
00053 ofs.setf(std::cout.flags());
00054 ofs.precision(std::cout.precision());
00055 ofs.width(std::cout.width());
00056 ofs.fill(std::cout.fill());
00057
00058 ofs << "#zhematrix" << " " << n << std::endl;
00059 for(long i=0; i<n; i++){
00060 for(long j=0; j<=i; j++ ){
00061 ofs << operator()(i,j) << " ";
00062 }
00063 ofs << std::endl;
00064
00065 #ifdef CPPL_DEBUG
00066 if(std::fabs(std::imag(operator()(i,i))) > DBL_MIN){
00067 WARNING_REPORT;
00068 std::cerr << "The " << i << "th diagonal component of the zhematrix is not a real number." << std::endl;
00069 }
00070 #endif//CPPL_DEBUG
00071 }
00072
00073 ofs.close();
00074 destroy();
00075 }