VERB_code_2.3
_dsymatrix-io.hpp
1 //=============================================================================
3 inline double& _dsymatrix::operator()(const long& i, const long& j) const
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] _dsymatrix::operator()(const long&, const long&) const"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  if( i<0 || j<0 || N<=i || N<=j ){
12  std::cerr << "[ERROR] _dsymatrix::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  if( i >= j ){
21  //return Array[i+N*j];
22  return Darray[j][i];
23  } else {
24  //return Array[j+N*i];
25  return Darray[i][j];
26  }
27 }
28 
32 
33 //=============================================================================
34 inline std::ostream& operator<<(std::ostream& s, const _dsymatrix& mat)
35 {
36 #ifdef CPPL_VERBOSE
37  std::cerr << "# [MARK] operator<<(std::ostream&, const _dsymatrix&)"
38  << std::endl;
39 #endif//CPPL_VERBOSE
40 
41  for(long i=0; i<mat.N; i++){
42  for(long j=0; j<mat.N; j++){
43  if( i >= j ){
44  s << " " << mat(i,j) << " ";
45  } else {
46  s << "{" << mat(i,j) << "} ";
47  }
48  }
49  s << std::endl;
50  }
51 
52  mat.destroy();
53  return s;
54 }
55 
59 
60 //=============================================================================
61 inline void _dsymatrix::write(const char* filename) const
62 {
63 #ifdef CPPL_VERBOSE
64  std::cerr << "# [MARK] _dsymatrix::write(const char*) const"
65  << std::endl;
66 #endif//CPPL_VERBOSE
67 
68  std::ofstream s(filename, std::ios::trunc);
69 
70  s << "dsymatrix" << " " << N << std::endl;
71  for(long i=0; i<N; i++){
72  for(long j=0; j<=i; j++ ){
73  s << operator()(i,j) << " ";
74  }
75  s << std::endl;
76  }
77 
78  s.close();
79  destroy();
80 }
void destroy() const
Definition: _dsymatrix-misc.hpp:3
friend _dgematrix i(const _dsymatrix &)
Definition: _dsymatrix-calc.hpp:21
double & operator()(const long &, const long &) const
Definition: _dsymatrix-io.hpp:3
long N
matrix column or row size
Definition: _dsymatrix.hpp:7
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Matrix Class
Definition: _dsymatrix.hpp:3
double ** Darray
array of pointers of column head addresses
Definition: _dsymatrix.hpp:9