My Project
_zgematrix-io.hpp
1 //=============================================================================
3 inline std::complex<double>& _zgematrix::operator()(const long& i, const long& j) const
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] _zgematrix::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 ){
12  std::cerr << "[ERROR] _zgematrix::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[i+M*j];
21  return Darray[j][i];
22 }
23 
27 
28 //=============================================================================
29 inline std::ostream& operator<<(std::ostream& s, const _zgematrix& mat)
30 {
31 #ifdef CPPL_VERBOSE
32  std::cerr << "# [MARK] operator<<(std::ostream&, const _zgematrix&)"
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  s << " " << mat(i,j);
39  }
40  s << std::endl;
41  }
42 
43  mat.destroy();
44  return s;
45 }
46 
50 
51 //=============================================================================
52 inline void _zgematrix::write(const char *filename) const
53 {
54 #ifdef CPPL_VERBOSE
55  std::cerr << "# [MARK] _zgematrix::write(const char*) const"
56  << std::endl;
57 #endif//CPPL_VERBOSE
58 
59  std::ofstream s(filename, std::ios::trunc);
60 
61  s << "zgematrix" << " " << M << " " << N << std::endl;
62  for(long i=0; i<M; i++){
63  for(long j=0; j<N; j++){
64  s << operator()(i,j) << " ";
65  }
66  s << std::endl;
67  }
68 
69  s.close();
70  destroy();
71 }
std::complex< double > & operator()(const long &, const long &) const
Definition: _zgematrix-io.hpp:3
long N
matrix column size
Definition: _zgematrix.hpp:8
friend _zgematrix i(const _zgematrix &)
Definition: _zgematrix-calc.hpp:24
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
void destroy() const
Definition: _zgematrix-misc.hpp:3
std::complex< double > ** Darray
array of pointers of column head addresses
Definition: _zgematrix.hpp:10
long M
matrix row size
Definition: _zgematrix.hpp:7