ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_a22.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 dvdv_sub(void);
13 
19 {
20  if (v1.indexmin()!=v2.indexmin()||v1.indexmax()!=v2.indexmax())
21  {
22  cerr << "Incompatible bounds in "
23  "prevariable operator-(const dvar_vector& v1,const dvar_vector& v2)"
24  << endl;
25  ad_exit(1);
26  }
27  //dvector cv1=value(v1);
28  //dvector cv2=value(v2);
29  kkludge_object kkk;
30  dvar_vector vtmp(v1.indexmin(),v1.indexmax(),kkk);
31  for (int i=v1.indexmin();i<=v1.indexmax();i++)
32  {
33  vtmp.elem_value(i)=v1.elem_value(i)-v2.elem_value(i);
34  }
35 
36  //dvar_vector vtmp=nograd_assign(tmp);
37 
40  // The derivative list considerations
41  save_identifier_string("bbbb");
44  fp->save_dvar_vector_position(vtmp);
45  save_identifier_string("aaaa");
46  GRAD_STACK1->set_gradient_stack(dvdv_sub);
47  return vtmp;
48 }
49 
54 void dvdv_sub(void)
55 {
57 
58  // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
65  dvector dfv1(dftmp.indexmin(),dftmp.indexmax());
66  dvector dfv2(dftmp.indexmin(),dftmp.indexmax());
67  for (int i=dftmp.indexmin();i<=dftmp.indexmax();i++)
68  {
69  //vtmp.elem(i)=value(v1.elem(i))+value(v2.elem(i));
70  dfv1.elem(i)=dftmp.elem(i);
71  dfv2.elem(i)=-dftmp.elem(i);
72  }
73  dfv1.save_dvector_derivatives(v1pos);
74  dfv2.save_dvector_derivatives(v2pos);
75  //ierr=fsetpos(gradient_structure::get_fp(),&filepos);
76 }
Description not yet available.
Definition: fvar.hpp:920
double & elem(int i)
Definition: dvector.h:152
double & elem_value(int i)
Definition: fvar.hpp:2226
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
Description not yet available.
Definition: fvar.hpp:4814
exitptr ad_exit
Definition: gradstrc.cpp:53
Null class to allow specialized function overloads.
Definition: fvar.hpp:469
ADMB variable vector.
Definition: fvar.hpp:2172
void verify_identifier_string(const char *)
Verifies gradient stack string.
Definition: cmpdif3.cpp:149
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
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
void dvdv_sub(void)
Description not yet available.
Definition: fvar_a22.cpp:54
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
static _THREAD grad_stack * GRAD_STACK1
int indexmax() const
Definition: fvar.hpp:2292