My Project
_drovector-io.hpp
1 //=============================================================================
3 inline double& _drovector::operator()(const long& i) const
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] _drovector::operator()(const long&) const"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10 #ifdef CPPL_DEBUG
11  if( i<0 || L<=i ){
12  std::cerr << "[ERROR] _drovector::operator()(const long&) const"
13  << std::endl
14  << "The required component is out of the vector size."
15  << std::endl
16  << "Your input was (" << i << ")." << std::endl;
17  exit(1);
18  }
19 #endif//CPPL_DEBUG
20 
21  return Array[i];
22 }
23 
27 
28 //=============================================================================
29 inline std::ostream& operator<<(std::ostream& s, const _drovector& vec)
30 {
31 #ifdef CPPL_VERBOSE
32  std::cerr << "# [MARK] operator<<(std::ostream&, const _drovector&)"
33  << std::endl;
34 #endif//CPPL_VERBOSE
35 
36  for(long i=0; i<vec.L; i++){ s << " " << vec.Array[i]; }
37  s << std::endl;
38 
39  vec.destroy();
40  return s;
41 }
42 
46 
47 //=============================================================================
48 inline void _drovector::write(const char* filename) const
49 {
50 #ifdef CPPL_VERBOSE
51  std::cerr << "# [MARK] _drovector::write(const char*) const"
52  << std::endl;
53 #endif//CPPL_VERBOSE
54 
55  std::ofstream s(filename, std::ios::trunc);
56 
57  s << "drovector" << " " << L << std::endl;
58  for(long i=0; i<L; i++){
59  s << operator()(i) << " ";
60  }
61  s << std::endl;
62 
63  s.close();
64  destroy();
65 }
double & operator()(const long &) const
Definition: _drovector-io.hpp:3
double * Array
1D Array to store vector data
Definition: _drovector.hpp:8
void destroy() const
Definition: _drovector-misc.hpp:3
(DO NOT USE) Smart-temporary Real Double-precision Row Vector Class
Definition: _drovector.hpp:3
long L
vector size
Definition: _drovector.hpp:7