Go to the documentation of this file.00001
00002
00003 inline double& _dgbmatrix::operator()(const long& i, const long& j) const
00004 {VERBOSE_REPORT;
00005 #ifdef CPPL_DEBUG
00006 if( i<0 || j<0 || m<=i || n<=j || i-j>kl || j-i>ku ){
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
00015 return darray[j][ku-j+i];
00016 }
00017
00018
00019
00020
00021
00022
00023 inline std::ostream& operator<<(std::ostream& s, const _dgbmatrix& mat)
00024 {VERBOSE_REPORT;
00025 for(long i=0; i<mat.m; i++){
00026 for(long j=0; j<mat.n; j++){
00027 if( i-j>mat.kl || j-i>mat.ku ){ s << " x"; }
00028 else{ s << " " << mat(i,j); }
00029 }
00030 s << std::endl;
00031 }
00032
00033 mat.destroy();
00034 return s;
00035 }
00036
00037
00038
00039
00040
00041
00042 inline void _dgbmatrix::write(const char *filename) const
00043 {VERBOSE_REPORT;
00044 std::ofstream ofs(filename, std::ios::trunc);
00045 ofs.setf(std::cout.flags());
00046 ofs.precision(std::cout.precision());
00047 ofs.width(std::cout.width());
00048 ofs.fill(std::cout.fill());
00049
00050 ofs << "#dgbmatrix" << " " << m << " " << n << " " << kl << " " << ku << std::endl;
00051 for(long i=0; i<m; i++){
00052 for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
00053 ofs << operator()(i,j) << " ";
00054 }
00055 ofs << std::endl;
00056 }
00057
00058 ofs.close();
00059 destroy();
00060 }