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 00017 dvar_vector operator+(const dvar_vector& t1, const prevariable& x) 00018 { 00019 return x+t1; 00020 } 00021 00022 void DF_dble_dv_add(void); 00023 00028 dvar_vector operator+(const prevariable& x, const dvar_vector& t1) 00029 { 00030 RETURN_ARRAYS_INCREMENT(); 00031 dvar_vector tmp(t1.indexmin(),t1.indexmax()); 00032 save_identifier_string("wcbf"); 00033 x.save_prevariable_position(); 00034 for (int i=t1.indexmin(); i<=t1.indexmax(); i++) 00035 { 00036 tmp.elem_value(i)=t1.elem_value(i)+value(x); 00037 } 00038 tmp.save_dvar_vector_position(); 00039 t1.save_dvar_vector_position(); 00040 save_identifier_string("dduu"); 00041 RETURN_ARRAYS_DECREMENT(); 00042 gradient_structure::GRAD_STACK1->set_gradient_stack(DF_dble_dv_add); 00043 return(tmp); 00044 } 00045 00050 void DF_dble_dv_add(void) 00051 { 00052 verify_identifier_string("dduu"); 00053 dvar_vector_position t1_pos=restore_dvar_vector_position(); 00054 dvar_vector_position tmp_pos=restore_dvar_vector_position(); 00055 prevariable_position xpos=restore_prevariable_position(); 00056 dvector dftmp=restore_dvar_vector_derivatives(tmp_pos); 00057 dvector dft1(t1_pos.indexmin(),t1_pos.indexmax()); 00058 verify_identifier_string("wcbf"); 00059 //double xinv=1./x; 00060 double dfx=0.; 00061 for (int i=t1_pos.indexmax(); i>=t1_pos.indexmin(); i--) 00062 { 00063 // tmp.elem_value(i)=value(x)+t1.elem_value(i); 00064 //tmp.elem_value(i)=value(x)*t1.elem_value(i)/value(x); 00065 dfx+=dftmp(i); 00066 dft1(i)=dftmp(i); 00067 } 00068 save_double_derivative(dfx,xpos); 00069 dft1.save_dvector_derivatives(t1_pos); 00070 }
Generated on Tue Mar 8 2016 19:51:33 for ADMB Documentation by 1.8.0 |