CPPLapack
 All Classes Files Functions Variables Friends Pages
_drovector-io.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! operator() for const object */
3 inline double& _drovector::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 _drovector& vec)
23 {CPPL_VERBOSE_REPORT;
24  for(CPPL_INT i=0; i<vec.l; i++){ s << " " << vec.array[i]; }
25  s << std::endl;
26 
27  vec.destroy();
28  return s;
29 }
30 
31 ///////////////////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 //=============================================================================
36 inline void _drovector::write(const char* filename) const
37 {CPPL_VERBOSE_REPORT;
38  std::ofstream ofs(filename, std::ios::trunc);
39  ofs.setf(std::cout.flags());
40  ofs.precision(std::cout.precision());
41  ofs.width(std::cout.width());
42  ofs.fill(std::cout.fill());
43 
44  ofs << "#drovector" << " " << l << std::endl;
45  for(CPPL_INT i=0; i<l; i++){
46  ofs << operator()(i) << " ";
47  }
48  ofs << std::endl;
49 
50  ofs.close();
51  destroy();
52 }
void write(const char *) const
std::ostream & operator<<(std::ostream &s, const _drovector &vec)
double * array
1D array to store vector data
Definition: _drovector.hpp:11
CPPL_INT l
vector size
Definition: _drovector.hpp:9
_dgematrix i(const _dgbmatrix &mat)
void destroy() const
(DO NOT USE) Smart-temporary Real Double-precision Row Vector Class
Definition: _drovector.hpp:3
double & operator()(const CPPL_INT &) const