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