ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_a23.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 void dvcv_sub(void);
13 
19 {
20  int min = v1.indexmin();
21  int max = v1.indexmax();
22 
23 #ifndef OPT_LIB
24  if (min != v2.indexmin() || max != v2.indexmax())
25  {
26  cerr << "Incompatible bounds in prevariable operator-(const dvar_vector&, const dvector&)\n";
27  ad_exit(1);
28  }
29 #endif
30 
31  //dvector cv1=value(v1);
32  //dvector cv2=value(v2);
33  dvar_vector vtmp(min, max);
34 
35  double_and_int* pvtmpi = vtmp.va + min;
36  double_and_int* pv1i = v1.va + min;
37  double* pv2i = v2.get_v() + min;
38  for (int i = min; i <= max; ++i)
39  {
40  pvtmpi->x = pv1i->x - *pv2i;
41 
42  ++pvtmpi;
43  ++pv1i;
44  ++pv2i;
45  }
46 
47  //dvar_vector vtmp=nograd_assign(tmp);
50  // The derivative list considerations
51  save_identifier_string("bbbb");
53  fp->save_dvar_vector_position(vtmp);
54  save_identifier_string("aaaa");
55  GRAD_STACK1->set_gradient_stack(dvcv_sub);
56 
57  return vtmp;
58 }
59 
64 void dvcv_sub(void)
65 {
67 
68  // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
74 
75  int min = dftmp.indexmin();
76  int max = dftmp.indexmax();
77  dvector dfv1(min, max);
78  double* pdfv1i = dfv1.get_v() + min;
79  double* pdftmpi = dftmp.get_v() + min;
80  for (int i = min; i <= max; ++i)
81  {
82  //vtmp.elem(i)=value(v1.elem(i))+v2.elem(i);
83  *pdfv1i = *pdftmpi;
84 
85  ++pdfv1i;
86  ++pdftmpi;
87  }
88  dfv1.save_dvector_derivatives(v1pos);
89  //ierr=fsetpos(gradient_structure::get_fp(),&filepos);
90 }
Description not yet available.
Definition: fvar.hpp:920
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
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
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
exitptr ad_exit
Definition: gradstrc.cpp:53
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
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.
int save_identifier_string(const char *)
Writes a gradient stack verification string.
Definition: cmpdif2.cpp:315
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
void dvcv_sub(void)
Description not yet available.
Definition: fvar_a23.cpp:64
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