ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_a21.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 cvdv_sub(void);
13 
19 {
20  int min = v1.indexmin();
21  int max = v1.indexmax();
22 #ifndef OPT_LIB
23  if (min != v2.indexmin() || max != v2.indexmax())
24  {
25  cerr << "Incompatible bounds in "
26  "prevariable operator-(const dvector& v1, const dvar_vector& v2)" << endl;
27  ad_exit(1);
28  }
29 #endif
30  //dvector cv1=value(v1);
31  //dvector cv2=value(v2);
32  dvar_vector vtmp(min, max);
33  double_and_int* pvtmp = vtmp.va + min;
34  double* pv1 = v1.get_v() + min;
35  double_and_int* pv2 = v2.va + min;
36  for (int i = min; i <= max; ++i)
37  {
38  pvtmp->x = *pv1 - pv2->x;
39  ++pvtmp;
40  ++pv1;
41  ++pv2;
42  }
43 
44  //dvar_vector vtmp=nograd_assign(tmp);
45 
48  // The derivative list considerations
49  save_identifier_string("bbbb");
51  fp->save_dvar_vector_position(vtmp);
52  save_identifier_string("aaaa");
53  GRAD_STACK1->set_gradient_stack(cvdv_sub);
54  return vtmp;
55 }
56 
61 void cvdv_sub(void)
62 {
64 
65  // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
71  int min = dftmp.indexmin();
72  int max = dftmp.indexmax();
73  dvector dfv2(min, max);
74  double* pdfv2 = dfv2.get_v() + min;
75  double* pdftmp = dftmp.get_v() + min;
76  for (int i = min; i <= max; ++i)
77  {
78  //vtmp.elem(i)=v1.elem(i)-value(v2.elem(i));
79  *pdfv2 = -(*pdftmp);
80  ++pdfv2;
81  ++pdftmp;
82  }
83  dfv2.save_dvector_derivatives(v2pos);
84  //ierr=fsetpos(gradient_structure::get_fp(),&filepos);
85 }
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
prnstream & endl(prnstream &)
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 cvdv_sub(void)
Description not yet available.
Definition: fvar_a21.cpp:61
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