ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvarb_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: fvara_io.cpp
12 
13 // i/o operations for class fvar_arry
14 
15 #include "fvar.hpp"
16 
17 #ifdef __TURBOC__
18  #pragma hdrstop
19  #include <iostream.h>
20  #include <iomanip.h>
21  #include <fstream.h>
22  #define __USE_IOSTREAM__
23 #endif
24 
25 #ifdef __ZTC__
26  #include <iostream.hpp>
27  #include <iomanip.hpp>
28  #include <fstream.hpp>
29  #define __USE_IOSTREAM__
30 #endif
31 
32 
33 #ifdef __USE_IOSTREAM__
34 
39 uistream& operator>>(const uistream& istr, const dvar_vector& _z)
40 {
42  if (allocated(z))
43  z.read_from(istr);
44  return (uistream&) istr;
45 }
46 
52 {
53  if (allocated(*this))
54  {
55  uistream& s = (uistream&) _s;
56  int n = indexmax() - indexmin() + 1;
57  double_and_int * p = va + indexmin();
58 
59  for (int i=1; i <= n; i++)
60  {
61  s >> (p++)->x;
62  }
63  }
64 }
65 
70 uostream& operator<<(const uostream& ostr, const dvar_vector& z)
71 {
72  if (allocated(z))
73  z.write_on(ostr);
74  return (uostream&) ostr;
75 }
76 
81 void dvar_vector::write_on(const uostream& _s) const
82 {
83  if (allocated(*this))
84  {
85  uostream& s = (uostream&) _s;
86  int n = indexmax() - indexmin() + 1;
87  double_and_int * p = va + indexmin();
88 
89  for (int i=1; i <= n; i++)
90  {
91  s << (p++)->x;
92  }
93  }
94 }
95 #endif
#define x
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_a59.cpp:13
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
ADMB variable vector.
Definition: fvar.hpp:2172
Holds the data for the prevariable class.
Definition: fvar.hpp:191
void write_on(const ostream &) const
Description not yet available.
Definition: fvara_io.cpp:48
Description not yet available.
Definition: fvar.hpp:3398
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int indexmin() const
Definition: fvar.hpp:2287
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
Description not yet available.
Definition: fvar.hpp:3516
double_and_int * va
Definition: fvar.hpp:2175
void read_from(const istream &)
Description not yet available.
Definition: fvara_io.cpp:94
int indexmax() const
Definition: fvar.hpp:2292