6 std::cerr <<
"# [MARK] dgbmatrix::operator()(const long&, const long&)"
11 if( i<0 || j<0 || M<=i || N<=j || i-j>KL || j-i>KU ){
12 std::cerr <<
"[ERROR] dgbmatrix::operator()(long, long)" << std::endl
13 <<
"The required component is out of the matrix size."
15 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
21 return Darray[j][KU-j+
i];
29 std::cerr <<
"# [MARK] dgbmatrix::operator()(const long&, const long&) const"
34 if( i<0 || j<0 || M<=i || N<=j || i-j>KL || j-i>KU ){
35 std::cerr <<
"[ERROR] dgbmatrix::operator()(long, long)" << std::endl
36 <<
"The required component is out of the matrix size."
38 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
44 return Darray[j][KU-j+
i];
53 inline void dgbmatrix::set(
const long& i,
const long& j,
const double& v)
const
56 std::cerr <<
"# [MARK] dgbmatrix::set(const long&, const long&, const double&) const"
61 if( i<0 || j<0 || M<=i || N<=j || i-j>KL || j-i>KU ){
62 std::cerr <<
"[ERROR] dgbmatrix::set(long&, long&, double&)" << std::endl
63 <<
"The required component is out of the matrix size."
65 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
79 inline std::ostream& operator<<(std::ostream& s,
const dgbmatrix& mat)
82 std::cerr <<
"# [MARK] operator<<(std::ostream&, const dgbmatrix&)"
86 for(
long i=0; i<mat.M; i++){
87 for(
long j=0; j<mat.N; j++){
88 if( i-j>mat.KL || j-i>mat.KU ){ s <<
" x"; }
89 else{ s <<
" " << mat(i,j); }
102 inline void dgbmatrix::write(
const char *filename)
const
105 std::cerr <<
"# [MARK] dgbmatrix::write(const char*) const"
109 std::ofstream s(filename, std::ios::trunc);
111 s <<
"dgbmatrix" <<
" "
112 << M <<
" " << N <<
" " << KL <<
" " << KU << std::endl;
113 for(
long i=0;
i<M;
i++){
114 for(
long j=max(0,
i-KL); j<min(N,
i+KU+1); j++){
124 inline void dgbmatrix::read(
const char* filename)
127 std::cerr <<
"# [MARK] dgbmatrix::read(const char*)"
131 std::ifstream s( filename );
133 std::cerr <<
"[ERROR] dgbmatrix::read(const char*) " << std::endl
134 <<
"The file \"" << filename <<
"\" can not be opened."
141 if(
id !=
"dgbmatrix" ){
142 std::cerr <<
"[ERROR] dgbmatrix::read(const char*) " << std::endl
143 <<
"The type name of the file \"" << filename
144 <<
"\" is not dgbmatrix." << std::endl
145 <<
"Its type name was " <<
id <<
" ." << std::endl;
149 s >> M >> N >> KL >> KU;
151 for(
long i=0;
i<M;
i++){
152 for(
long j=max(0,
i-KL); j<min(N,
i+KU+1); j++){
157 std::cerr <<
"[ERROR] dgbmatrix::read(const char*) " << std::endl
158 <<
"There is something is wrong with the file \""
159 << filename <<
" ." << std::endl
160 <<
"Most likely, there is not enough data components, "
161 <<
"or a linefeed code or space code is missing "
162 <<
"at the end of the last line." << std::endl;
friend _dgematrix i(const dgbmatrix &)
Definition: dgbmatrix-calc.hpp:22
double & operator()(const long &, const long &)
Definition: dgbmatrix-io.hpp:3
void set(const long &, const long &, const double &) const
Definition: dgbmatrix-io.hpp:53
Real Double-precision General Band Matrix Class.
Definition: dgbmatrix.hpp:3
void resize(const long &, const long &, const long &, const long &)
Definition: dgbmatrix-misc.hpp:132