00001
00003 inline double& _dsymatrix::operator()(const long& i, const long& j) const
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] _dsymatrix::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] _dsymatrix::operator()(long, long)" << std::endl
00013 << "The required component is out of the matrix size."
00014 << std::endl
00015 << "Your input was (" << i << "," << j << ")." << std::endl;
00016 exit(1);
00017 }
00018 #endif//CPPL_DEBUG
00019
00020 if( i >= j ){
00021
00022 return Darray[j][i];
00023 } else {
00024
00025 return Darray[i][j];
00026 }
00027 }
00028
00032
00033
00034 inline std::ostream& operator<<(std::ostream& s, const _dsymatrix& mat)
00035 {
00036 #ifdef CPPL_VERBOSE
00037 std::cerr << "# [MARK] operator<<(std::ostream&, const _dsymatrix&)"
00038 << std::endl;
00039 #endif//CPPL_VERBOSE
00040
00041 for(long i=0; i<mat.N; i++){
00042 for(long j=0; j<mat.N; j++){
00043 if( i >= j ){
00044 s << " " << mat(i,j) << " ";
00045 } else {
00046 s << "{" << mat(i,j) << "} ";
00047 }
00048 }
00049 s << std::endl;
00050 }
00051
00052 mat.destroy();
00053 return s;
00054 }
00055
00059
00060
00061 inline void _dsymatrix::write(const char* filename) const
00062 {
00063 #ifdef CPPL_VERBOSE
00064 std::cerr << "# [MARK] _dsymatrix::write(const char*) const"
00065 << std::endl;
00066 #endif//CPPL_VERBOSE
00067
00068 std::ofstream s(filename, std::ios::trunc);
00069
00070 s << "dsymatrix" << " " << N << std::endl;
00071 for(long i=0; i<N; i++){
00072 for(long j=0; j<=i; j++ ){
00073 s << operator()(i,j) << " ";
00074 }
00075 s << std::endl;
00076 }
00077
00078 s.close();
00079 destroy();
00080 }