ADMB Documentation  11.1.1890
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_a32.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvar_a32.cpp 1112 2013-07-12 21:41:41Z 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 dv_subassign(void);
00014 
00019 dvar_vector dvar_vector::operator()(const ivector& u)
00020  {
00021    dvar_vector tmp(u.indexmin(),u.indexmax());
00022 
00023    for (int i=u.indexmin();i<=u.indexmax();i++)
00024    {
00025      tmp.elem_value(i)=elem_value(u(i));
00026    }
00027    save_identifier_string("by");
00028    save_dvar_vector_position();
00029    tmp.save_dvar_vector_position();
00030    u.save_ivector_value();
00031    u.save_ivector_position();
00032    save_identifier_string("ay");
00033    gradient_structure::GRAD_STACK1->
00034      set_gradient_stack(dv_subassign);
00035    return tmp;
00036  }
00037 
00042 void dv_subassign(void)
00043 {
00044   // int ierr=fsetpos(gradient_structure::get_fp(),&filepos);
00045   verify_identifier_string("ay");
00046   ivector_position u_pos=restore_ivector_position();
00047   ivector u=restore_ivector_value(u_pos);
00048   dvar_vector_position tmp_pos=restore_dvar_vector_position();
00049   dvector dftmp=restore_dvar_vector_derivatives(tmp_pos);
00050   dvar_vector_position t_pos=restore_dvar_vector_position();
00051   dvector dft(t_pos.indexmin(),t_pos.indexmax());
00052   verify_identifier_string("by");
00053   dft.initialize();
00054   int mmin=dftmp.indexmin();
00055   int mmax=dftmp.indexmax();
00056   for (int i=mmin;i<=mmax;i++)
00057   {
00058      //tmp.elem_value(i)=this->elem_value(u(i));
00059      dft.elem(u(i))+=dftmp.elem(i);
00060   }
00061   dft.save_dvector_derivatives(t_pos);
00062 }
00063 
00068 dvar_vector dvar_vector::operator()(const lvector& u)
00069  {
00070    dvar_vector tmp(u.indexmin(),u.indexmax());
00071 
00072    for ( int i=u.indexmin(); i<=u.indexmax(); i++)
00073    {
00074      tmp(i)=(*this)(u(i));
00075    }
00076    return tmp;
00077  }