ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvarm_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: fvarm_io.cpp
12 
14 
15 #include "fvar.hpp"
16 
17 
18 #ifdef __TURBOC__
19  #pragma hdrstop
20  #include <iostream.h>
21  #include <iomanip.h>
22  #include <fstream.h>
23  #define __USE_IOSTREAM__
24 #endif
25 
26 #ifdef __ZTC__
27  #include <iostream.hpp>
28  #include <iomanip.hpp>
29  #include <fstream.hpp>
30  #define __USE_IOSTREAM__
31 #endif
32 
37 ostream& operator<<(const ostream& _ostr, const dvar_matrix& z)
38 {
39  ostream& ostr= (ostream&) _ostr;
40  z.write_on(ostr);
41 
42  return ostr;
43 }
44 
49 void dvar_matrix::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 
64  for (int i=rowmin(); i <= rowmax(); i++)
65  {
66  #ifdef __USE_IOSTREAM__
67  s.width(new_w);
68  s.precision(new_p);
69  s.flags(new_form);
70  s.fill(new_fill);
71  #endif
72  s << (*this)[i];
73  if(i<rowmax())
74  {
75  s << endl;
76  }
77  }
78 }
79 
84 istream& operator>>(const istream& _istr, const dvar_matrix& _z)
85 {
86  dvar_matrix& z = (dvar_matrix&)_z;
87  istream& istr= (istream&) _istr;
88  z.read_from(istr);
89 
90  return istr;
91 }
92 
97 void dvar_matrix::read_from(const istream& s)
98 {
99  int n = rowmax();
100  for (int i = rowmin(); i <= n; ++i)
101  {
102  s >> (*this)[i];
103  /*
104  if (!s.good())
105  {
106  cerr << " Error in dvar_matrix read\n";
107  ad_exit(1);
108  }
109  */
110  }
111 }
int rowmax(void) const
Definition: fvar.hpp:2564
void read_from(const istream &)
Read values to dvar_matrix from input istream s.
Definition: fvarm_io.cpp:97
prnstream & endl(prnstream &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int rowmin(void) const
Definition: fvar.hpp:2560
void write_on(const ostream &) const
Description not yet available.
Definition: fvarm_io.cpp:49
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
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480