ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_ma7.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 /*
00014 void dvar_matrix::initialize(void)
00015 {
00016   if (!(!(*this)))  // only initialize allocated objects
00017   {
00018     for (int i=rowmin();i<=rowmax();i++)
00019     {
00020       elem(i).initialize();
00021     }
00022   }
00023 }
00024 */
00025 
00030 void dfmatinit(void)
00031 {
00032   verify_identifier_string("q");
00033   dvar_matrix_position tmp_pos=restore_dvar_matrix_position();
00034   verify_identifier_string("p");
00035   dmatrix tmp(tmp_pos);
00036   tmp.initialize();
00037   tmp.save_dmatrix_derivatives_na(tmp_pos);
00038 }
00039 
00044 void dvar_matrix::initialize(void)
00045 {
00046   if (!(!(*this)))  // only initialize allocated objects
00047   {
00048     if (indexmin()>indexmax())
00049        cout << "error" << endl;
00050     int imin=indexmin();
00051     int imax=indexmax();
00052     for (int i=imin;i<=imax;i++)
00053     {
00054       if (allocated(elem(i)))
00055       {
00056         dvar_vector& tmp=elem(i);
00057         int jmin=tmp.indexmin();
00058         int jmax=tmp.indexmax();
00059         double * pd=&(tmp.elem_value(jmin));
00060         for (int j=jmin;j<=jmax;j++)
00061         {
00062           *pd++=0.0;
00063         }
00064       }
00065     }
00066     save_identifier_string("p");
00067     save_dvar_matrix_position();
00068     gradient_structure::GRAD_STACK1->
00069       set_gradient_stack(dfmatinit);
00070     save_identifier_string("q");
00071   }
00072 }