ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a26.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_minuseq(void);
00014 
00019  dvar_vector& dvar_vector::operator-=(const dvar_vector& v1)
00020  {
00021    if (indexmin() != v1.indexmin() || indexmax() != v1.indexmax())
00022    {
00023      cerr << " Incompatible array bounds in "
00024      "dvector& operator += (const dvar_vector&)\n";
00025      ad_exit(21);
00026    }
00027 
00028    {
00029      for (int i=indexmin();i<=indexmax();i++)
00030      {
00031        elem_value(i) -= v1.elem_value(i);
00032      }
00033    }
00034 
00035    save_identifier_string("uuvv");
00036    save_dvar_vector_position();  // for this->
00037    v1.save_dvar_vector_position();
00038    save_identifier_string("wwxx");
00039     gradient_structure::GRAD_STACK1->
00040             set_gradient_stack(dv_minuseq);
00041    return(*this);
00042  }
00043 
00048 void dv_minuseq(void)
00049 {
00050   // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
00051   verify_identifier_string("wwxx");
00052   dvar_vector_position v1_pos=restore_dvar_vector_position();
00053   dvar_vector_position this_pos=restore_dvar_vector_position();
00054   verify_identifier_string("uuvv");
00055   dvector dfthis=-1.*restore_dvar_vector_der_nozero(this_pos);
00056   dfthis.save_dvector_derivatives(v1_pos);
00057 }
00058 
00063 dvar_vector& dvar_vector::operator-=(const dvector& v1)
00064  {
00065    if (indexmin() != v1.indexmin() || indexmax() != v1.indexmax())
00066    {
00067      cerr << " Incompatible array bounds in "
00068      "dvector& operator += (const dvar_vector&)\n";
00069      ad_exit(21);
00070    }
00071 
00072    {
00073      for (int i=indexmin();i<=indexmax();i++)
00074      {
00075        elem_value(i) -= v1.elem(i);
00076      }
00077    }
00078    return(*this);
00079  }