ADMB Documentation  11.1.1916
 All Classes Files Functions Variables Typedefs Friends Defines
f1b2loc2.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: f1b2loc2.cpp 1110 2013-07-12 01:11:28Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <df1b2fun.h>
00012 #include "f1b2locl.h"
00013 class newadkludge;
00014 extern newadkludge * newadkl;
00015 
00020 local_dep_df1b2variable::local_dep_df1b2variable(void) :
00021   df1b2variable(newadkl)
00022 {
00023   //adpool * tmppool=df1b2variable::pool;
00024   //int tmpnvar=df1b2variable::nvar;
00025   //df1b2variable::restore_adpool_pointer();
00026   p=new df1b2variable();
00027   //df1b2variable::save_adpool_pointer();
00028   //df1b2variable::pool=tmppool;
00029   //df1b2variable::nvar=tmpnvar;
00030 }
00031 
00036 local_dep_df1b2variable::~local_dep_df1b2variable()
00037 {
00038   delete (df1b2variable *) p;
00039 }
00040 
00045 local_dep_df1b2variable&  local_dep_df1b2variable::operator =
00046   (const df1b2variable& x)
00047 {
00048   df1b2variable::operator = (x);
00049   *(p->get_u()) = *get_u();
00050   local_init_var::dot_calcs_all(*this);
00051   /*
00052   int global_nvar=adpool_nvar_stack[adpool_stack_pointer-1];
00053   if (p)
00054   {
00055     p->initialize(global_nvar);
00056     *(p->get_u()) = *get_u();
00057   }
00058   */
00059   return *this;
00060 }
00061 
00066 local_dep_df1b2variable::local_dep_df1b2variable
00067   (double*  _xdot,double * _pxdot) : df1b2variable()
00068 {
00069   p=0;
00070   xdot=_xdot;
00071   pxdot=_pxdot;
00072 }
00073 
00078 local_dep_df1b2variable::local_dep_df1b2variable
00079   (const df1b2variable & _x) : df1b2variable(newadkl)
00080 {
00081   ADUNCONST(df1b2variable,x)
00082   p=&_x;
00083   xu=*(x.get_u());
00084 }
00085 
00090 local_dep_df1b2vector::local_dep_df1b2vector(const df1b2vector & _x)
00091 {
00092   ADUNCONST(df1b2vector,x)
00093   p=&_x;
00094   int mmin=x.indexmin();
00095   int mmax=x.indexmax();
00096   //int ind_index = x(mmin).get_ind_index();
00097   df1b2variable::noallocate=1;
00098   df1b2vector::allocate(mmin,mmax);
00099   df1b2variable::noallocate=0;
00100 }
00101 
00102  // #define USE_BARD_PEN
00103  // class newadkludge;
00104  // extern newadkludge * newadkl=0;
00105  //
00106  //
00107   typedef local_dep_var  * PLOCAL_INIT_VAR;
00108  //
00109  // class laplace_approximation_calculator;
00110  // laplace_approximation_calculator * funnel_dep_var::lapprox=0;
00111  // df1b2variable * funnel_dep_var::funnel_constraints_penalty=0;
00112   int local_dep_var::num_vars=0;
00113  // //int funnel_dep_var::num_all_vars=0;
00114   int local_dep_var::num_inactive_vars=0;
00115   int local_dep_var::num_active_parameters=0;
00116  // //funnel_dep_var ** funnel_dep_var::all_list=new PFUNNEL_INIT_VAR[200];
00117   local_dep_var ** local_dep_var::list=new PLOCAL_INIT_VAR[200];
00118   local_dep_var ** local_dep_var::inactive_list=new PLOCAL_INIT_VAR[200];
00119   //dep_df1b2vector * local_dep_var::py=0;
00120   imatrix * local_dep_var::plist=0;
00121  //
00122  // void  xxx(dep_df1b2vector & tmp,int x){;}
00123  //
00128   void local_dep_var::add_to_list(void)
00129   {
00130     index=num_vars;
00131     list[num_vars++]=this;
00132     //all_list[num_all_vars++]=this;
00133   }
00134  //
00135  // void funnel_dep_var::delete_from_list(void)
00136  // {
00137  //   if (index!=num_vars-1)
00138  //   {
00139  //     cerr << "can only delete last member" << endl;
00140  //     ad_exit(1);
00141  //   }
00142  //   num_vars--;
00143  //   index=-1;
00144  // }
00145  //
00146 
00151   void local_dep_var::add_to_inactive_list(void)
00152   {
00153     index=-1;
00154     inactive_list[num_inactive_vars++]=this;
00155   }
00156 
00161   void local_init_var::end_local_calculations(void)
00162   {
00163     local_dep_var::deallocate_all();
00164     reset_counters();
00165     f1b2gradlist=globalf1b2gradlist;
00166     df1b2_gradlist::set_yes_derivatives();
00167     df1b2variable::restore_adpool_pointer();
00168   }
00169 
00174   void local_dep_var::allocate_all(void)
00175   {
00176     for (int i=0;i<num_vars;i++)
00177     {
00178       list[i]->allocate();
00179     }
00180   }
00181 
00186   void local_dep_var::deallocate_all(void)
00187   {
00188     for (int i=0;i<num_vars;i++)
00189     {
00190       list[i]->deallocate();
00191     }
00192   }
00193 
00198   void local_dep_df1b2variable::allocate(void)
00199   {
00200     df1b2variable::allocate();
00201   }
00202 
00207   void local_dep_df1b2variable::deallocate(void)
00208   {
00209     df1b2variable::deallocate();
00210   }
00211 
00216   int local_dep_var::nvarcalc_all(void)
00217   {
00218     int n=0;
00219     for (int i=0;i<num_vars;i++)
00220     {
00221       n+=list[i]->nvar_calc();
00222     }
00223     return n;
00224   }
00225 
00230   void local_dep_df1b2variable::set_index(imatrix& y,int& ii)
00231   {
00232     y(ii,1)= ind_index;
00233     y(ii,2)= ii;
00234     ii++;
00235   }
00236 
00241   int local_dep_df1b2vector::nvar_calc(void)
00242   {
00243     return p->indexmax()-p->indexmin()+1;
00244   }
00245 
00250   void local_dep_df1b2vector::set_index(imatrix& y,int& ii)
00251   {
00252     int mmin=p->indexmin();
00253     int mmax=p->indexmax();
00254     int i;
00255     for (i=mmin;i<=mmax;i++)
00256     {
00257       //y(ii,1)= ( *(df1b2_dep_vector *)(p) )(i).get_ind_index();
00258       y(ii,2)= ii;
00259       ii++;
00260     }
00261   }