ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
dmat_io3.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 // file: dmat_io.cpp
00012 
00013 // i/o operations for class dmatrix
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 #ifdef __USE_IOSTREAM__
00034 
00039 uistream& operator>>(const uistream& istr, const dmatrix& _z)
00040 {
00041   ADUNCONST(dmatrix,z)
00042   z.read_from(istr);
00043 
00044   return (uistream&)istr;
00045 }
00046 
00051 void dmatrix::read_from(const uistream& s)
00052 {
00053   int n = rowmin() + rowsize() - 1;
00054 
00055   for (int i=rowmin(); i <= n; i++)
00056   {
00057      s >> (*this)[i];
00058      if (!s.good())
00059      {
00060        cerr << " Error in dmatrix read\n";
00061        ad_exit(1);
00062      }
00063   }
00064 }
00065 
00070 uostream& operator<<(const uostream& ostr, const dmatrix& z)
00071 {
00072   z.write_on(ostr);
00073 
00074   return (uostream&) ostr;
00075 }
00076 
00081 void dmatrix::write_on(const uostream& s) const
00082 {
00083   for (int i=rowmin(); i <= rowmax(); i++)
00084   {
00085      s << (*this)[i];
00086      if (!s.good())
00087      {
00088        cerr << " Error in dmatrix write\n";
00089        ad_exit(1);
00090      }
00091   }
00092 }
00093 #endif