ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a40.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_cdble_dv_diff(void);
00014 
00019 dvar_vector operator-(const double x, const dvar_vector& t1)
00020   {
00021     RETURN_ARRAYS_INCREMENT();
00022     dvar_vector tmp(t1.indexmin(),t1.indexmax());
00023     save_identifier_string("ecbb");
00024     for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00025     {
00026       tmp.elem_value(i)=x-t1.elem_value(i);
00027     }
00028     tmp.save_dvar_vector_position();
00029     t1.save_dvar_vector_position();
00030     save_identifier_string("druu");
00031     RETURN_ARRAYS_DECREMENT();
00032     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_cdble_dv_diff);
00033     return(tmp);
00034   }
00035 
00040  void DF_cdble_dv_diff(void)
00041  {
00042     verify_identifier_string("druu");
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("ecbb");
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  }
00057 
00058  void DF_dv_minus(void);
00059 
00064 dvar_vector operator-(const dvar_vector& t1)
00065   {
00066     RETURN_ARRAYS_INCREMENT();
00067     dvar_vector tmp(t1.indexmin(),t1.indexmax());
00068     save_identifier_string("vcbb");
00069     for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00070     {
00071       tmp.elem_value(i)=-t1.elem_value(i);
00072     }
00073     tmp.save_dvar_vector_position();
00074     t1.save_dvar_vector_position();
00075     save_identifier_string("tduu");
00076     RETURN_ARRAYS_DECREMENT();
00077     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_dv_minus);
00078     return(tmp);
00079   }
00080 
00085  void DF_dv_minus(void)
00086  {
00087     verify_identifier_string("tduu");
00088     dvar_vector_position t1_pos=restore_dvar_vector_position();
00089     dvar_vector_position tmp_pos=restore_dvar_vector_position();
00090     dvector dftmp=restore_dvar_vector_derivatives(tmp_pos);
00091     dvector dft1(t1_pos.indexmin(),t1_pos.indexmax());
00092     verify_identifier_string("vcbb");
00093     //double xinv=1./x;
00094     for (int i=t1_pos.indexmax(); i>=t1_pos.indexmin(); i--)
00095     {
00096        // tmp.elem_value(i)=t1.elem_value(i)-value(x);
00097       //tmp.elem_value(i)=value(x)*t1.elem_value(i)/value(x);
00098       dft1(i)=-dftmp(i);
00099     }
00100     dft1.save_dvector_derivatives(t1_pos);
00101  }