ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_a50.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_dvmfexp(void);
14 
20 {
21  //dvector cv1=value(v1);
22  int mmin=v1.indexmin();
23  int mmax=v1.indexmax();
24  dvar_vector vtmp(mmin,mmax);
25 
26  double_and_int* pvtmpi = vtmp.va + mmin;
27  double_and_int* pv1i = v1.va + mmin;
28 
29  for (int i=mmin;i<=mmax;i++)
30  {
31  double v1i = pv1i->x;
32  if (v1i < 60.0)
33  {
34  pvtmpi->x = exp(v1i);
35  }
36  else
37  {
38  double exp60 = exp(60.0);
39  double x = v1i - 60.0;
40  pvtmpi->x = exp60 * (1.0 + 2.0 * x)/(1.0 + x);
41  }
42 
43  ++pvtmpi;
44  ++pv1i;
45  }
46 
48 
50  fp->save_dvar_vector_value(v1);
52  fp->save_dvar_vector_value(vtmp);
53  fp->save_dvar_vector_position(vtmp);
56  return vtmp;
57 }
58 
63 void DF_dvmfexp(void)
64 {
66 
67  // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
71  dvector vtmp=restore_dvar_vector_value(tmp_pos);
75  int min = dfvtmp.indexmin();
76  int max = dfvtmp.indexmax();
77  dvector dfv1(min, max);
78 
79  double* pdfv1i = dfv1.get_v() + min;
80  double* pdfvtmpi = dfvtmp.get_v() + min;
81  double* pvtmpi = vtmp.get_v() + min;
82  double* pv1i = v1.get_v() + min;
83  for (int i = min; i <= max; ++i)
84  {
85  //vtmp.elem(i)=mfexp(value(v1.elem(i))));
86  if (*pv1i < 60.0)
87  {
88  *pdfv1i = *pdfvtmpi * *pvtmpi;
89  }
90  else
91  {
92  double exp60 = exp(60.0);
93  double b = *pv1i - 60.0;
94  *pdfv1i = *pdfvtmpi * exp60 * std::pow(1.0 + b, -2.0);
95  }
96 
97  ++pdfv1i;
98  ++pdfvtmpi;
99  ++pvtmpi;
100  ++pv1i;
101  }
102  dfv1.save_dvector_derivatives(v1pos);
103  //ierr=fsetpos(gradient_structure::get_fp(),&filepos);
104 }
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void DF_dvmfexp(void)
Description not yet available.
Definition: fvar_a50.cpp:63
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
d3_array mfexp(const d3_array &m)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr7.cpp:10
void save_dvar_vector_value(const dvar_vector &v)
Definition: cmpdif4.cpp:106
dvar_vector_position restore_dvar_vector_position()
Definition: cmpdif4.cpp:69
#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.
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
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
int indexmin() const
Definition: fvar.hpp:2287
void save_dvar_vector_position(const dvar_vector &v)
Definition: cmpdif3.cpp:214
static _THREAD DF_FILE * fp
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_and_int * va
Definition: fvar.hpp:2175
static _THREAD grad_stack * GRAD_STACK1
#define max(a, b)
Definition: cbivnorm.cpp:189
double *& get_v(void)
Definition: dvector.h:148
int indexmax() const
Definition: fvar.hpp:2292
double x
&lt; value of the variable
Definition: fvar.hpp:195
d3_array pow(const d3_array &m, int e)
Description not yet available.
Definition: d3arr6.cpp:17