ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a30.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 dv_xminuseq(void);
00014 
00019 dvar_vector& dvar_vector::operator-=(const prevariable& d)
00020  {
00021    {
00022      for (int i=indexmin();i<=indexmax();i++)
00023      {
00024        elem_value(i) -= value(d);
00025      }
00026    }
00027 
00028    save_identifier_string("Pvv");
00029    save_dvar_vector_position();  // for this->
00030    d.save_prevariable_position();
00031    save_identifier_string("Pxx");
00032     gradient_structure::GRAD_STACK1->
00033             set_gradient_stack(dv_xminuseq);
00034    return(*this);
00035  }
00036 
00041 void dv_xminuseq(void)
00042 {
00043   // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
00044   verify_identifier_string("Pxx");
00045   prevariable_position d_pos=restore_prevariable_position();
00046   dvar_vector_position this_pos=restore_dvar_vector_position();
00047   verify_identifier_string("Pvv");
00048   dvector dfthis=restore_dvar_vector_der_nozero(this_pos);
00049   double temp=-sum(dfthis);
00050   save_double_derivative(temp,d_pos);
00051 }
00052 
00053 void dv_xpluseq(void);
00054 
00059 dvar_vector& dvar_vector::operator+=(const prevariable& d)
00060  {
00061    {
00062      for (int i=indexmin();i<=indexmax();i++)
00063      {
00064        elem_value(i) += value(d);
00065      }
00066    }
00067 
00068    save_identifier_string("Qvv");
00069    save_dvar_vector_position();  // for this->
00070    d.save_prevariable_position();
00071    save_identifier_string("Qxx");
00072     gradient_structure::GRAD_STACK1->set_gradient_stack(dv_xpluseq);
00073    return(*this);
00074  }
00075 
00080 void dv_xpluseq(void)
00081 {
00082   // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
00083   verify_identifier_string("Qxx");
00084   prevariable_position d_pos=restore_prevariable_position();
00085   dvar_vector_position this_pos=restore_dvar_vector_position();
00086   verify_identifier_string("Qvv");
00087   dvector dfthis=restore_dvar_vector_der_nozero(this_pos);
00088   double temp=sum(dfthis);
00089   save_double_derivative(temp,d_pos);
00090 }
00091 
00096  dvar_vector& dvar_vector::operator-= (double d)
00097  {
00098    {
00099      for (int i=indexmin();i<=indexmax();i++)
00100      {
00101        elem_value(i) -= d;
00102      }
00103    }
00104 
00105    return(*this);
00106  }
00107 
00112  dvar_vector& dvar_vector::operator+= (double d)
00113  {
00114    {
00115      for (int i=indexmin();i<=indexmax();i++)
00116      {
00117        elem_value(i) += d;
00118      }
00119    }
00120 
00121    return(*this);
00122  }