ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_a40.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_diff(void);
14 
19 dvar_vector operator-(const double x, const dvar_vector& t1)
20 {
23 
24  int min = t1.indexmin();
25  int max = t1.indexmax();
26  dvar_vector tmp(min, max);
27  //save_identifier_string("ecbb");
28  double_and_int* ptmpi = tmp.va + min;
29  double_and_int* pt1i = t1.va + min;
30  for (int i = min; i <= max; ++i)
31  {
32  ptmpi->x = x - pt1i->x;
33  ++ptmpi;
34  ++pt1i;
35  }
39  //save_identifier_string("druu");
42  return(tmp);
43 }
44 
49 void DF_cdble_dv_diff(void)
50 {
52 
53  //verify_identifier_string("druu");
57  int min = t1_pos.indexmin();
58  int max = t1_pos.indexmax();
59  dvector dft1(min, max);
60  //verify_identifier_string("ecbb");
61  //double xinv=1./x;
62  double* pdft1i = dft1.get_v() + max;
63  double* pdftmpi = dftmp.get_v() + max;
64  for (int i = max; i >= min; --i)
65  {
66  // tmp.elem_value(i)=t1.elem_value(i)-value(x);
67  //tmp.elem_value(i)=value(x)*t1.elem_value(i)/value(x);
68  *pdft1i = -(*pdftmpi);
69 
70  --pdft1i;
71  --pdftmpi;
72  }
73  dft1.save_dvector_derivatives(t1_pos);
74 }
75 
76 void DF_dv_minus(void);
77 
83 {
86 
87  int min = t1.indexmin();
88  int max = t1.indexmax();
89  dvar_vector tmp(min, max);
90  //save_identifier_string("vcbb");
91  const double_and_int* pt1i = t1.va + min;
92  double_and_int* ptmpi = tmp.va + min;
93  for (int i = min; i <= max; ++i)
94  {
95  ptmpi->x = -pt1i->x;
96 
97  ++ptmpi;
98  ++pt1i;
99  }
101  fp->save_dvar_vector_position(tmp);
103  //save_identifier_string("tduu");
106  return(tmp);
107 }
108 
113 void DF_dv_minus(void)
114 {
116 
117  //verify_identifier_string("tduu");
121  int min = t1_pos.indexmin();
122  int max = t1_pos.indexmax();
123  dvector dft1(min, max);
124  //verify_identifier_string("vcbb");
125  //double xinv=1./x;
126  double* pdft1i = dft1.get_v() + max;
127  double* pdftmpi = dftmp.get_v() + max;
128  for (int i = max; i >= min; --i)
129  {
130  // tmp.elem_value(i)=t1.elem_value(i)-value(x);
131  //tmp.elem_value(i)=value(x)*t1.elem_value(i)/value(x);
132  *pdft1i = -(*pdftmpi);
133  --pdft1i;
134  --pdftmpi;
135  }
136  dft1.save_dvector_derivatives(t1_pos);
137 }
d3_array operator-(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:152
#define x
Vector of double precision numbers.
Definition: dvector.h:50
void DF_dv_minus(void)
Description not yet available.
Definition: fvar_a40.cpp:113
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
int indexmin() const
Definition: fvar.hpp:4827
ADMB variable vector.
Definition: fvar.hpp:2172
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
int indexmax() const
Definition: fvar.hpp:4831
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
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
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
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
double_and_int * va
Definition: fvar.hpp:2175
static _THREAD grad_stack * GRAD_STACK1
#define max(a, b)
Definition: cbivnorm.cpp:189
void DF_cdble_dv_diff(void)
Description not yet available.
Definition: fvar_a40.cpp:49
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
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