ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a55.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_ccv_dble_prod(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("xc");
00024     //x.save_prevariable_value();
00025     x.save_prevariable_position();
00026     for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00027     {
00028       tmp.elem_value(i)=t1.elem(i)*value(x);
00029     }
00030     t1.save_dvector_value();
00031     tmp.save_dvar_vector_position();
00032     t1.save_dvector_position();
00033     save_identifier_string("Da");
00034     RETURN_ARRAYS_DECREMENT();
00035     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_ccv_dble_prod);
00036     return(tmp);
00037   }
00038 
00043 dvar_vector operator*(const prevariable& x, const dvector& t1)
00044   {
00045     RETURN_ARRAYS_INCREMENT();
00046     dvar_vector tmp(t1.indexmin(),t1.indexmax());
00047     save_identifier_string("xc");
00048     //x.save_prevariable_value();
00049     x.save_prevariable_position();
00050     for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00051     {
00052       tmp.elem_value(i)=t1.elem(i)*value(x);
00053     }
00054     t1.save_dvector_value();
00055     tmp.save_dvar_vector_position();
00056     t1.save_dvector_position();
00057     save_identifier_string("Da");
00058     RETURN_ARRAYS_DECREMENT();
00059     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_ccv_dble_prod);
00060     return(tmp);
00061   }
00062 
00067  void DF_ccv_dble_prod(void)
00068  {
00069     verify_identifier_string("Da");
00070     dvector_position t1_pos=restore_dvector_position();
00071     dvar_vector_position tmp_pos=restore_dvar_vector_position();
00072     dvector t1=restore_dvar_vector_value(tmp_pos);
00073     prevariable_position xpos=restore_prevariable_position();
00074     //double x=restore_prevariable_value();
00075     dvector dftmp=restore_dvar_vector_derivatives(tmp_pos);
00076     //dvector dft1(t1_pos.indexmin(),t1_pos.indexmax());
00077     verify_identifier_string("xc");
00078     double dfx=0.;
00079     for (int i=t1_pos.indexmax(); i>=t1_pos.indexmin(); i--)
00080     {
00081       //tmp.elem_value(i)=value(x)*t1.elem_value(i)*value(x);
00082       dfx+=dftmp(i)*t1(i);
00083       //dft1(i)=dftmp(i)*x;
00084     }
00085     save_double_derivative(dfx,xpos);
00086     //dft1.save_dvector_derivatives(t1_pos);
00087  }