00001
00003 inline double& _dgematrix::operator()(const long& i, const long& j) const
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] _dgematrix::operator()(const long&, const long&) const"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 if( i<0 || j<0 || M<=i || N<=j ){
00012 std::cerr << "[ERROR] _dgematrix::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
00021 return Darray[j][i];
00022 }
00023
00027
00028
00029 inline std::ostream& operator<<(std::ostream& s, const _dgematrix& mat)
00030 {
00031 #ifdef CPPL_VERBOSE
00032 std::cerr << "# [MARK] operator<<(std::ostream&, const _dgematrix&)"
00033 << std::endl;
00034 #endif//CPPL_VERBOSE
00035
00036 for(long i=0; i<mat.M; i++){
00037 for(long j=0; j<mat.N; j++){
00038 s << " " << mat(i,j);
00039 }
00040 s << std::endl;
00041 }
00042
00043 mat.destroy();
00044 return s;
00045 }
00046
00050
00051
00052 inline void _dgematrix::write(const char *filename) const
00053 {
00054 #ifdef CPPL_VERBOSE
00055 std::cerr << "# [MARK] _dgematrix::write(const char*) const"
00056 << std::endl;
00057 #endif//CPPL_VERBOSE
00058
00059 std::ofstream s(filename, std::ios::trunc);
00060
00061 s << "dgematrix" << " " << M << " " << N << std::endl;
00062 for(long i=0; i<M; i++){
00063 for(long j=0; j<N; j++ ){
00064 s << operator()(i,j) << " ";
00065 }
00066 s << std::endl;
00067 }
00068
00069 s.close();
00070 destroy();
00071 }