ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a54.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00013   void DF_v_xdble_diff(void);
00014 
00019 dvar_vector operator-(const dvector& t1, const prevariable& x)
00020   {
00021     RETURN_ARRAYS_INCREMENT();
00022     dvar_vector tmp(t1.indexmin(),t1.indexmax());
00023     save_identifier_string("zcb");
00024     x.save_prevariable_position();
00025     for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00026     {
00027       tmp.elem_value(i)=t1.elem(i)-value(x);
00028     }
00029     tmp.save_dvar_vector_position();
00030     save_identifier_string("ddu");
00031     RETURN_ARRAYS_DECREMENT();
00032     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_v_xdble_diff);
00033     return(tmp);
00034   }
00035 
00040  void DF_v_xdble_diff(void)
00041  {
00042     verify_identifier_string("ddu");
00043     dvar_vector_position tmp_pos=restore_dvar_vector_position();
00044     prevariable_position xpos=restore_prevariable_position();
00045     dvector dftmp=restore_dvar_vector_derivatives(tmp_pos);
00046     verify_identifier_string("zcb");
00047     //double xinv=1./x;
00048     double dfx=0.;
00049     for (int i=tmp_pos.indexmax(); i>=tmp_pos.indexmin(); i--)
00050     {
00051       // tmp.elem_value(i)=t1.elem(i)-value(x);
00052       dfx-=dftmp(i);
00053     }
00054     save_double_derivative(dfx,xpos);
00055  }