00001
00002
00003
00004
00005
00006
00011 #include <cstring>
00012 #if !defined(__BORLANDC__) && !defined(_MSC_VER)
00013 #include <inttypes.h>
00014 #endif
00015 #include <df1b2fun.h>
00016 #include "admb_messages.h"
00017 #ifndef OPT_LIB
00018 #include <cassert>
00019 #include <climits>
00020 #endif
00021
00022 do_naught_kludge df1b2_init_number::do_naught_kludge_a;
00023
00024
00025 #if defined(ADDEBUG_PRINT)
00026 int addebug_count=0;
00027 #endif
00028
00029
00030 int max_num_init_df1b2variable=500;
00031
00032 char AD_allocation_error_message[]="Error tryng to allocate memory for ";
00033
00034 unsigned int get_f1b2buffer_size(const char* s);
00035
00036 #if defined(CHECK_COUNT)
00037 int df1b2_gradlist::ncount_check=-1;
00038 #endif
00039
00040 adpool * df1b2variable::pool= new adpool();
00041
00046 df1b2function1::df1b2function1(double (*_f)(double),double (*_df)(double),
00047 double (*_d2f)(double),double (*_d3f)(double), const adstring& _s )
00048 {
00049 f=_f;
00050 df=_df;
00051 d2f=_d2f;
00052 d3f=_d3f;
00053 funname=_s;
00054 }
00055
00060 ad_dstar::~ad_dstar(void)
00061 {
00062 if (p) delete []p;
00063 p = 0;
00064 }
00065
00070 unsigned int df1b2variable::get_blocksize()
00071 {
00072 return get_blocksize(nvar);
00073 }
00074
00079 unsigned int df1b2variable::get_blocksize(const unsigned int n)
00080 {
00081 return 6*n+5;
00082
00083 }
00084
00089 void df1b2variable::set_blocksize()
00090 {
00091 blocksize=get_blocksize();
00092 pool->set_size(sizeof(double)*blocksize);
00093 pool->nvar=df1b2variable::get_nvar();
00094 }
00095
00096
00097 init_df1b2variable ** init_df1b2variable::list=0;
00098 unsigned int df1b2variable::nvar = 0;
00099 int df1b2variable::minder=0;
00100 int df1b2variable::maxder=0;
00101 unsigned int df1b2variable::blocksize=0;
00102 int init_df1b2variable::num_variables=0;
00103 int df1b2_gradlist::no_derivatives=0;
00104 int df1b2variable::passnumber=0;
00105 unsigned int ad_dstar::n=0;
00106
00107 void ad_read_pass2(void);
00108
00109 #if !defined(__BORLANDC__)
00110 int adptr_diff(void* x, void* y)
00111 {
00112 intptr_t a = (intptr_t)x;
00113 intptr_t b = (intptr_t)y;
00114 ptrdiff_t diff = a - b;
00115 #ifndef OPT_LIB
00116 assert(diff <= INT_MAX);
00117 #endif
00118 return (int)diff;
00119 }
00120 #endif
00121
00122 #if defined(__CHECK_MEMORY__)
00123 int sanity_flag=0;
00124 #endif
00125
00129 void df1b2variable::initialize(void)
00130 {
00131 #if defined(__CHECK_MEMORY__)
00132 if (sanity_flag)
00133 {
00134 df1b2variable::pool->sanity_check();
00135 }
00136 #endif
00137 unsigned int nvar=((twointsandptr*)ptr)->ptr->nvar;
00138 initialize(nvar);
00139 }
00140
00146 void df1b2variable::initialize(const unsigned int n)
00147 {
00148
00149
00150 size_t nbytes = (get_blocksize(n) - 2) * sizeof(double);
00151 memset(ptr + 2, 0, nbytes);
00152 }
00153
00158 void init_df1b2variable::set_u_dot(void)
00159 {
00160
00161 double uvalue=*get_u();
00162 initialize();
00163 int nder=maxder-minder+1;
00164 for (int i=0;i<nder;i++)
00165 {
00166 u_dot[i]=0.0;
00167 }
00168 if (ind_index>=minder && ind_index<=maxder)
00169 {
00170 int offset= ind_index-minder;
00171 u_dot[offset]=1.0;
00172 }
00173 *get_u()=uvalue;
00174 }
00175
00180 void init_df1b2variable::operator = (double d)
00181 {
00182
00183 initialize();
00184
00185 if (ind_index>=minder && ind_index<=maxder)
00186 {
00187 int offset= ind_index-minder;
00188 u_dot[offset]=1.0;
00189 }
00190 get_ind_index()=-1;
00191 *u=d;
00192 }
00193
00198 df1b2variable::df1b2variable(const df1b2variable& v)
00199 {
00200 #if defined(__CHECK_MEMORY__)
00201 if (pchecker)
00202 {
00203 if (v.ptr == pchecker)
00204 {
00205 cout << " copy constructor called " << endl;
00206 }
00207 }
00208 #endif
00209 if (v.ptr)
00210 {
00211 ptr=v.ptr;
00212 ncopies=v.ncopies;
00213 (*ncopies)++;
00214 u=v.u;
00215 u_dot=v.u_dot;
00216 u_bar=v.u_bar;
00217 u_dot_bar=v.u_dot_bar;
00218 u_tilde=v.u_tilde;
00219 u_dot_tilde=v.u_dot_tilde;
00220 u_bar_tilde=v.u_bar_tilde;
00221 u_dot_bar_tilde=v.u_dot_bar_tilde;
00222 }
00223 else
00224 {
00225 ptr=NULL;
00226 ncopies=NULL;
00227 u=NULL;
00228 u_dot=NULL;
00229 u_bar=NULL;
00230 u_dot_bar=NULL;
00231 u_tilde=NULL;
00232 u_dot_tilde=NULL;
00233 u_bar_tilde=NULL;
00234 u_dot_bar_tilde=NULL;
00235 }
00236 }
00237
00238 adkludge1 * adkludgexxx;
00239
00240 typedef init_df1b2variable * PINIT_DF1B2VARIABLE;
00241
00246 init_df1b2variable::init_df1b2variable(double v) : df1b2variable(adkludgexxx)
00247 {
00248 ++num_variables;
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 ind_index=num_variables;
00269 *get_u()=v;
00270 if (num_variables>=minder && num_variables<=maxder)
00271 {
00272
00273
00274 }
00275 }
00279 df1b2variable::~df1b2variable()
00280 {
00281 deallocate();
00282 }
00286 void df1b2variable::deallocate(void)
00287 {
00288 if (ptr)
00289 {
00290 #if defined(__CHECK_MEMORY__)
00291 if (pchecker)
00292 {
00293 if (ptr == pchecker)
00294 {
00295 cout << "destructor called " << endl;
00296 }
00297 }
00298 #endif
00299 if (ncopies && *ncopies)
00300 {
00301 (*ncopies)--;
00302 }
00303 else
00304 {
00305 if (!df1b2_gradlist::no_derivatives)
00306 f1b2gradlist->write_save_pass2_tilde_values(this);
00307 ((twointsandptr*)ptr)->ptr->free(ptr);
00308
00309 ptr = 0;
00310 }
00311 }
00312 }
00313
00318 void init_df1b2vector::set_value(const dvector& v)
00319 {
00320 int mmin=indexmin();
00321 int mmax=indexmax();
00322 if (v.indexmin() != mmin || v.indexmax() != mmax )
00323 {
00324 cerr << "incompatible shape in "
00325 "init_df1b2vector::set_value(const dvector& v)" << endl;
00326 }
00327
00328 for (int i=mmin;i<=mmax;i++)
00329 {
00330 (*this)(i)=v(i);
00331 }
00332 }
00333
00337 init_df1b2vector::init_df1b2vector()
00338 {
00339 allocate();
00340 }
00344 init_df1b2vector::init_df1b2vector(int lb, int ub)
00345 {
00346 allocate(lb, ub);
00347 }
00348
00353 void init_df1b2vector::allocate(int lb,int ub)
00354 {
00355 init_df1b2variable::num_variables= 0;
00356 index_min=lb;
00357 index_max=ub;
00358 ncopies=new int;
00359 *ncopies=0;
00360 int size=indexmax()-indexmin()+1;
00361 if (init_df1b2variable::list==0)
00362 {
00363 max_num_init_df1b2variable
00364 =max(size,max_num_init_df1b2variable);
00365
00366 init_df1b2variable::list =
00367 new PINIT_DF1B2VARIABLE [max_num_init_df1b2variable];
00368 if (init_df1b2variable::list==0)
00369 {
00370 cerr << "Error allocating memory for init_df1b2variable::list"
00371 << endl;
00372 exit(1);
00373 }
00374 }
00375
00376
00377 trueptr=new init_df1b2variable[size];
00378 if (trueptr == 0)
00379 {
00380 cerr << "Error allocating memory for init_df1b2variable"
00381 << endl;
00382 ad_exit(1);
00383 }
00384
00385
00386
00387 ptr=trueptr;
00388 ptr-=lb;
00389 }
00390
00395 void init_df1b2vector::reallocate()
00396 {
00397 int mmin=indexmin();
00398 int mmax=indexmax();
00399 for (int i=mmin;i<=mmax;i++)
00400 {
00401 ptr[i].allocate();
00402 }
00403 }
00407 void init_df1b2vector::allocate(void)
00408 {
00409
00410 index_min = 0;
00411 index_max = -1;
00412 ncopies = NULL;
00413 trueptr = NULL;
00414 ptr = NULL;
00415 }
00419 init_df1b2vector::~init_df1b2vector()
00420 {
00421 if (ncopies)
00422 {
00423 if (*ncopies)
00424 (*ncopies)--;
00425 else
00426 {
00427 if (trueptr)
00428 {
00429 delete [] trueptr;
00430 trueptr = NULL;
00431 }
00432 delete ncopies;
00433 ncopies = NULL;
00434 }
00435 }
00436 }
00440 void init_df1b2vector::deallocate()
00441 {
00442 if (ncopies)
00443 {
00444 if (*ncopies)
00445 (*ncopies)--;
00446 else
00447 {
00448 delete [] trueptr;
00449 trueptr = NULL;
00450 delete ncopies;
00451 ncopies = NULL;
00452 }
00453 }
00454 }
00458 init_df1b2vector::init_df1b2vector(const init_df1b2vector& v)
00459 {
00460 ncopies = v.ncopies;
00461 if (v.ncopies)
00462 {
00463 (*ncopies)++;
00464 trueptr = v.trueptr;
00465 ptr = v.ptr;
00466 index_min = v.index_min;
00467 index_max = v.index_max;
00468 }
00469 else
00470 {
00471 allocate();
00472 }
00473
00474 }
00475
00480 double& value(const df1b2variable& _x)
00481 {
00482 ADUNCONST(df1b2variable,x)
00483 return *x.u;
00484 }
00485
00490 df1b2function2::df1b2function2(double (*_f)(double,double),
00491 double (*_df1)(double,double),double (*_df2)(double,double),
00492 double (*_d2f11)(double,double),
00493 double (*_d2f12)(double,double),
00494 double (*_d2f22)(double,double),
00495 double (*_d3f111)(double,double),
00496 double (*_d3f112)(double,double),
00497 double (*_d3f122)(double,double),
00498 double (*_d3f222)(double,double), const adstring& _s)
00499 {
00500 f=_f;
00501 df1=_df1; df2=_df2;
00502 d2f11=_d2f11; d2f12=_d2f12; d2f22=_d2f22;
00503 d3f111=_d3f111;
00504 d3f112=_d3f112;
00505 d3f122=_d3f122;
00506 d3f222=_d3f222;
00507 funname=_s;
00508 }
00509 typedef double (* PTDF)(double);
00510
00515 PTDF tan_address()
00516 {
00517 return &tan;
00518 }
00519
00524 df1b2variable df1b2function1::operator () (const df1b2variable& _x)
00525 {
00526 ADUNCONST(df1b2variable,x)
00527 df1b2variable z;
00528 double xu=*x.get_u();
00529 double * xd=x.get_u_dot();
00530 double * zd=z.get_u_dot();
00531 *z.get_u()=(*f)(xu);
00532 double dfx=(*df)(xu);
00533 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00534 {
00535 *zd++ =dfx * *xd++;
00536 }
00537
00538
00539
00540
00541
00542 if (!df1b2_gradlist::no_derivatives)
00543 {
00544 if ((void*)(f)==tan_address())
00545 f1b2gradlist->write_pass1x(&x,&z,this);
00546 else
00547 f1b2gradlist->write_pass1(&x,&z,this);
00548 }
00549 return z;
00550 }
00551
00556 df1b2variable df1b2function2::operator () (const df1b2variable& _x,
00557 const df1b2variable& _y)
00558 {
00559 ADUNCONST(df1b2variable,x)
00560 ADUNCONST(df1b2variable,y)
00561 df1b2variable z;
00562 double xu=*x.get_u();
00563 double yu=*y.get_u();
00564 double * xd=x.get_u_dot();
00565 double * yd=y.get_u_dot();
00566 double * zd=z.get_u_dot();
00567 *z.get_u()=(*f)(xu,yu);
00568 double dfx=(*df1)(xu,yu);
00569 double dfy=(*df2)(xu,yu);
00570 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00571 {
00572 *zd++ =dfx * *xd++ + dfy * *yd++;
00573 }
00574
00575
00576 if (!df1b2_gradlist::no_derivatives)
00577 f1b2gradlist->write_pass1(&x,&y,&z,this);
00578 return z;
00579 }
00580
00585 void df1b2_gradlist::reset(void)
00586 {
00587 ncount=0;
00588 list.reset();
00589 nlist.reset();
00590 list2.reset();
00591 nlist2.reset();
00592 list3.reset();
00593 nlist3.reset();
00594 }
00595
00600 df1b2_gradlist::df1b2_gradlist
00601 (
00602 unsigned int _bs, unsigned int _nbs,
00603 unsigned int _bs2, unsigned int _nbs2,
00604 unsigned int _bs3, unsigned int _nbs3,
00605 const adstring& _filename
00606 )
00607 {
00608 unsigned int bs=get_f1b2buffer_size("-l1");
00609 if (!bs) bs=_bs;
00610 list.allocate(bs,_filename);
00611
00612 unsigned int nbs=get_f1b2buffer_size("-nl1");
00613 if (!nbs) nbs=_nbs;
00614 nlist.allocate(nbs,"n"+_filename);
00615
00616 unsigned int bs2=get_f1b2buffer_size("-l2");
00617 if (!bs2) bs2=_bs2;
00618 list2.allocate(bs2,_filename+"2");
00619
00620 unsigned int nbs2=get_f1b2buffer_size("-nl2");
00621 if (!nbs2) nbs2=_nbs2;
00622 nlist2.allocate(nbs2,"n"+_filename+"2");
00623
00624 unsigned int bs3=get_f1b2buffer_size("-l3");
00625 if (!bs3) bs3=_bs3;
00626 list3.allocate(bs3,_filename+"3");
00627
00628 unsigned int nbs3=get_f1b2buffer_size("-nl3");
00629 if (!nbs3) nbs3=_nbs3;
00630 nlist3.allocate(nbs3,"n"+_filename+"3");
00631
00632 list3.set_noreadflag(1);
00633 nlist3.set_noreadflag(1);
00634
00635 ncount=0;
00636 }
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00652 smartlist::smartlist(unsigned int _bufsize,const adstring& _filename):
00653 sbptr(NULL)
00654 {
00655 #ifndef OPT_LIB
00656
00657 assert(sizeof(char) == 1);
00658 #endif
00659
00660 bufsize=_bufsize;
00661 filename=_filename;
00662 AD_ALLOCATE(buffer,char,bufsize,df1b2_gradlist)
00663 buffend=buffer+bufsize-1;
00664 bptr=buffer;
00665 fp = open((char*)filename,
00666 O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
00667 if (fp == -1)
00668 {
00669 cerr << "Error trying to open file " << filename
00670 << " in class smartlist " << endl;
00671 exit(1);
00672 }
00673 }
00674
00675 void ad_dstar::allocate(const unsigned int _n)
00676 {
00677 n = _n;
00678 }
00679
00684 ad_dstar::ad_dstar(void)
00685 {
00686 if (!n)
00687 {
00688 cerr << "need to initialize size in class ad_dstar" << endl;
00689 exit(1);
00690 }
00691 p = new double[n];
00692 }
00693
00698 void set_dependent_variable(const df1b2variable& _x)
00699 {
00700 df1b2variable& x=(df1b2variable&) (_x);
00701
00702 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00703 {
00704 x.u_dot_bar[i]=1.0;
00705 }
00706 }
00707
00712 dmatrix get_hessian(const init_df1b2vector& _x)
00713 {
00714 ADUNCONST(init_df1b2vector,x)
00715 #ifdef OPT_LIB
00716 int nvar = (int)df1b2variable::nvar;
00717 #else
00718 unsigned int _nvar=df1b2variable::nvar;
00719 assert(_nvar <= INT_MAX);
00720 int nvar = (int)_nvar;
00721 #endif
00722 dmatrix h(1,nvar,1,nvar);
00723 for (int i=1;i<=nvar;i++)
00724 {
00725 for (int j=1;j<=nvar;j++)
00726 {
00727 h(i,j)=x(i).u_bar[j-1];
00728 }
00729 }
00730 return h;
00731 }
00732
00733 typedef df1b2variable (*P_USER_FUNCTION)(const init_df1b2vector& x);
00734
00739 double d1F(P_USER_FUNCTION pu,const init_df1b2vector& _x,int i,double _delta)
00740 {
00741 ADUNCONST(init_df1b2vector,x)
00742 double delta=.3*_delta;
00743 double xsave=value(x(i));
00744 x(i)=xsave+delta;
00745 double fp=value(pu(x));
00746 x(i)=xsave-delta;
00747 double fm=value(pu(x));
00748 x(i)=xsave;
00749 double d1fa=(fp-fm)/(2.0*delta);
00750 x(i)=xsave+2.0*delta;
00751 fp=value(pu(x));
00752 x(i)=xsave-2.0*delta;
00753 fm=value(pu(x));
00754 x(i)=xsave;
00755 double d1fb=(fp-fm)/(4.0*delta);
00756 double d1f=(8.0*d1fa-d1fb)/7.0;
00757 return d1f;
00758 }
00759
00764 double d2F(P_USER_FUNCTION pu,const init_df1b2vector& _x,int i,int j,
00765 double delta)
00766 {
00767 ADUNCONST(init_df1b2vector,x)
00768 double xsave=value(x(i));
00769 x(i)=xsave+delta;
00770 double fp=d1F(pu,x,j,delta);
00771 x(i)=xsave-delta;
00772 double fm=d1F(pu,x,j,delta);
00773 double d1fa=(fp-fm)/(2.0*delta);
00774 x(i)=xsave+2.0*delta;
00775 fp=d1F(pu,x,j,delta);
00776 x(i)=xsave-2.0*delta;
00777 fm=d1F(pu,x,j,delta);
00778 x(i)=xsave;
00779 double d1fb=(fp-fm)/(4.0*delta);
00780 double d1f=(8.0*d1fa-d1fb)/7.0;
00781 return d1f;
00782 }
00783
00788 double d3F(P_USER_FUNCTION pu,const init_df1b2vector& _x,int i,int j,int k,
00789 double delta)
00790 {
00791 ADUNCONST(init_df1b2vector,x)
00792 double xsave=value(x(i));
00793 x(i)=xsave+delta;
00794 double fp=d2F(pu,x,j,k,delta);
00795 x(i)=xsave-delta;
00796 double fm=d2F(pu,x,j,k,delta);
00797 x(i)=xsave;
00798 double d1f=(fp-fm)/(2.0*delta);
00799 return d1f;
00800 }
00801
00806 dmatrix check_second_derivatives(const init_df1b2vector& x)
00807 {
00808 f1b2gradlist->set_no_derivatives();
00809 #ifdef OPT_LIB
00810 int nvar = (int)df1b2variable::nvar;
00811 #else
00812 unsigned int _nvar=df1b2variable::nvar;
00813 assert(_nvar <= INT_MAX);
00814 int nvar = (int)_nvar;
00815 #endif
00816 dmatrix h(1, nvar, 1, nvar);
00817
00818 h.initialize();
00819 for (int i=1;i<=init_df1b2variable::num_variables;i++)
00820 {
00821 for (int j=1;j<=init_df1b2variable::num_variables;j++)
00822 {
00823
00824 }
00825 }
00826 return h;
00827 }
00828
00833 d3_array check_third_derivatives(const init_df1b2vector& x)
00834 {
00835 f1b2gradlist->set_no_derivatives();
00836 #ifdef OPT_LIB
00837 int nvar = (int)df1b2variable::nvar;
00838 #else
00839 unsigned int _nvar=df1b2variable::nvar;
00840 assert(_nvar <= INT_MAX);
00841 int nvar = (int)_nvar;
00842 #endif
00843 d3_array h(1, nvar, 1, nvar, 1, nvar);
00844
00845 h.initialize();
00846 for (int i=1;i<=init_df1b2variable::num_variables;i++)
00847 {
00848 for (int j=1;j<=init_df1b2variable::num_variables;j++)
00849 {
00850 for (int k=1;k<=init_df1b2variable::num_variables;k++)
00851 {
00852
00853 }
00854 }
00855 }
00856 return h;
00857 }
00858
00859 #if defined(__DERCHECK__)
00860
00865 dercheck_info::dercheck_info(int _node_number,double _delta,int _index) :
00866 node_number(_node_number), delta(_delta), index(_index)
00867 {
00868 der_value=0.0;
00869 pass_number=0;
00870 counter=0;
00871 f1=0.0;
00872 f2=0.0;
00873 }
00874 dercheck_info * derchecker;
00875
00876 #endif
00877
00878
00879 re_objective_function_value * re_objective_function_value::pobjfun=0;
00880
00885 re_objective_function_value::re_objective_function_value(void)
00886 {
00887 pobjfun=this;
00888 }
00889
00894 re_objective_function_value::~re_objective_function_value()
00895 {
00896 pobjfun=0;
00897 }
00898
00903 re_objective_function_value& re_objective_function_value::operator =
00904 (const df1b2variable& v)
00905 {
00906 df1b2variable::operator = (v);
00907 return *this;
00908 }
00909
00914 re_objective_function_value& re_objective_function_value::operator =
00915 (double v)
00916 {
00917 df1b2variable::operator = (v);
00918 return *this;
00919 }
00920
00925 void re_objective_function_value::allocate(void)
00926 {
00927 df1b2variable::allocate();
00928 }
00929
00934 void re_objective_function_value::allocate(const char * s)
00935 {
00936 pobjfun=this;
00937 df1b2variable::allocate();
00938 }
00939
00940 #if !defined(OPT_LIB)
00941
00945 init_df1b2variable& init_df1b2vector::operator () (int i)
00946 {
00947 if (i < indexmin())
00948 {
00949 ADMB_ARRAY_BOUNDS_ERROR("Index too low",
00950 "init_df1b2variable& init_df1b2vector::operator () (int i)",
00951 indexmin(), indexmax(), i);
00952 }
00953 if (i > indexmax())
00954 {
00955 ADMB_ARRAY_BOUNDS_ERROR("Index too high",
00956 "init_df1b2variable& init_df1b2vector::operator () (int i)",
00957 indexmin(), indexmax(), i);
00958 }
00959 return ptr[i];
00960 }
00961
00966 init_df1b2variable& init_df1b2vector::operator [] (int i)
00967 {
00968 if (i < indexmin())
00969 {
00970 ADMB_ARRAY_BOUNDS_ERROR("Index too low",
00971 "init_df1b2variable& init_df1b2vector::operator [] (int i)",
00972 indexmin(), indexmax(), i);
00973 }
00974 if (i > indexmax())
00975 {
00976 ADMB_ARRAY_BOUNDS_ERROR("Index too high",
00977 "init_df1b2variable& init_df1b2vector::operator [] (int i)",
00978 indexmin(), indexmax(), i);
00979 }
00980 return ptr[i];
00981 }
00982 #endif
00983
00986 unsigned int get_f1b2buffer_size(const char* s)
00987 {
00988 unsigned int n = 0;
00989 int on1=-1;
00990 int nopt=0;
00991 if ( (on1=option_match(ad_comm::argc,ad_comm::argv,s,nopt))>-1)
00992 {
00993 if (!nopt)
00994 {
00995 cerr << "Usage " << s << " option needs integer -- ignored" << endl;
00996 }
00997 else
00998 {
00999 int i = atoi(ad_comm::argv[on1+1]);
01000 if (i > 0)
01001 {
01002 n = (unsigned int)i;
01003 }
01004 }
01005 }
01006 return n;
01007 }
01008
01013 df1b2variable::df1b2variable(const random_effects_bounded_vector_info& rebv)
01014 {
01015 df1b2variable& v= *(rebv.pv->v+rebv.i);
01016 if (v.ptr)
01017 {
01018 ptr=v.ptr;
01019 ncopies=v.ncopies;
01020 (*ncopies)++;
01021 u=v.u;
01022 u_dot=v.u_dot;
01023 u_bar=v.u_bar;
01024 u_dot_bar=v.u_dot_bar;
01025 u_tilde=v.u_tilde;
01026 u_dot_tilde=v.u_dot_tilde;
01027 u_bar_tilde=v.u_bar_tilde;
01028 u_dot_bar_tilde=v.u_dot_bar_tilde;
01029 }
01030 else
01031 {
01032 ptr=NULL;
01033 ncopies=NULL;
01034 u=NULL;
01035 u_dot=NULL;
01036 u_bar=NULL;
01037 u_dot_bar=NULL;
01038 u_tilde=NULL;
01039 u_dot_tilde=NULL;
01040 u_bar_tilde=NULL;
01041 u_dot_bar_tilde=NULL;
01042 }
01043 }