ADMB Documentation  11.2.2828
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a57.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvar_a57.cpp 1919 2014-04-22 22:02:01Z 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_unary_diff(void);
00014 
00019   dvar_vector dvar_vector::operator- (void)
00020   {
00021     RETURN_ARRAYS_INCREMENT();
00022     int mmin=indexmin();
00023     int mmax=indexmax();
00024     dvar_vector tmp(mmin,mmax);
00025     save_identifier_string("ec");
00026     for (int i=mmin; i<=mmax; i++)
00027     {
00028       tmp.elem_value(i)=-elem_value(i);
00029     }
00030     tmp.save_dvar_vector_position();
00031     save_dvar_vector_position();
00032     save_identifier_string("d");
00033     RETURN_ARRAYS_DECREMENT();
00034     gradient_structure::GRAD_STACK1->set_gradient_stack(DF_unary_diff);
00035     return(tmp);
00036   }
00037 
00042  void DF_unary_diff(void)
00043  {
00044     verify_identifier_string("d");
00045     dvar_vector_position t1_pos=restore_dvar_vector_position();
00046     dvar_vector_position tmp_pos=restore_dvar_vector_position();
00047     dvector dftmp=restore_dvar_vector_derivatives(tmp_pos);
00048     dvector dft1(t1_pos.indexmin(),t1_pos.indexmax());
00049     verify_identifier_string("ec");
00050     //double xinv=1./x;
00051     for (int i=t1_pos.indexmax(); i>=t1_pos.indexmin(); i--)
00052     {
00053        // tmp.elem_value(i)=t1.elem_value(i)-value(x);
00054       //tmp.elem_value(i)=value(x)*t1.elem_value(i)/value(x);
00055       dft1(i)=-dftmp(i);
00056     }
00057     dft1.save_dvector_derivatives(t1_pos);
00058  }