00001 /* 00002 * $Id: fvar_a35.cpp 542 2012-07-10 21:04:06Z 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_dble_diff(void); 00014 00019 dvar_vector operator-(const dvar_vector& t1, const prevariable& x) 00020 { 00021 RETURN_ARRAYS_INCREMENT(); 00022 dvar_vector tmp(t1.indexmin(),t1.indexmax()); 00023 save_identifier_string("zcbb"); 00024 x.save_prevariable_position(); 00025 for (int i=t1.indexmin(); i<=t1.indexmax(); i++) 00026 { 00027 tmp.elem_value(i)=t1.elem_value(i)-value(x); 00028 } 00029 tmp.save_dvar_vector_position(); 00030 t1.save_dvar_vector_position(); 00031 save_identifier_string("dduu"); 00032 RETURN_ARRAYS_DECREMENT(); 00033 gradient_structure::GRAD_STACK1-> 00034 set_gradient_stack(DF_dv_dble_diff); 00035 return(tmp); 00036 } 00037 00042 void DF_dv_dble_diff(void) 00043 { 00044 verify_identifier_string("dduu"); 00045 dvar_vector_position t1_pos=restore_dvar_vector_position(); 00046 dvar_vector_position tmp_pos=restore_dvar_vector_position(); 00047 prevariable_position xpos=restore_prevariable_position(); 00048 dvector dftmp=restore_dvar_vector_derivatives(tmp_pos); 00049 dvector dft1(t1_pos.indexmin(),t1_pos.indexmax()); 00050 verify_identifier_string("zcbb"); 00051 //double xinv=1./x; 00052 double dfx=0.; 00053 for (int i=t1_pos.indexmax(); i>=t1_pos.indexmin(); i--) 00054 { 00055 // tmp.elem_value(i)=t1.elem_value(i)-value(x); 00056 //tmp.elem_value(i)=value(x)*t1.elem_value(i)/value(x); 00057 dfx-=dftmp(i); 00058 dft1(i)=dftmp(i); 00059 } 00060 save_double_derivative(dfx,xpos); 00061 dft1.save_dvector_derivatives(t1_pos); 00062 }
|
|
Generated on Thu May 23 2013 08:53:34 for ADMB Documentation by 1.8.0
|