CPPLapack
 All Classes Files Functions Variables Friends Pages
_dgematrix-io.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! operator() for object */
3 inline double& _dgematrix::operator()(const CPPL_INT& i, const CPPL_INT& j) const
4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if( i<0 || j<0 || m<=i || n<=j ){
7  ERROR_REPORT;
8  std::cerr << "The required component is out of the matrix size." << std::endl
9  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  //double val(array[i+m*j]);
15  return darray[j][i];
16 }
17 
18 ///////////////////////////////////////////////////////////////////////////////
19 ///////////////////////////////////////////////////////////////////////////////
20 ///////////////////////////////////////////////////////////////////////////////
21 
22 //=============================================================================
23 inline std::ostream& operator<<(std::ostream& s, const _dgematrix& mat)
24 {CPPL_VERBOSE_REPORT;
25  for(CPPL_INT i=0; i<mat.m; i++){
26  for(CPPL_INT j=0; j<mat.n; j++){
27  s << " " << mat(i,j);
28  }
29  s << std::endl;
30  }
31 
32  mat.destroy();
33  return s;
34 }
35 
36 ///////////////////////////////////////////////////////////////////////////////
37 ///////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
39 
40 //=============================================================================
41 inline void _dgematrix::write(const char *filename) const
42 {CPPL_VERBOSE_REPORT;
43  std::ofstream ofs(filename, std::ios::trunc);
44  ofs.setf(std::cout.flags());
45  ofs.precision(std::cout.precision());
46  ofs.width(std::cout.width());
47  ofs.fill(std::cout.fill());
48 
49  ofs << "#dgematrix" << " " << m << " " << n << std::endl;
50  for(CPPL_INT i=0; i<m; i++){
51  for(CPPL_INT j=0; j<n; j++ ){
52  ofs << operator()(i,j) << " ";
53  }
54  ofs << std::endl;
55  }
56 
57  ofs.close();
58  destroy();
59 }
double ** darray
array of pointers of column head addresses
Definition: _dgematrix.hpp:12
_dgematrix i(const _dgbmatrix &mat)
friend _dgematrix i(const _dgematrix &)
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
double & operator()(const CPPL_INT &, const CPPL_INT &) const
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
std::ostream & operator<<(std::ostream &s, const _dgematrix &mat)
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
void destroy() const
void write(const char *) const