ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_a48.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  void DF_cdble_dv_diveq(void);
14 
20  {
23  save_identifier_string("wctf");
24  double xinv = 1.0 / x;
25  int min = index_min;
26  int max = index_max;
27  double_and_int* pva = va + min;
28  for (int i = min; i <= max; ++i)
29  {
30  pva->x *=xinv;
31  ++pva;
32  }
34  fp->save_dvar_vector_position(*this);
35  fp->save_double_value(x);
36  save_identifier_string("cmtu");
39  return(*this);
40  }
41 
46  void DF_cdble_dv_diveq(void)
47  {
49 
51  double x=fp->restore_double_value();
55  double xinv=1./x;
56  int max = dfthis.indexmax();
57  int min = dfthis.indexmin();
58  double* pdfthis = dfthis.get_v() + max;
59  for (int i = max; i >= min; --i)
60  {
61  // elem_value(i)=elem_value(i)/x;
62  //dfthis(i)*=xinv;
63  *pdfthis *= xinv;
64  --pdfthis;
65  }
66  dfthis.save_dvector_derivatives(this_pos);
67  }
68 
69 
70  void DF_vdble_dv_diveq(void);
71 
77  {
81 
82  double xinv = 1.0 / value(x);
83  int min = index_min;
84  int max = index_max;
85  double_and_int* pva = va + min;
86  for (int i = min; i <= max; ++i)
87  {
88  //elem_value(i)=elem_value(i)*xinv;
89  pva->x *= xinv;
90  ++pva;
91  }
92  save_identifier_string("wctg");
93  fp->save_dvar_vector_value(*this);
94  fp->save_dvar_vector_position(*this);
97  save_identifier_string("cmtu");
100  return(*this);
101  }
102 
107  void DF_vdble_dv_diveq(void)
108  {
110 
111  verify_identifier_string("cmtu");
113  double dfx=restore_prevariable_derivative(x_pos);
114  double x=fp->restore_prevariable_value();
116  dvector tmp=restore_dvar_vector_value(this_pos);
117  dvector dfthis=restore_dvar_vector_derivatives(this_pos);
118  verify_identifier_string("wctg");
119  double tmp1=0.0;
120  double xinv=1.0/x;
121  int max = dfthis.indexmax();
122  int min = dfthis.indexmin();
123  double* pdfthis = dfthis.get_v() + max;
124  double* ptmp = tmp.get_v() + max;
125  for (int i = max; i >= min; --i)
126  {
127  // elem_value(i)=elem_value(i)/x;
128  //tmp1+=dfthis(i)*tmp(i);
129  tmp1 += *pdfthis * *ptmp;
130  --pdfthis;
131  --ptmp;
132  }
133  tmp1*=-xinv;
134 
135  pdfthis = dfthis.get_v() + max;
136  for (int i = max; i >= min; --i)
137  {
138  // elem_value(i)=elem_value(i)/x;
139  *pdfthis *= xinv;
140  --pdfthis;
141  }
142  dfthis.save_dvector_derivatives(this_pos);
143  save_double_derivative(dfx+tmp1,x_pos);
144  }
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
dvar_vector & operator/=(const prevariable &d)
Description not yet available.
Definition: fvar_a48.cpp:76
void DF_cdble_dv_diveq(void)
Description not yet available.
Definition: fvar_a48.cpp:46
#define x
void save_prevariable_value(const prevariable &v)
Definition: cmpdif8.cpp:76
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
friend dvector value(const dvar_vector &v1)
Description not yet available.
Definition: fvar_ar3.cpp:43
void save_dvector_derivatives(const dvar_vector_position &pos) const
Puts the derivative values in a dvector into a dvar_vector&#39;s guts.
Definition: cmpdif5.cpp:212
Description not yet available.
Definition: fvar.hpp:4814
ADMB variable vector.
Definition: fvar.hpp:2172
void verify_identifier_string(const char *)
Verifies gradient stack string.
Definition: cmpdif3.cpp:149
Holds the data for the prevariable class.
Definition: fvar.hpp:191
void set_gradient_stack(void(*func)(void), double *dep_addr, double *ind_addr1=NULL, double mult1=0, double *ind_addr2=NULL, double mult2=0)
Description not yet available.
Definition: fvar.hpp:1045
void DF_vdble_dv_diveq(void)
Description not yet available.
Definition: fvar_a48.cpp:107
prevariable_position restore_prevariable_position()
Definition: cmpdif8.cpp:43
void save_prevariable_position(const prevariable &v)
Definition: cmpdif8.cpp:60
void save_dvar_vector_value(const dvar_vector &v)
Definition: cmpdif4.cpp:106
dvar_vector_position restore_dvar_vector_position()
Definition: cmpdif4.cpp:69
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
#define min(a, b)
Definition: cbivnorm.cpp:188
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
double restore_double_value()
Definition: cmpdif8.cpp:186
static _THREAD gradient_structure * _instance
int save_identifier_string(const char *)
Writes a gradient stack verification string.
Definition: cmpdif2.cpp:315
dvector restore_dvar_vector_value(const dvar_vector_position &tmp)
Restores the size, address, and value information for a dvar_vector.
Definition: cmpdif4.cpp:227
void save_dvar_vector_position(const dvar_vector &v)
Definition: cmpdif3.cpp:214
static _THREAD DF_FILE * fp
int index_min
Definition: fvar.hpp:2176
Stores the adjoint gradient data that will be processed by gradcalc.
dvector restore_dvar_vector_derivatives(const dvar_vector_position &tmp)
Description not yet available.
Definition: cmpdif5.cpp:150
double restore_prevariable_value()
Definition: cmpdif8.cpp:168
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
double_and_int * va
Definition: fvar.hpp:2175
void save_double_value(double x)
Definition: cmpdif8.cpp:94
void save_double_derivative(const double x, const prevariable_position &_pos)
Description not yet available.
Definition: cmpdif8.cpp:28
static _THREAD grad_stack * GRAD_STACK1
#define max(a, b)
Definition: cbivnorm.cpp:189
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
double *& get_v(void)
Definition: dvector.h:148
double x
&lt; value of the variable
Definition: fvar.hpp:195
int index_max
Definition: fvar.hpp:2177