ADMB Documentation  11.1.2192
 All Classes Files Functions Variables Typedefs Friends Defines
model45.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: model45.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00007 #include <admodel.h>
00008 
00009 void param_init_bounded_vector_vector::set_initial_value(
00010   const double_index_type& _it)
00011  {
00012     it=new double_index_type(_it);
00013  }
00014 
00015  param_init_bounded_vector_vector::param_init_bounded_vector_vector()
00016  {
00017    it=NULL;
00018  }
00019 
00020  void param_init_bounded_vector_vector::allocate(int min1,int max1,
00021    const index_type& min,const index_type& max,const double_index_type& dmin,
00022    const double_index_type& dmax,
00023    const char * s)
00024  {
00025    allocate(min1,max1,min,max,dmin,dmax,1,s);
00026  }
00027 
00028  void param_init_bounded_vector_vector::allocate(int min1,int max1,
00029    const index_type& min,const index_type& max,const double_index_type& dmin,
00030    const double_index_type& dmax,const index_type& phase_start,
00031    const char * s)
00032  {
00033    index_min=min1;
00034    index_max=max1;
00035    int size=indexmax()-indexmin()+1;
00036 
00037    if (size>0)
00038    {
00039      if (!(v=new param_init_bounded_vector[size]))
00040      {
00041         cerr << " error trying to allocate memory in "
00042           "param_init_vector_vector " << endl;
00043         exit(1);
00044      }
00045      v-=indexmin();
00046      for (int i=indexmin();i<=indexmax();i++)
00047      {
00048        if (it) v[i].set_initial_value(ad_double((*it)[i]));
00049        adstring ss=s + adstring("[") + str(i) + adstring("]");
00050        v[i].allocate(ad_integer(min[i]),ad_integer(max[i]),
00051          ad_double(dmin[i]),ad_double(dmax[i]),
00052          ad_integer(phase_start[i]),(char*)(ss) );
00053      }
00054    }
00055    else
00056      v=NULL;
00057  }
00058 
00059    param_init_bounded_vector_vector::~param_init_bounded_vector_vector()
00060    {
00061      deallocate();
00062    }
00063 
00064    void param_init_bounded_vector_vector::deallocate(void)
00065    {
00066      if(it)
00067      {
00068        delete it;
00069        it=NULL;
00070      }
00071      if (v)
00072      {
00073        v+=indexmin();
00074        delete [] v;
00075        v=NULL;
00076      }
00077    }