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 void dvar_vector::initialize(void) 00018 { 00019 if (!(!(*this))) // only initialize allocated objects 00020 { 00021 for (int i=indexmin();i<=indexmax();i++) 00022 { 00023 //this->elem(i)=0.0; 00024 va[i].x=0.0; 00025 } 00026 save_identifier_string("b"); 00027 this->save_dvar_vector_position(); 00028 save_identifier_string("a"); 00029 gradient_structure::GRAD_STACK1-> 00030 set_gradient_stack(dv_init); 00031 } 00032 } 00033 00034 00039 void dv_init(void) 00040 { 00041 // int ierr=fsetpos(gradient_structure::get_fp(),&filepos); 00042 verify_identifier_string("a"); 00043 dvar_vector_position tmp_pos=restore_dvar_vector_position(); 00044 verify_identifier_string("b"); 00045 dvector dftmp(tmp_pos.indexmin(),tmp_pos.indexmax()); 00046 for (int i=dftmp.indexmin();i<=dftmp.indexmax();i++) 00047 { 00048 //vtmp.elem(i)=value(v1.elem(i))+value(v2.elem(i)); 00049 dftmp.elem(i)=0.0; 00050 } 00051 dftmp.save_dvector_derivatives_na(tmp_pos); 00052 //ierr=fsetpos(gradient_structure::get_fp(),&filepos); 00053 } 00054 00055 00060 void dvar_vector::initialize(const dvector& ww) 00061 { 00062 if (indexmin() != ww.indexmin() || indexmax() != ww.indexmax()) 00063 { 00064 cerr << "Index bounds do not match in " 00065 "void dvar_vector::initialize(const dvector& ww)"<<endl; 00066 ad_exit(1); 00067 } 00068 00069 for (int i=indexmin();i<=indexmax();i++) 00070 { 00071 //this->elem(i)=0.0; 00072 va[i].x=ww.elem(i); 00073 } 00074 save_identifier_string("b"); 00075 this->save_dvar_vector_position(); 00076 save_identifier_string("a"); 00077 gradient_structure::GRAD_STACK1-> 00078 set_gradient_stack(dv_init); 00079 }
Generated on Tue Mar 8 2016 19:51:33 for ADMB Documentation by 1.8.0 |