ADMB Documentation  11.1x.2711
 All Classes Files Functions Variables Typedefs Friends Defines
model31.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: model31.cpp 2456 2014-10-02 18:13:21Z 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=(const 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=(const 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   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=(const double m)
00130 {
00131   dvar_vector::operator = (m);
00132   return *this;
00133 }
00134 
00135 dll_param_vector& dll_param_vector::operator=(const prevariable& m)
00136 {
00137   dvar_vector::operator = (m);
00138   return *this;
00139 }
00140 
00141 void dll_param_vector::allocate(double *_pd,int imin,int imax,
00142   const char * _s)
00143 {
00144   pd=_pd;
00145   named_dvar_vector::allocate(imin,imax,_s);
00146   if (pd && allocated(*this))
00147   {
00148     double * tmp=_pd;
00149     for (int i=imin;i<=imax;i++)
00150     {
00151       (*this)[i]=*tmp++;
00152     }
00153   }
00154 }
00155 void dll_param_init_vector::allocate(double * _pd,int imin,int imax,
00156   const char * _s)
00157 {
00158   allocate(_pd,imin,imax,1,_s);
00159 }
00160 
00161 void dll_data_vector::allocate(double * _pd,int imin,int imax,const char * _s)
00162 {
00163   pd=_pd;
00164   named_dvector::allocate(imin,imax,_s);
00165   if (pd && allocated())
00166   {
00167     double * tmp=_pd;
00168     for (int i=imin;i<=imax;i++)
00169     {
00170       (*this)[i]=*tmp++;
00171     }
00172   }
00173 }
00174 dll_data_vector& dll_data_vector::operator = (const dvector& x)
00175 {
00176   data_vector::operator = (x);
00177   return (*this);
00178 }
00179 
00180 dll_data_vector& dll_data_vector::operator = (const double& x)
00181 {
00182   data_vector::operator = (x);
00183   return (*this);
00184 }
00185 
00186 void dll_data_matrix::allocate(double * _d,int rmin,int rmax,
00187   int cmin,int cmax,const char * _s)
00188 {
00189   d=_d;
00190   named_dmatrix::allocate(rmin,rmax,cmin,cmax,_s);
00191   if (d && allocated(*this))
00192   {
00193     double * tmp=_d;
00194     if (!AD_gaussflag)
00195     {
00196       for (int j=cmin;j<=cmax;j++)
00197       {
00198         for (int i=rmin;i<=rmax;i++)
00199         {
00200           (*this)(i,j)=*tmp++;
00201         }
00202       }
00203     }
00204     else
00205     {
00206       for (int i=rmin;i<=rmax;i++)
00207       {
00208         for (int j=cmin;j<=cmax;j++)
00209         {
00210           (*this)(i,j)=*tmp++;
00211         }
00212       }
00213     }
00214   }
00215 }
00216 
00217 
00218 dll_data_matrix& dll_data_matrix::operator=(const dmatrix& m)
00219 {
00220   data_matrix::operator = (m);
00221   return *this;
00222 }
00223 
00224 dll_data_matrix& dll_data_matrix::operator=(const double& m)
00225 {
00226   data_matrix::operator = (m);
00227   return *this;
00228 }
00229 
00230 void dll_param_init_matrix::allocate(double* _d,int rmin,int rmax,
00231   int cmin,int cmax,const char *_s )
00232 {
00233   allocate(_d,rmin,rmax,cmin,cmax,1,_s );
00234 }
00235 
00236 
00237 void dll_param_init_matrix::allocate(double* _d,int rmin,int rmax,
00238   int cmin,int cmax,int _phase_start,const char *_s )
00239 {
00240   d=_d;
00241   named_dvar_matrix::allocate(rmin,rmax,cmin,cmax,_s);
00242   initial_params::allocate(_phase_start);
00243   if (d && allocated(*this))
00244   {
00245     double * tmp=_d;
00246     if (!AD_gaussflag)
00247     {
00248       for (int j=cmin;j<=cmax;j++)
00249       {
00250         for (int i=rmin;i<=rmax;i++)
00251         {
00252           (*this)(i,j)=*tmp++;
00253         }
00254       }
00255     }
00256     else
00257     {
00258       for (int i=rmin;i<=rmax;i++)
00259       {
00260         for (int j=cmin;j<=cmax;j++)
00261         {
00262           (*this)(i,j)=*tmp++;
00263         }
00264       }
00265     }
00266   }
00267 }
00268 
00269 void dll_param_matrix::allocate(double* _pd,int rmin,int rmax,
00270   int cmin,int cmax,const char *_s )
00271 {
00272   pd=_pd;
00273   named_dvar_matrix::allocate(rmin,rmax,cmin,cmax,_s);
00274   if (pd && allocated(*this))
00275   {
00276     double * tmp=_pd;
00277     if (!AD_gaussflag)
00278     {
00279       for (int j=cmin;j<=cmax;j++)
00280       {
00281         for (int i=rmin;i<=rmax;i++)
00282         {
00283           (*this)(i,j)=*tmp++;
00284         }
00285       }
00286     }
00287     else
00288     {
00289       for (int i=rmin;i<=rmax;i++)
00290       {
00291         for (int j=cmin;j<=cmax;j++)
00292         {
00293           (*this)(i,j)=*tmp++;
00294         }
00295       }
00296     }
00297   }
00298 }
00299 
00300 void dll_param_init_bounded_number::allocate(double *_pd,double _minb,
00301   double _maxb,const char * _s)
00302 {
00303   allocate(_pd,_minb,_maxb,1,_s);
00304 }
00305 
00306 void dll_param_init_bounded_number::allocate(double *_pd,double _minb,
00307   double _maxb,int _phase_start,const char * _s)
00308 {
00309   pd=_pd;
00310   minb=_minb;
00311   maxb=_maxb;
00312   named_dvariable::allocate(_s);
00313   initial_params::allocate(_phase_start);
00314   {
00315     if (!pd)
00316       prevariable::operator=((minb+maxb)/2.);
00317     else
00318     {
00319       double iv=*pd;
00320       if ( iv <=minb || iv >= maxb)
00321       {
00322         prevariable::operator=((minb+maxb)/2.);
00323       }
00324       else
00325       {
00326         prevariable::operator=(iv);
00327       }
00328     }
00329   }
00330 }
00331 
00332 void dll_param_init_bounded_vector::allocate(double* _pd,int imin,int imax,
00333   double _minb,double _maxb,int phase_start,const char * s)
00334 {
00335   pd=_pd;
00336   minb=_minb;
00337   maxb=_maxb;
00338   named_dvar_vector::allocate(imin,imax,s);
00339   initial_params::allocate(phase_start);
00340   if (pd && allocated(*this))
00341   {
00342     double * tmp=_pd;
00343     for (int i=imin;i<=imax;i++)
00344     {
00345       double td=*tmp++;
00346       if (td<minb || td>maxb) td=(minb+maxb)/2.;
00347       (*this)[i]=td;
00348     }
00349   }
00350 }
00351 
00352 void dll_param_init_bounded_vector::allocate(double* _pd,int imin,int imax,
00353   double _minb,double _maxb,const char * s)
00354 {
00355   allocate(_pd,imin,imax,_minb,_maxb,1,s);
00356 }
00357 
00358 dll_param_matrix& dll_param_matrix::operator =
00359   (const dvar_matrix& m)
00360 {
00361   param_matrix::operator = (m);
00362   return *this;
00363 }
00364 
00365 dll_param_matrix& dll_param_matrix::operator =
00366   (const double m)
00367 {
00368   param_matrix::operator = (m);
00369   return *this;
00370 }
00371 
00372 dll_param_matrix& dll_param_matrix::operator =
00373   (const dvariable& m)
00374 {
00375   param_matrix::operator = (m);
00376   return *this;
00377 }
00378 
00379 dll_param_matrix& dll_param_matrix::operator =
00380   (const dmatrix& m)
00381 {
00382   param_matrix::operator = (m);
00383   return *this;
00384 }
00385 
00386 dll_param_init_matrix& dll_param_init_matrix::operator =
00387   (const dmatrix& m)
00388 {
00389   param_init_matrix::operator = (m);
00390   return *this;
00391 }
00392 
00393 dll_param_init_matrix& dll_param_init_matrix::operator =
00394   (const dvar_matrix& m)
00395 {
00396   param_init_matrix::operator = (m);
00397   return *this;
00398 }
00399 
00400 dll_param_init_matrix& dll_param_init_matrix::operator =
00401   (const dvariable& m)
00402 {
00403   param_init_matrix::operator = (m);
00404   return *this;
00405 }
00406 
00407 dll_param_init_matrix& dll_param_init_matrix::operator =
00408   (const double& m)
00409 {
00410   param_init_matrix::operator = (m);
00411   return *this;
00412 }