ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
dvec_io2.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dvec_io2.cpp 1112 2013-07-12 21:41:41Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 // file: dvect_io.cpp
00012 
00013 // i/o ooperations for class dvector
00014 #include "fvar.hpp"
00015 
00016 #ifdef __TURBOC__
00017   #pragma hdrstop
00018   #include <iostream.h>
00019   #include <iomanip.h>
00020   #include <fstream.h>
00021   #define __USE_IOSTREAM__
00022 #endif
00023 
00024 #ifdef __ZTC__
00025   #include <iostream.hpp>
00026   #include <iomanip.hpp>
00027   #include <fstream.hpp>
00028   #define __USE_IOSTREAM__
00029 #endif
00030 
00031 #include <string.h>
00032 
00033 
00034 #ifdef __USE_IOSTREAM__
00035 
00040 uistream& operator>>(const uistream& istr, const dvector& _z)
00041 {
00042   ADUNCONST(dvector,z)
00043   z.read_from(istr);
00044   return (uistream&)istr;
00045 }
00046 
00051 uostream& operator<<(const uostream& ostr,const dvector& z)
00052 {
00053   z.write_on(ostr);
00054 
00055   return (uostream&)ostr;
00056 }
00057 
00062 void dvector::write_on(const uostream& _s) const
00063 {
00064   ADUNCONST(uostream,s)
00065   int mmin = indexmin();
00066   int mmax = indexmax();
00067   for (int i=mmin;i<=mmax;i++)
00068   {
00069     s.write((char*)&((*this)[i]), sizeof(double) );
00070   }
00071 }
00072 
00077 void dvector::read_from(const uistream& _s)
00078 {
00079   ADUNCONST(uistream,s)
00080   int mmin = indexmin();
00081   int mmax = indexmax();
00082   for (int i=mmin;i<=mmax;i++)
00083   {
00084     s.read((char*)&((*this)[i]), sizeof(double) );
00085   }
00086 }
00087 #endif