ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
df1b2f24.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: df1b2f24.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 
00013 #include <df1b2fun.h>
00014 
00019 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
00020   double _minb,double _maxb)
00021 {
00022   minb=_minb;
00023   maxb=_maxb;
00024   df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax);
00025 }
00026 
00031 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
00032   double _minb,double _maxb,const char * s)
00033 {
00034   minb=_minb;
00035   maxb=_maxb;
00036   df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,s);
00037 }
00038 
00043 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,
00044   const index_type& cmin,const index_type& cmax,double _minb,double _maxb,
00045   const char * s)
00046 {
00047   minb=_minb;
00048   maxb=_maxb;
00049   df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,s);
00050 }
00051 
00056 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,
00057   const index_type& cmin,const index_type& cmax,double _minb,double _maxb,
00058   int phase,const char * s)
00059 {
00060   minb=_minb;
00061   maxb=_maxb;
00062   df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,phase,s);
00063   df1b2matrix::operator = ((minb+maxb)/2.0);
00064 }
00065 
00070 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
00071   double _minb,double _maxb,int phase,const char * s)
00072 {
00073   minb=_minb;
00074   maxb=_maxb;
00075   df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,phase,s);
00076 }
00077 
00082 void set_value(const df1b2matrix& _m,const init_df1b2vector& _v, const int& _ii,
00083   double fmin,double fmax,const df1b2variable& fpen)
00084 {
00085   ADUNCONST(int,ii)
00086   ADUNCONST(df1b2matrix,m)
00087   ADUNCONST(init_df1b2vector,v)
00088   int min=m.indexmin();
00089   int max=m.indexmax();
00090   for (int i=min;i<=max;i++)
00091   {
00092     int cmin=m(i).indexmin();
00093     int cmax=m(i).indexmax();
00094     for (int j=cmin;j<=cmax;j++)
00095     {
00096       m(i,j)=boundp(v(ii++),fmin,fmax,fpen);
00097     }
00098   }
00099 }
00100 
00101 void set_value(const df1b2matrix& _m,const init_df1b2vector& _v, const int& _ii,
00102   double fmin,double fmax,const df1b2variable& fpen,double s)
00103 {
00104   ADUNCONST(int,ii)
00105   ADUNCONST(df1b2matrix,m)
00106   ADUNCONST(init_df1b2vector,v)
00107   int min=m.indexmin();
00108   int max=m.indexmax();
00109   for (int i=min;i<=max;i++)
00110   {
00111     int cmin=m(i).indexmin();
00112     int cmax=m(i).indexmax();
00113     for (int j=cmin;j<=cmax;j++)
00114     {
00115       m(i,j)=boundp(v(ii++),fmin,fmax,fpen,s);
00116     }
00117   }
00118 }
00119 
00124 void df1b2_init_bounded_matrix::set_value(const init_df1b2vector& _x,
00125   const int& ii,const df1b2variable& pen)
00126 {
00127   init_df1b2vector& x=(init_df1b2vector&) _x;
00128   int ii1=ii;
00129   if (initial_df1b2params::pointer_table)
00130   {
00131     int mmin=indexmin();
00132     int mmax=indexmax();
00133     for (int i=mmin;i<=mmax;i++)
00134     {
00135       int cmin=(*this)(i).indexmin();
00136       int cmax=(*this)(i).indexmax();
00137       for (int j=cmin;j<=cmax;j++)
00138       {
00139 #if defined(__x86_64)
00140         intptr_t tmp =(intptr_t)(&((*this)(i,j)));
00141 #else
00142         int tmp= (int)( &((*this)(i,j)) );
00143 #endif
00144         (*initial_df1b2params::pointer_table)(ii1)(1)=tmp;
00145         (*initial_df1b2params::pointer_table)(ii1)(2)=x(ii1).ind_index;
00146         ii1++;
00147       }
00148     }
00149   }
00150   if (scalefactor==0.0)
00151   {
00152     ::set_value(*this,x,ii,minb,maxb,pen);
00153   }
00154   else
00155   {
00156     ::set_value(*this,x,ii,minb,maxb,pen,scalefactor);
00157   }
00158 }
00159 
00164 void set_value(const df1b2_init_bounded_matrix & _v,const dvector& x,
00165   const int& _ii,double fmin,double fmax)
00166 {
00167   ADUNCONST(int,ii)
00168   ADUNCONST(df1b2_init_bounded_matrix,v)
00169   double fpen=0.0;
00170   int mmin=v.indexmin();
00171   int mmax=v.indexmax();
00172   for (int i=mmin;i<=mmax;i++)
00173   {
00174     int cmin=v(i).indexmin();
00175     int cmax=v(i).indexmax();
00176     for (int j=cmin;j<=cmax;j++)
00177     {
00178       v(i,j)=boundp(x(ii++),fmin,fmax,fpen);
00179     }
00180   }
00181 }
00182 
00183 
00184 void set_value(const df1b2_init_bounded_matrix & _v,const dvector& x,
00185   const int& _ii,double fmin,double fmax,double s)
00186 {
00187   ADUNCONST(int,ii)
00188   ADUNCONST(df1b2_init_bounded_matrix,v)
00189   double fpen=0.0;
00190   int mmin=v.indexmin();
00191   int mmax=v.indexmax();
00192   for (int i=mmin;i<=mmax;i++)
00193   {
00194     int cmin=v(i).indexmin();
00195     int cmax=v(i).indexmax();
00196     for (int j=cmin;j<=cmax;j++)
00197     {
00198       v(i,j)=boundp(x(ii++),fmin,fmax,fpen,s);
00199     }
00200   }
00201 }
00202 
00207 void df1b2_init_bounded_matrix::set_value(const dvector& x,
00208   const int& ii)
00209 {
00210   //double pen=0.0;
00211   ::set_value(*this,x,ii,minb,maxb);
00212 }