ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a43.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_div(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("cffb");
00024     save_double_value(x);
00025     for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00026     {
00027       tmp.elem_value(i)=x/t1.elem_value(i);
00028     }
00029     t1.save_dvar_vector_value();
00030     tmp.save_dvar_vector_position();
00031     t1.save_dvar_vector_position();
00032     save_identifier_string("dffa");
00033     RETURN_ARRAYS_DECREMENT();
00034     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_cdble_dv_div);
00035     return(tmp);
00036   }
00037 
00042  void DF_cdble_dv_div(void)
00043  {
00044     verify_identifier_string("dffa");
00045     dvar_vector_position t1_pos=restore_dvar_vector_position();
00046     dvar_vector_position tmp_pos=restore_dvar_vector_position();
00047     dvector t1=restore_dvar_vector_value(t1_pos);
00048     double x=restore_double_value();
00049     dvector dftmp=restore_dvar_vector_derivatives(tmp_pos);
00050     dvector dft1(t1_pos.indexmin(),t1_pos.indexmax());
00051     verify_identifier_string("cffb");
00052     for (int i=t1_pos.indexmax(); i>=t1_pos.indexmin(); i--)
00053     {
00054       //tmp.elem_value(i)=value(x)/t1.elem_value(i);
00055       double t1inv=1./t1.elem(i);
00056       dft1(i)=-dftmp(i)*x*t1inv*t1inv;
00057     }
00058     dft1.save_dvector_derivatives(t1_pos);
00059  }