VERB_code_2.3
_zgbmatrix-io.hpp
1 //=============================================================================
3 inline std::complex<double>& _zgbmatrix::operator()(const long& i, const long& j) const
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] _zgbmatrix::operator()(const long&, const long&) const"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  if( i<0 || j<0 || M<=i || N<=j || i-j>KL || j-i>KU ){
12  std::cerr << "[ERROR] _zgbmatrix::operator()(long, long)" << std::endl
13  << "The required component is out of the matrix size."
14  << std::endl
15  << "Your input was (" << i << "," << j << ")." << std::endl;
16  exit(1);
17  }
18 #endif//CPPL_DEBUG
19 
20  //return Array[KU+i+(KL+KU)*j];
21  return Darray[j][KU-j+i];
22 }
23 
27 
28 //=============================================================================
29 inline std::ostream& operator<<(std::ostream& s, const _zgbmatrix& mat)
30 {
31 #ifdef CPPL_VERBOSE
32  std::cerr << "# [MARK] operator<<(std::ostream&, const _zgbmatrix&)"
33  << std::endl;
34 #endif//CPPL_VERBOSE
35 
36  for(long i=0; i<mat.M; i++){
37  for(long j=0; j<mat.N; j++){
38  if( i-j>mat.KL || j-i>mat.KU ){ s << " x"; }
39  else{ s << " " << mat(i,j); }
40  }
41  s << std::endl;
42  }
43 
44  mat.destroy();
45  return s;
46 }
47 
51 
52 //=============================================================================
53 inline void _zgbmatrix::write(const char* filename) const
54 {
55 #ifdef CPPL_VERBOSE
56  std::cerr << "# [MARK] _zgbmatrix::write(const char*) const"
57  << std::endl;
58 #endif//CPPL_VERBOSE
59 
60  std::ofstream s(filename, std::ios::trunc);
61 
62  s << "zgbmatrix" << " "
63  << M << " " << N << " " << KL << " " << KU << std::endl;
64  for(long i=0; i<M; i++){
65  for(long j=max(0,i-KL); j<min(N,i+KU+1); j++){
66  s << operator()(i,j) << " ";
67  }
68  s << std::endl;
69  }
70 
71  s.close();
72  destroy();
73 }
std::complex< double > & operator()(const long &, const long &) const
Definition: _zgbmatrix-io.hpp:3
double max(double v1, double v2)
Return maximum.
Definition: variousFunctions.cpp:355
long N
matrix column size
Definition: _zgbmatrix.hpp:8
void destroy() const
Definition: _zgbmatrix-misc.hpp:3
long KU
upper band width
Definition: _zgbmatrix.hpp:10
long M
matrix row size
Definition: _zgbmatrix.hpp:7
(DO NOT USE) Smart-temporary Complex Double-precision General Band Matrix Class
Definition: _zgbmatrix.hpp:3
std::complex< double > ** Darray
array of pointers of column head addresses
Definition: _zgbmatrix.hpp:12
long KL
lower band width
Definition: _zgbmatrix.hpp:9
friend _zgematrix i(const _zgbmatrix &)
Definition: _zgbmatrix-calc.hpp:23