ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat_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: dmat_io.cpp
12 
13 // i/o operations for class dmatrix
14 #include "fvar.hpp"
15 
16 #ifdef __TURBOC__
17  #pragma hdrstop
18  #include <iostream.h>
19  #include <iomanip.h>
20  #include <fstream.h>
21 #endif
22 
23 #ifdef __ZTC__
24  #include <iostream.hpp>
25  #include <iomanip.hpp>
26  #include <fstream.hpp>
27 #endif
28 
29 #include <string.h>
30 
35 ostream& operator<<(const ostream& _ostr, const dmatrix& z)
36 {
37  ostream& ostr = (ostream&) _ostr;
38  z.write_on(ostr);
39  return ostr;
40 }
41 
46 void dmatrix::write_on(const ostream& _s) const
47 {
48  using std::streamsize;
49 
50  ostream& s=(ostream&) _s;
51  streamsize new_w = s.width();
52  streamsize new_p = s.precision();
53 #if !defined(__cplusplus)
54  long new_form = s.flags();
55 #else
56  ios::fmtflags new_form = s.flags();
57 #endif
58  char new_fill = s.fill();
59 
60  for (int i=rowmin(); i <= rowmax(); i++)
61  {
62  s.width(new_w);
63  s.precision(new_p);
64  s.flags(new_form);
65  s.fill(new_fill);
66  s << (*this)[i];
67  if (i<rowmax())
68  {
69  s << endl;
70  }
71  }
72 }
73 
78 istream& operator>>(const istream& _istr, const dmatrix& _z)
79 {
80  dmatrix& z= (dmatrix&) _z;
81  istream& istr = (istream&) _istr;
82  z.read_from(istr);
83 
84  return istr;
85 }
86 
91 void dmatrix::read_from(const istream& s)
92 {
93  for (int i=rowmin();i <= rowmax();i++)
94  {
95  s >> (*this)[i];
96  }
97 }
98 
void write_on(const ostream &) const
Description not yet available.
Definition: dmat_io.cpp:46
prnstream & endl(prnstream &)
int rowmax() const
Definition: fvar.hpp:2929
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Description not yet available.
Definition: fvar.hpp:2819
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 istream &)
Description not yet available.
Definition: dmat_io.cpp:91
int rowmin() const
Definition: fvar.hpp:2925