ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmpdif8.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 #include <fvar.hpp>
12 
13 #ifdef __TURBOC__
14  #pragma hdrstop
15  #include <iostream.h>
16 #endif
17 
18 #ifdef __ZTC__
19  #include <iostream.hpp>
20 #endif
21 
22 #include <string.h>
23 
28 void save_double_derivative(const double x, const prevariable_position& _pos)
29 {
31  // adds the derivative value in a double to a prevariables' guts
32  pos.xval()+=x;
33 }
34 
40 {
42 }
44 {
45  constexpr size_t wsize = sizeof(double_and_int*);
46 
47  double_and_int* tmp;
48  fread(&tmp, wsize);
49  return prevariable_position(tmp);
50 }
51 
57 {
59 }
61 {
62  constexpr size_t wsize = sizeof(double_and_int*);
63 
64  double_and_int* tmp = v.get_v();
65  fwrite(&tmp, wsize);
66 }
67 
73 {
75 }
77 {
78  //double_and_int * tmp=get_v();
79  //const unsigned wsize=sizeof(double_and_int*);
80  //gradient_structure::get_fp()->fwrite(&tmp,wsize);
81  double x=value(v);
82  //const unsigned dsize=sizeof(double);
83  fwrite(x);
84 }
85 
90 void save_double_value(const double x)
91 {
93 }
94 void DF_FILE::save_double_value(const double x)
95 {
96  //const unsigned wsize=sizeof(double);
97  fwrite(x);
98 }
99 
104 void save_int_value(int x)
105 {
107 }
109 {
110  //const unsigned wsize=sizeof(double);
111  fwrite(x);
112 }
113 
118 void save_pointer_value(void *ptr)
119 {
121 }
123 {
124  fwrite(ptr);
125 }
126 
132 {
134  double tmpout=pos.xval();
135  pos.xval()=0.0;
136  return tmpout;
137 }
138 
144 {
146 }
148 {
149  // Back up the stream and read the number of bytes written in the
150  // ``write function'' corresponding to this ``read function''
151  constexpr size_t wsize = sizeof(double_and_int*);
152 
153  double_and_int* tmp;
154  fread(&tmp, wsize);
155  double tmpout=tmp->x;
156  tmp->x=0.0;
157  return tmpout;
158 }
159 
165 {
167 }
169 {
170  // Back up the stream and read the number of bytes written in the
171  // ``write function'' corresponding to this ``read function''
172  constexpr size_t wsize = sizeof(double);
173  double tmpout = 0;
174  fread(&tmpout, wsize);
175  return tmpout;
176 }
177 
183 {
185 }
187 {
188  double tmpout = 0;
189  fread(tmpout);
190  return tmpout;
191 }
192 
198 {
200 }
202 {
203  int tmpout = 0;
204  fread(tmpout);
205  return tmpout;
206 }
207 
213 {
215 }
217 {
218  void* tmpout = NULL;
219  fread(tmpout);
220  return tmpout;
221 }
double restore_prevariable_derivative(const prevariable_position &_pos)
Description not yet available.
Definition: cmpdif8.cpp:131
Base class for dvariable.
Definition: fvar.hpp:1315
Description not yet available.
Definition: fvar.hpp:4440
double restore_prevariable_derivative()
Definition: cmpdif8.cpp:147
#define x
void save_prevariable_value(const prevariable &v)
Definition: cmpdif8.cpp:76
int restore_int_value(void)
Description not yet available.
Definition: cmpdif8.cpp:197
void save_prevariable_value() const
Description not yet available.
Definition: cmpdif8.cpp:72
void save_int_value(int x)
Definition: cmpdif8.cpp:108
double restore_double_value()
Description not yet available.
Definition: cmpdif8.cpp:182
void save_double_value(const double x)
Description not yet available.
Definition: cmpdif8.cpp:90
Holds the data for the prevariable class.
Definition: fvar.hpp:191
void save_pointer_value(void *ptr)
Description not yet available.
Definition: cmpdif8.cpp:118
double & xval()
Definition: fvar.hpp:4452
prevariable_position restore_prevariable_position()
Definition: cmpdif8.cpp:43
void save_prevariable_position(const prevariable &v)
Definition: cmpdif8.cpp:60
double restore_prevariable_value()
Description not yet available.
Definition: cmpdif8.cpp:164
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
double restore_double_value()
Definition: cmpdif8.cpp:186
int restore_int_value()
Definition: cmpdif8.cpp:201
static _THREAD DF_FILE * fp
size_t pos(const adstring &substr, const adstring &s)
Definition: string3.cpp:56
void * restore_pointer_value()
Definition: cmpdif8.cpp:216
void save_int_value(int x)
Description not yet available.
Definition: cmpdif8.cpp:104
void fwrite(const void *s, const size_t num_bytes)
Reads num_bytes from s and writes to buffer.
Definition: df_file.cpp:296
double restore_prevariable_value()
Definition: cmpdif8.cpp:168
void fread(void *s, const size_t num_bytes)
Reads num_bytes from buffer and copies to s.
Definition: df_file.cpp:270
void * restore_pointer_value()
Description not yet available.
Definition: cmpdif8.cpp:212
void save_pointer_value(void *ptr)
Definition: cmpdif8.cpp:122
void save_double_value(double x)
Definition: cmpdif8.cpp:94
prevariable_position restore_prevariable_position()
Description not yet available.
Definition: cmpdif8.cpp:39
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
double_and_int *& get_v()
Definition: fvar.hpp:1419
void save_double_derivative(const double x, const prevariable_position &_pos)
Description not yet available.
Definition: cmpdif8.cpp:28
void save_prevariable_position() const
Description not yet available.
Definition: cmpdif8.cpp:56
double x
&lt; value of the variable
Definition: fvar.hpp:195