ADMB Documentation  11.1.2503
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a39.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvar_a39.cpp 1942 2014-04-28 22:22:45Z johnoel $
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_dv_cdble_diff(void);
00014 
00019 dvar_vector operator-(const dvar_vector& t1, const double x)
00020   {
00021     RETURN_ARRAYS_INCREMENT();
00022     dvar_vector tmp(t1.indexmin(),t1.indexmax());
00023     save_identifier_string("ucbb");
00024     for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00025     {
00026       tmp.elem_value(i)=t1.elem_value(i)-x;
00027     }
00028     tmp.save_dvar_vector_position();
00029     t1.save_dvar_vector_position();
00030     save_identifier_string("dduu");
00031     RETURN_ARRAYS_DECREMENT();
00032     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_dv_cdble_diff);
00033     return(tmp);
00034   }
00035 
00040  void DF_dv_cdble_diff(void)
00041  {
00042     verify_identifier_string("dduu");
00043     dvar_vector_position t1_pos=restore_dvar_vector_position();
00044     dvar_vector_position tmp_pos=restore_dvar_vector_position();
00045     dvector dftmp=restore_dvar_vector_derivatives(tmp_pos);
00046     dvector dft1(t1_pos.indexmin(),t1_pos.indexmax());
00047     verify_identifier_string("ucbb");
00048     //double xinv=1./x;
00049     for (int i=t1_pos.indexmax(); i>=t1_pos.indexmin(); i--)
00050     {
00051        // tmp.elem_value(i)=t1.elem_value(i)-value(x);
00052       //tmp.elem_value(i)=value(x)*t1.elem_value(i)/value(x);
00053       dft1(i)=dftmp(i);
00054     }
00055     dft1.save_dvector_derivatives(t1_pos);
00056  }