ADMB Documentation  11.1.1894
 All Classes Files Functions Variables Typedefs Friends Defines
model31.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: model31.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  */
00007 #include <admodel.h>
00008 
00009 void dll_data_int::allocate(int *_pi,const char * _s)
00010 {
00011   model_name_tag::allocate(_s);
00012   pi=_pi;
00013   val=*_pi;
00014 }
00015 
00016 void dll_data_number::allocate(double *_pd,const char * _s)
00017 {
00018   model_name_tag::allocate(_s);
00019   pd=_pd;
00020   val=*_pd;
00021 }
00022 
00023 dll_data_number& dll_data_number::operator=(const double& v)
00024 {
00025   data_number::operator =(v);
00026   return *this;
00027 }
00028 dll_param_number& dll_param_number::operator=(const prevariable& m)
00029 {
00030   dvariable::operator = (m);
00031   return *this;
00032 }
00033 
00034 dll_param_number& dll_param_number::operator = (CGNU_DOUBLE m)
00035 {
00036   dvariable::operator = (m);
00037   return *this;
00038 }
00039 
00040 void dll_param_init_number::allocate
00041   (double * _pd,int _phase_start,const char *_s)
00042 {
00043   named_dvariable::allocate(_s);
00044   initial_params::allocate(_phase_start);
00045   pd=_pd;
00046   value(*this)=*_pd;
00047 }
00048 
00049 void dll_param_number::allocate
00050   (double * _pd,const char *_s)
00051 {
00052   named_dvariable::allocate(_s);
00053   pd=_pd;
00054   value(*this)=*_pd;
00055 }
00056 
00057 
00058 void dll_param_init_number::allocate
00059   (double *_pd,const char *_s)
00060 {
00061   allocate(_pd,1,_s);
00062 }
00063 
00064 dll_param_init_number& dll_param_init_number::operator = (CGNU_DOUBLE m)
00065 {
00066   dvariable::operator = (m);
00067   return *this;
00068 }
00069 
00070 dll_param_init_number& dll_param_init_number::operator=(const prevariable& m)
00071 {
00072   dvariable::operator = (m);
00073   return *this;
00074 }
00075 
00076 dll_param_init_vector& dll_param_init_vector::operator = (const dvector& x)
00077 {
00078   param_init_vector::operator = (x);
00079   return (*this);
00080 }
00081 
00082 dll_param_init_vector& dll_param_init_vector::operator = (const dvar_vector& x)
00083 {
00084   param_init_vector::operator = (x);
00085   return (*this);
00086 }
00087 
00088 dll_param_init_vector& dll_param_init_vector::operator =
00089   (const prevariable& x)
00090 {
00091   param_init_vector::operator = (x);
00092   return (*this);
00093 }
00094 
00095 dll_param_init_vector& dll_param_init_vector::operator = (const double& x)
00096 {
00097   dll_param_init_vector::operator = (x);
00098   return (*this);
00099 }
00100 
00101 void dll_param_init_vector::allocate(double * _pd,int imin,int imax,
00102   int _phase_start,const char * _s)
00103 {
00104   pd=_pd;
00105   named_dvar_vector::allocate(imin,imax,_s);
00106   if (pd && allocated(*this))
00107   {
00108     initial_params::allocate(_phase_start);
00109     double * tmp=_pd;
00110     for (int i=imin;i<=imax;i++)
00111     {
00112       (*this)[i]=*tmp++;
00113     }
00114   }
00115 }
00116 
00117 dll_param_vector& dll_param_vector::operator=(const dvar_vector& m)
00118 {
00119   dvar_vector::operator = (m);
00120   return *this;
00121 }
00122 
00123 dll_param_vector& dll_param_vector::operator=(const dvector& m)
00124 {
00125   dvar_vector::operator = (m);
00126   return *this;
00127 }
00128 
00129 dll_param_vector& dll_param_vector::operator =
00130   (CGNU_DOUBLE m)
00131 {
00132   dvar_vector::operator = (m);
00133   return *this;
00134 }
00135 
00136 dll_param_vector& dll_param_vector::operator=(const prevariable& m)
00137 {
00138   dvar_vector::operator = (m);
00139   return *this;
00140 }
00141 
00142 void dll_param_vector::allocate(double *_pd,int imin,int imax,
00143   const char * _s)
00144 {
00145   pd=_pd;
00146   named_dvar_vector::allocate(imin,imax,_s);
00147   if (pd && allocated(*this))
00148   {
00149     double * tmp=_pd;
00150     for (int i=imin;i<=imax;i++)
00151     {
00152       (*this)[i]=*tmp++;
00153     }
00154   }
00155 }
00156 void dll_param_init_vector::allocate(double * _pd,int imin,int imax,
00157   const char * _s)
00158 {
00159   allocate(_pd,imin,imax,1,_s);
00160 }
00161 
00162 void dll_data_vector::allocate(double * _pd,int imin,int imax,const char * _s)
00163 {
00164   pd=_pd;
00165   named_dvector::allocate(imin,imax,_s);
00166   if (pd && allocated())
00167   {
00168     double * tmp=_pd;
00169     for (int i=imin;i<=imax;i++)
00170     {
00171       (*this)[i]=*tmp++;
00172     }
00173   }
00174 }
00175 dll_data_vector& dll_data_vector::operator = (const dvector& x)
00176 {
00177   data_vector::operator = (x);
00178   return (*this);
00179 }
00180 
00181 dll_data_vector& dll_data_vector::operator = (const double& x)
00182 {
00183   data_vector::operator = (x);
00184   return (*this);
00185 }
00186 
00187 void dll_data_matrix::allocate(double * _d,int rmin,int rmax,
00188   int cmin,int cmax,const char * _s)
00189 {
00190   d=_d;
00191   named_dmatrix::allocate(rmin,rmax,cmin,cmax,_s);
00192   if (d && allocated(*this))
00193   {
00194     double * tmp=_d;
00195     if (!AD_gaussflag)
00196     {
00197       for (int j=cmin;j<=cmax;j++)
00198       {
00199         for (int i=rmin;i<=rmax;i++)
00200         {
00201           (*this)(i,j)=*tmp++;
00202         }
00203       }
00204     }
00205     else
00206     {
00207       for (int i=rmin;i<=rmax;i++)
00208       {
00209         for (int j=cmin;j<=cmax;j++)
00210         {
00211           (*this)(i,j)=*tmp++;
00212         }
00213       }
00214     }
00215   }
00216 }
00217 
00218 
00219 dll_data_matrix& dll_data_matrix::operator=(const dmatrix& m)
00220 {
00221   data_matrix::operator = (m);
00222   return *this;
00223 }
00224 
00225 dll_data_matrix& dll_data_matrix::operator=(const double& m)
00226 {
00227   data_matrix::operator = (m);
00228   return *this;
00229 }
00230 
00231 void dll_param_init_matrix::allocate(double* _d,int rmin,int rmax,
00232   int cmin,int cmax,const char *_s )
00233 {
00234   allocate(_d,rmin,rmax,cmin,cmax,1,_s );
00235 }
00236 
00237 
00238 void dll_param_init_matrix::allocate(double* _d,int rmin,int rmax,
00239   int cmin,int cmax,int _phase_start,const char *_s )
00240 {
00241   d=_d;
00242   named_dvar_matrix::allocate(rmin,rmax,cmin,cmax,_s);
00243   initial_params::allocate(_phase_start);
00244   if (d && allocated(*this))
00245   {
00246     double * tmp=_d;
00247     if (!AD_gaussflag)
00248     {
00249       for (int j=cmin;j<=cmax;j++)
00250       {
00251         for (int i=rmin;i<=rmax;i++)
00252         {
00253           (*this)(i,j)=*tmp++;
00254         }
00255       }
00256     }
00257     else
00258     {
00259       for (int i=rmin;i<=rmax;i++)
00260       {
00261         for (int j=cmin;j<=cmax;j++)
00262         {
00263           (*this)(i,j)=*tmp++;
00264         }
00265       }
00266     }
00267   }
00268 }
00269 
00270 void dll_param_matrix::allocate(double* _pd,int rmin,int rmax,
00271   int cmin,int cmax,const char *_s )
00272 {
00273   pd=_pd;
00274   named_dvar_matrix::allocate(rmin,rmax,cmin,cmax,_s);
00275   if (pd && allocated(*this))
00276   {
00277     double * tmp=_pd;
00278     if (!AD_gaussflag)
00279     {
00280       for (int j=cmin;j<=cmax;j++)
00281       {
00282         for (int i=rmin;i<=rmax;i++)
00283         {
00284           (*this)(i,j)=*tmp++;
00285         }
00286       }
00287     }
00288     else
00289     {
00290       for (int i=rmin;i<=rmax;i++)
00291       {
00292         for (int j=cmin;j<=cmax;j++)
00293         {
00294           (*this)(i,j)=*tmp++;
00295         }
00296       }
00297     }
00298   }
00299 }
00300 
00301 void dll_param_init_bounded_number::allocate(double *_pd,double _minb,
00302   double _maxb,const char * _s)
00303 {
00304   allocate(_pd,_minb,_maxb,1,_s);
00305 }
00306 
00307 void dll_param_init_bounded_number::allocate(double *_pd,double _minb,
00308   double _maxb,int _phase_start,const char * _s)
00309 {
00310   pd=_pd;
00311   minb=_minb;
00312   maxb=_maxb;
00313   named_dvariable::allocate(_s);
00314   initial_params::allocate(_phase_start);
00315   {
00316     if (!pd)
00317       prevariable::operator=((minb+maxb)/2.);
00318     else
00319     {
00320       double iv=*pd;
00321       if ( iv <=minb || iv >= maxb)
00322       {
00323         prevariable::operator=((minb+maxb)/2.);
00324       }
00325       else
00326       {
00327         prevariable::operator=(iv);
00328       }
00329     }
00330   }
00331 }
00332 
00333 void dll_param_init_bounded_vector::allocate(double* _pd,int imin,int imax,
00334   double _minb,double _maxb,int phase_start,const char * s)
00335 {
00336   pd=_pd;
00337   minb=_minb;
00338   maxb=_maxb;
00339   named_dvar_vector::allocate(imin,imax,s);
00340   initial_params::allocate(phase_start);
00341   if (pd && allocated(*this))
00342   {
00343     double * tmp=_pd;
00344     for (int i=imin;i<=imax;i++)
00345     {
00346       double td=*tmp++;
00347       if (td<minb || td>maxb) td=(minb+maxb)/2.;
00348       (*this)[i]=td;
00349     }
00350   }
00351 }
00352 
00353 void dll_param_init_bounded_vector::allocate(double* _pd,int imin,int imax,
00354   double _minb,double _maxb,const char * s)
00355 {
00356   allocate(_pd,imin,imax,_minb,_maxb,1,s);
00357 }
00358 
00359 dll_param_matrix& dll_param_matrix::operator =
00360   (const dvar_matrix& m)
00361 {
00362   param_matrix::operator = (m);
00363   return *this;
00364 }
00365 
00366 dll_param_matrix& dll_param_matrix::operator =
00367   (const double m)
00368 {
00369   param_matrix::operator = (m);
00370   return *this;
00371 }
00372 
00373 dll_param_matrix& dll_param_matrix::operator =
00374   (const dvariable& m)
00375 {
00376   param_matrix::operator = (m);
00377   return *this;
00378 }
00379 
00380 dll_param_matrix& dll_param_matrix::operator =
00381   (const dmatrix& m)
00382 {
00383   param_matrix::operator = (m);
00384   return *this;
00385 }
00386 
00387 dll_param_init_matrix& dll_param_init_matrix::operator =
00388   (const dmatrix& m)
00389 {
00390   param_init_matrix::operator = (m);
00391   return *this;
00392 }
00393 
00394 dll_param_init_matrix& dll_param_init_matrix::operator =
00395   (const dvar_matrix& m)
00396 {
00397   param_init_matrix::operator = (m);
00398   return *this;
00399 }
00400 
00401 dll_param_init_matrix& dll_param_init_matrix::operator =
00402   (const dvariable& m)
00403 {
00404   param_init_matrix::operator = (m);
00405   return *this;
00406 }
00407 
00408 dll_param_init_matrix& dll_param_init_matrix::operator =
00409   (const double& m)
00410 {
00411   param_init_matrix::operator = (m);
00412   return *this;
00413 }