ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dvect_io.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 // file: dvect_io.cpp
12 
13 // i/o ooperations for class dvector
14 #include "fvar.hpp"
15 
16 #ifdef __TURBOC__
17  #pragma hdrstop
18  #include <iostream.h>
19  #include <iomanip.h>
20  #include <fstream.h>
21  #define __USE_IOSTREAM__
22 #endif
23 
24 #ifdef __ZTC__
25  #include <iostream.hpp>
26  #include <iomanip.hpp>
27  #include <fstream.hpp>
28  #define __USE_IOSTREAM__
29 #endif
30 
31 #include <string.h>
32 
37 ostream& operator<<(const ostream& _ostr,const dvector& z)
38 {
39  ostream& ostr=(ostream&) _ostr;
40  z.write_on(ostr);
41 
42  return ostr;
43 }
44 
49 void dvector::write_on(const ostream& _s) const
50 {
51  ostream& s=(ostream&) _s;
52 #ifdef __USE_IOSTREAM__
53  using std::streamsize;
54  streamsize new_w = s.width();
55  streamsize new_p = s.precision();
56 #if !defined(__cplusplus)
57  long new_form = s.flags();
58 #else
59  ios::fmtflags new_form = s.flags();
60 #endif
61  char new_fill = s.fill();
62 #endif
63  for (int i=indexmin(); i <= indexmax(); i++)
64  {
65  #ifdef __USE_IOSTREAM__
66  s.width(0);
67  s << " ";
68  s.width(new_w);
69  s.precision(new_p);
70  s.flags(new_form);
71  s.fill(new_fill);
72  s << (*this)[i];
73  #else
74  s << " " << (*this)[i];
75  #endif
76  }
77 }
78 
83 istream& operator>>(const istream& _istr, const dvector& _z)
84 {
85  dvector& z = (dvector&)_z;
86  istream& istr= (istream&) _istr;
87  z.read_from(istr);
88 
89  return istr;
90 }
91 
96 void dvector::read_from(const istream& _s)
97 {
98  istream& s= (istream&) _s;
99  for (int i=indexmin(); i <= indexmax(); i++)
100  {
101  s >> elem(i);
102  }
103 }
double & elem(int i)
Definition: dvector.h:152
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void write_on(const ostream &) const
Description not yet available.
Definition: dvect_io.cpp:49
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
istream & operator>>(const istream &input, const d3_array &arr3)
Read values from input stream into arr3.
Definition: d3_io.cpp:60
ostream & operator<<(const ostream &_s, preshowpoint p)
Description not yet available.
Definition: admanip.cpp:48
void read_from(const uistream &)
Description not yet available.
Definition: dvec_io2.cpp:77