ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df1b2fn2.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include <cstring>
12 #if !defined(__BORLANDC__) && !defined(_MSC_VER)
13 #include <inttypes.h>
14 #endif
15 #include <df1b2fun.h>
16 #include "admb_messages.h"
17 #ifndef OPT_LIB
18  #include <cassert>
19  #include <climits>
20 #endif
21 
23 
24 //#define ADDEBUG_PRINT
25 #if defined(ADDEBUG_PRINT)
26  int addebug_count=0;
27 #endif
28 
29 //df1b2_gradlist * f1b2gradlist = NULL;
31 
32 char AD_allocation_error_message[]="Error: trying to allocate memory for ";
33 
34 unsigned int get_f1b2buffer_size(const char* s);
35 
36 #if defined(CHECK_COUNT)
37  int df1b2_gradlist::ncount_check=-1;
38 #endif
39 
41 
46 df1b2function1::df1b2function1(double (*_f)(double),double (*_df)(double),
47  double (*_d2f)(double),double (*_d3f)(double), const adstring& _s )
48 {
49  f=_f;
50  df=_df;
51  d2f=_d2f;
52  d3f=_d3f;
53  funname=_s;
54 }
55 
61 {
62  if (p) delete []p;
63  p = 0;
64 }
65 
71 {
72  return get_blocksize(nvar);
73 }
74 
79 unsigned int df1b2variable::get_blocksize(const unsigned int n)
80 {
81  return 6*n+5;
82  //return 6*n+4;
83 }
84 
90 {
92  pool->set_size(sizeof(double)*blocksize);
94 }
95 
96 //init_df1b2variable * init_df1b2variable::list[max_num_init_df1b2variable];
98 unsigned int df1b2variable::nvar = 0;
101 unsigned int df1b2variable::blocksize=0;
105 unsigned int ad_dstar::n=0;
106 
107 void ad_read_pass2(void);
108 // should inline this
109 #if !defined(__BORLANDC__)
110 int adptr_diff(void* x, void* y)
111 {
112  intptr_t a = (intptr_t)x;
113  intptr_t b = (intptr_t)y;
114  ptrdiff_t diff = a - b;
115 #ifndef OPT_LIB
116  assert(diff <= INT_MAX);
117 #endif
118  return (int)diff;
119 }
120 #endif
121 
122 #if defined(__CHECK_MEMORY__)
123  int sanity_flag=0;
124 #endif
125 
130 {
131 #if defined(__CHECK_MEMORY__)
132  if (sanity_flag)
133  {
134  df1b2variable::pool->sanity_check();
135  }
136 #endif
137  unsigned int nvar=((twointsandptr*)ptr)->ptr->nvar;
138  initialize(nvar);
139 }
140 
146 void df1b2variable::initialize(const unsigned int n)
147 {
148  //int bs=get_blocksize(n);
149  //for (double * tmp=ptr+2;tmp<ptr+bs-1;*tmp++=0);
150  size_t nbytes = (get_blocksize(n) - 2) * sizeof(double);
151  memset(ptr + 2, 0, nbytes);
152 }
153 
159  {
160  //int j;
161  double uvalue=*get_u();
162  initialize();
163  int nder=maxder-minder+1;
164  for (int i=0;i<nder;i++)
165  {
166  u_dot[i]=0.0;
167  }
168  if (ind_index>=minder && ind_index<=maxder)
169  {
170  int offset= ind_index-minder;
171  u_dot[offset]=1.0;
172  }
173  *get_u()=uvalue;
174  }
175 
181  {
182  //int nc=*ncopies;
183  initialize();
184  //*ncopies=nc;
185  if (ind_index>=minder && ind_index<=maxder)
186  {
187  int offset= ind_index-minder;
188  u_dot[offset]=1.0;
189  }
190  get_ind_index()=-1;
191  *u=d;
192  }
193 
199  {
200 #if defined(__CHECK_MEMORY__)
201  if (pchecker)
202  {
203  if (v.ptr == pchecker)
204  {
205  cout << " copy constructor called " << endl;
206  }
207  }
208 #endif
209  if (v.ptr)
210  {
211  ptr=v.ptr;
212  ncopies=v.ncopies;
213  (*ncopies)++;
214  u=v.u;
215  u_dot=v.u_dot;
216  u_bar=v.u_bar;
218  u_tilde=v.u_tilde;
222  }
223  else
224  {
225  ptr=NULL;
226  ncopies=NULL;
227  u=NULL;
228  u_dot=NULL;
229  u_bar=NULL;
230  u_dot_bar=NULL;
231  u_tilde=NULL;
232  u_dot_tilde=NULL;
233  u_bar_tilde=NULL;
234  u_dot_bar_tilde=NULL;
235  }
236  }
237 
238  adkludge1 * adkludgexxx;
239 
241 
247  {
248  ++num_variables;
249  /*
250  if (list==0)
251  {
252  list =new PINIT_DF1B2VARIABLE[max_num_init_df1b2variable];
253  }
254  if (++num_variables>= max_num_init_df1b2variable)
255  {
256  cerr << "Need to increase the maximum number of init_df1b2variables"
257  << endl << "Use command line option -mni N" << endl;
258  }
259 
260  if (num_variables>=df1b2variable::nvar)
261  {
262  cerr << "Maximum number of independent variables exceeded"
263  << endl;
264  cerr << "current max is " << df1b2variable::nvar << endl;
265  }
266  list[num_variables]=this;
267  */
269  *get_u()=v;
271  {
272  //int offset= num_variables-minder;
273  //u_dot[offset]=1.0;
274  }
275  }
280 {
281  deallocate();
282 }
287 {
288  if (ptr)
289  {
290 #if defined(__CHECK_MEMORY__)
291  if (pchecker)
292  {
293  if (ptr == pchecker)
294  {
295  cout << "destructor called " << endl;
296  }
297  }
298 #endif
299  if (ncopies && *ncopies)
300  {
301  (*ncopies)--;
302  }
303  else
304  {
305  if (!df1b2_gradlist::no_derivatives)
307  ((twointsandptr*)ptr)->ptr->free(ptr);
308 
309  ptr = 0;
310  }
311  }
312 }
313 
319  {
320  int mmin=indexmin();
321  int mmax=indexmax();
322  if (v.indexmin() != mmin || v.indexmax() != mmax )
323  {
324  cerr << "incompatible shape in "
325  "init_df1b2vector::set_value(const dvector& v)" << endl;
326  }
327 
328  for (int i=mmin;i<=mmax;i++)
329  {
330  (*this)(i)=v(i);
331  }
332  }
333 
338 {
339  allocate();
340 }
345 {
346  allocate(lb, ub);
347 }
348 
351 void init_df1b2vector::allocate(int lb,int ub)
352 {
353  init_df1b2variable::num_variables= 0;
354  index_min=lb;
355  index_max=ub;
356  ncopies=new int;
357  *ncopies=0;
358  int size = ub < lb ? 0 : indexmax() - indexmin() + 1;
359  if (init_df1b2variable::list == 0)
360  {
363 
364  init_df1b2variable::list = new PINIT_DF1B2VARIABLE[static_cast<unsigned int>(
366  if (init_df1b2variable::list == 0)
367  {
368  cerr << "Error allocating memory for init_df1b2variable::list" << endl;
369  ad_exit(1);
370  }
371  }
372 
373 // ****************************************
374  trueptr = new init_df1b2variable[static_cast<unsigned int>(size)];
375  if (trueptr == 0)
376  {
377  cerr << "Error allocating memory for init_df1b2variable" << endl;
378  ad_exit(1);
379  }
380  //AD_ALLOCATE(trueptr,init_df1b2variable,size,df1b2_gradlist)
381 // ****************************************
382 
383  ptr = trueptr;
384  ptr -= lb;
385 }
386 
392  {
393  int mmin=indexmin();
394  int mmax=indexmax();
395  for (int i=mmin;i<=mmax;i++)
396  {
397  ptr[i].allocate();
398  }
399  }
404 {
405  //deallocate(); a// don;t know why this was ever here DF 6june09
406  index_min = 0;
407  index_max = -1;
408  ncopies = NULL;
409  trueptr = NULL;
410  ptr = NULL;
411 }
416 {
417  if (ncopies)
418  {
419  if (*ncopies)
420  (*ncopies)--;
421  else
422  {
423  if (trueptr)
424  {
425  delete [] trueptr;
426  trueptr = NULL;
427  }
428  delete ncopies;
429  ncopies = NULL;
430  }
431  }
432 }
437 {
438  if (ncopies)
439  {
440  if (*ncopies)
441  (*ncopies)--;
442  else
443  {
444  delete [] trueptr;
445  trueptr = NULL;
446  delete ncopies;
447  ncopies = NULL;
448  }
449  }
450 }
455 {
456  ncopies = v.ncopies;
457  if (v.ncopies)
458  {
459  (*ncopies)++;
460  trueptr = v.trueptr;
461  ptr = v.ptr;
462  index_min = v.index_min;
463  index_max = v.index_max;
464  }
465  else
466  {
467  allocate();
468  }
469  //cout << *ncopies << endl;
470 }
471 
476  double& value(const df1b2variable& _x)
477  {
479  return *x.u;
480  }
481 
486  df1b2function2::df1b2function2(double (*_f)(double,double),
487  double (*_df1)(double,double),double (*_df2)(double,double),
488  double (*_d2f11)(double,double),
489  double (*_d2f12)(double,double),
490  double (*_d2f22)(double,double),
491  double (*_d3f111)(double,double),
492  double (*_d3f112)(double,double),
493  double (*_d3f122)(double,double),
494  double (*_d3f222)(double,double), const adstring& _s)
495  {
496  f=_f;
497  df1=_df1; df2=_df2;
498  d2f11=_d2f11; d2f12=_d2f12; d2f22=_d2f22;
499  d3f111=_d3f111;
500  d3f112=_d3f112;
501  d3f122=_d3f122;
502  d3f222=_d3f222;
503  funname=_s;
504  }
505  typedef double (* PTDF)(double);
506 
512  {
513  return &tan;
514  }
515 
521  {
523  df1b2variable z;
524  double xu=*x.get_u();
525  double * xd=x.get_u_dot();
526  double * zd=z.get_u_dot();
527  *z.get_u()=(*f)(xu);
528  double dfx=(*df)(xu);
529  for (unsigned int i=0;i<df1b2variable::nvar;i++)
530  {
531  *zd++ =dfx * *xd++;
532  }
533 
534  // WRITE WHATEVER ON TAPE
535  //df1b2tape->set_tapeinfo_header(&x,&z,this,xd);
536  // save stuff for first reverse pass
537  // need &x, &z, this,
538  if (!df1b2_gradlist::no_derivatives)
539  {
540  if ((void*)(f)==tan_address())
541  f1b2gradlist->write_pass1x(&x,&z,this);
542  else
543  f1b2gradlist->write_pass1(&x,&z,this);
544  }
545  return z;
546  }
547 
553  const df1b2variable& _y)
554  {
557  df1b2variable z;
558  double xu=*x.get_u();
559  double yu=*y.get_u();
560  double * xd=x.get_u_dot();
561  double * yd=y.get_u_dot();
562  double * zd=z.get_u_dot();
563  *z.get_u()=(*f)(xu,yu);
564  double dfx=(*df1)(xu,yu);
565  double dfy=(*df2)(xu,yu);
566  for (unsigned int i=0;i<df1b2variable::nvar;i++)
567  {
568  *zd++ =dfx * *xd++ + dfy * *yd++;
569  }
570 
571  // WRITE WHATEVER ON TAPE
572  if (!df1b2_gradlist::no_derivatives)
573  f1b2gradlist->write_pass1(&x,&y,&z,this);
574  return z;
575  }
576 
582 {
583  ncount=0;
584  list.reset();
585  nlist.reset();
586  list2.reset();
587  nlist2.reset();
588  list3.reset();
589  nlist3.reset();
590 }
591 
597 (
598  unsigned int _bs, unsigned int _nbs,
599  unsigned int _bs2, unsigned int _nbs2,
600  unsigned int _bs3, unsigned int _nbs3,
601  const adstring& _filename
602 )
603 {
604  unsigned int bs=get_f1b2buffer_size("-l1");
605  if (!bs) bs=_bs;
606  list.allocate(bs,_filename);
607 
608  unsigned int nbs=get_f1b2buffer_size("-nl1");
609  if (!nbs) nbs=_nbs;
610  nlist.allocate(nbs,"n"+_filename);
611 
612  unsigned int bs2=get_f1b2buffer_size("-l2");
613  if (!bs2) bs2=_bs2;
614  list2.allocate(bs2,_filename+"2");
615 
616  unsigned int nbs2=get_f1b2buffer_size("-nl2");
617  if (!nbs2) nbs2=_nbs2;
618  nlist2.allocate(nbs2,"n"+_filename+"2");
619 
620  unsigned int bs3=get_f1b2buffer_size("-l3");
621  if (!bs3) bs3=_bs3;
622  list3.allocate(bs3,_filename+"3");
623 
624  unsigned int nbs3=get_f1b2buffer_size("-nl3");
625  if (!nbs3) nbs3=_nbs3;
626  nlist3.allocate(nbs3,"n"+_filename+"3");
627 
628  list3.set_noreadflag(1);
629  nlist3.set_noreadflag(1);
630 
631  ncount=0;
632 }
633 /*
634 smartlist::smartlist(void)
635 {
636  bufsize=0;
637  filename=0;
638  buffer=0;
639  buffend=0;
640  bptr=buffer;
641  fp=-1;
642 }
643 */
644 
648 smartlist::smartlist(unsigned int _bufsize,const adstring& _filename):
649  sbptr(NULL)
650 {
651 #ifndef OPT_LIB
652  //cerr << "need to modify smartlist class for multibyte char" << endl;
653  assert(sizeof(char) == 1);
654 #endif
655 
656  bufsize=_bufsize;
657  filename=_filename;
660  bptr=buffer;
661 #ifdef _MSC_VER
662  fp = open((char*)filename,
663  O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
664 #else
665  fp = open((char*)filename,
666  O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
667 #endif
668  if (fp == -1)
669  {
670  cerr << "Error trying to open file " << filename
671  << " in class smartlist " << endl;
672  ad_exit(1);
673  }
674 }
675 
676 void ad_dstar::allocate(const unsigned int _n)
677 {
678  n = _n;
679 }
680 
686 {
687  if (!n)
688  {
689  cerr << "need to initialize size in class ad_dstar" << endl;
690  ad_exit(1);
691  }
692  p = new double[n];
693 }
694 
700 {
701  df1b2variable& x=(df1b2variable&) (_x);
702  //cout << "dep " << int(x.u) << endl;
703  for (unsigned int i=0;i<df1b2variable::nvar;i++)
704  {
705  x.u_dot_bar[i]=1.0;
706  }
707 }
708 
714 {
716 #ifdef OPT_LIB
717  int nvar = (int)df1b2variable::nvar;
718 #else
719  unsigned int _nvar=df1b2variable::nvar;
720  assert(_nvar <= INT_MAX);
721  int nvar = (int)_nvar;
722 #endif
723  dmatrix h(1,nvar,1,nvar);
724  for (int i=1;i<=nvar;i++)
725  {
726  for (int j=1;j<=nvar;j++)
727  {
728  h(i,j)=x(i).u_bar[j-1];
729  }
730  }
731  return h;
732 }
733 
735 
740 double d1F(P_USER_FUNCTION pu,const init_df1b2vector& _x,int i,double _delta)
741 {
743  double delta=.3*_delta;
744  double xsave=value(x(i));
745  x(i)=xsave+delta;
746  double fp=value(pu(x));
747  x(i)=xsave-delta;
748  double fm=value(pu(x));
749  x(i)=xsave;
750  double d1fa=(fp-fm)/(2.0*delta);
751  x(i)=xsave+2.0*delta;
752  fp=value(pu(x));
753  x(i)=xsave-2.0*delta;
754  fm=value(pu(x));
755  x(i)=xsave;
756  double d1fb=(fp-fm)/(4.0*delta);
757  double d1f=(8.0*d1fa-d1fb)/7.0;
758  return d1f;
759 }
760 
765 double d2F(P_USER_FUNCTION pu,const init_df1b2vector& _x,int i,int j,
766  double delta)
767 {
769  double xsave=value(x(i));
770  x(i)=xsave+delta;
771  double fp=d1F(pu,x,j,delta);
772  x(i)=xsave-delta;
773  double fm=d1F(pu,x,j,delta);
774  double d1fa=(fp-fm)/(2.0*delta);
775  x(i)=xsave+2.0*delta;
776  fp=d1F(pu,x,j,delta);
777  x(i)=xsave-2.0*delta;
778  fm=d1F(pu,x,j,delta);
779  x(i)=xsave;
780  double d1fb=(fp-fm)/(4.0*delta);
781  double d1f=(8.0*d1fa-d1fb)/7.0;
782  return d1f;
783 }
784 
789 double d3F(P_USER_FUNCTION pu,const init_df1b2vector& _x,int i,int j,int k,
790  double delta)
791 {
793  double xsave=value(x(i));
794  x(i)=xsave+delta;
795  double fp=d2F(pu,x,j,k,delta);
796  x(i)=xsave-delta;
797  double fm=d2F(pu,x,j,k,delta);
798  x(i)=xsave;
799  double d1f=(fp-fm)/(2.0*delta);
800  return d1f;
801 }
802 
808 {
810 #ifdef OPT_LIB
811  int nvar = (int)df1b2variable::nvar;
812 #else
813  unsigned int _nvar=df1b2variable::nvar;
814  assert(_nvar <= INT_MAX);
815  int nvar = (int)_nvar;
816 #endif
817  dmatrix h(1, nvar, 1, nvar);
818  //const double delta=1.e-3;
819  h.initialize();
820  for (int i=1;i<=init_df1b2variable::num_variables;i++)
821  {
822  for (int j=1;j<=init_df1b2variable::num_variables;j++)
823  {
824  //h(i,j)=d2F(user_function,x,i,j,delta);
825  }
826  }
827  return h;
828 }
829 
835 {
837 #ifdef OPT_LIB
838  int nvar = (int)df1b2variable::nvar;
839 #else
840  unsigned int _nvar=df1b2variable::nvar;
841  assert(_nvar <= INT_MAX);
842  int nvar = (int)_nvar;
843 #endif
844  d3_array h(1, nvar, 1, nvar, 1, nvar);
845  //const double delta=2.e-4;
846  h.initialize();
847  for (int i=1;i<=init_df1b2variable::num_variables;i++)
848  {
849  for (int j=1;j<=init_df1b2variable::num_variables;j++)
850  {
851  for (int k=1;k<=init_df1b2variable::num_variables;k++)
852  {
853  //h(i,j,k)=d3F(user_function,x,i,j,k,delta);
854  }
855  }
856  }
857  return h;
858 }
859 
860 #if defined(__DERCHECK__)
861 
866 dercheck_info::dercheck_info(int _node_number,double _delta,int _index) :
867  node_number(_node_number), delta(_delta), index(_index)
868 {
869  der_value=0.0;
870  pass_number=0;
871  counter=0;
872  f1=0.0;
873  f2=0.0;
874 }
875 dercheck_info * derchecker;
876 
877 #endif
878 
879 
881 
887 {
888  pobjfun=this;
889 }
890 
896 {
897  pobjfun=0;
898 }
899 
904 re_objective_function_value& re_objective_function_value::operator =
905  (const df1b2variable& v)
906 {
908  return *this;
909 }
910 
915 re_objective_function_value& re_objective_function_value::operator =
916  (double v)
917 {
919  return *this;
920 }
921 
927 {
929 }
930 
936 {
937  pobjfun=this;
939 }
940 
941 #if !defined(OPT_LIB)
942 
947 {
948  if (i < indexmin())
949  {
950  ADMB_ARRAY_BOUNDS_ERROR("Index too low",
951  "init_df1b2variable& init_df1b2vector::operator () (int i)",
952  indexmin(), indexmax(), i);
953  }
954  if (i > indexmax())
955  {
956  ADMB_ARRAY_BOUNDS_ERROR("Index too high",
957  "init_df1b2variable& init_df1b2vector::operator () (int i)",
958  indexmin(), indexmax(), i);
959  }
960  return ptr[i];
961 }
962 
968 {
969  if (i < indexmin())
970  {
971  ADMB_ARRAY_BOUNDS_ERROR("Index too low",
972  "init_df1b2variable& init_df1b2vector::operator [] (int i)",
973  indexmin(), indexmax(), i);
974  }
975  if (i > indexmax())
976  {
977  ADMB_ARRAY_BOUNDS_ERROR("Index too high",
978  "init_df1b2variable& init_df1b2vector::operator [] (int i)",
979  indexmin(), indexmax(), i);
980  }
981  return ptr[i];
982 }
983 #endif
984 
987 unsigned int get_f1b2buffer_size(const char* s)
988 {
989  unsigned int n = 0;
990  int on1=-1;
991  int nopt=0;
992  if ( (on1=option_match(ad_comm::argc,ad_comm::argv,s,nopt))>-1)
993  {
994  if (!nopt)
995  {
996  cerr << "Usage " << s << " option needs integer -- ignored" << endl;
997  }
998  else
999  {
1000  int i = atoi(ad_comm::argv[on1+1]);
1001  if (i > 0)
1002  {
1003  n = (unsigned int)i;
1004  }
1005  }
1006  }
1007  return n;
1008 }
1009 
1015 {
1016  df1b2variable& v= *(rebv.pv->v+rebv.i);
1017  if (v.ptr)
1018  {
1019  ptr=v.ptr;
1020  ncopies=v.ncopies;
1021  (*ncopies)++;
1022  u=v.u;
1023  u_dot=v.u_dot;
1024  u_bar=v.u_bar;
1025  u_dot_bar=v.u_dot_bar;
1026  u_tilde=v.u_tilde;
1030  }
1031  else
1032  {
1033  ptr=NULL;
1034  ncopies=NULL;
1035  u=NULL;
1036  u_dot=NULL;
1037  u_bar=NULL;
1038  u_dot_bar=NULL;
1039  u_tilde=NULL;
1040  u_dot_tilde=NULL;
1041  u_bar_tilde=NULL;
1042  u_dot_bar_tilde=NULL;
1043  }
1044 }
init_df1b2vector(void)
Default constructor.
Definition: df1b2fn2.cpp:337
char * buffer
Definition: df1b2fun.h:504
void ad_read_pass2(void)
Description not yet available.
Definition: df1b2f12.cpp:70
static adpool * pool
Definition: df1b2fun.h:273
double(* d3f222)(double, double)
Definition: df1b2fun.h:443
double(* df)(double)
Definition: df1b2fun.h:411
d3_array tan(const d3_array &arr3)
Returns d3_array results with computed tan from elements in arr3.
Definition: d3arr2a.cpp:73
double(* PTDF)(double)
Definition: df1b2fn2.cpp:505
df1b2_gradlist * f1b2gradlist
Definition: df1b2glo.cpp:49
double(* d3f122)(double, double)
Definition: df1b2fun.h:442
void set_dependent_variable(const df1b2variable &_x)
Description not yet available.
Definition: df1b2fn2.cpp:699
unsigned int get_f1b2buffer_size(const char *s)
Get f1b2buffer size from commandline options.
Definition: df1b2fn2.cpp:987
int indexmax(void) const
Definition: df1b2fun.h:389
static void set_no_derivatives(void)
Definition: df1b2fun.h:760
double * p
Definition: df1b2fun.h:845
static do_naught_kludge do_naught_kludge_a
Definition: df1b2fun.h:1471
void allocate(void)
Description not yet available.
Definition: df1b2fn5.cpp:126
Description not yet available.
Definition: df1b2fun.h:1608
init_df1b2variable * ptr
Definition: df1b2fun.h:379
double * u_bar_tilde
Definition: df1b2fun.h:201
char AD_allocation_error_message[]
Definition: df1b2fn2.cpp:32
double * u_bar
Definition: df1b2fun.h:197
init_df1b2variable(double v=0.0)
Description not yet available.
Definition: df1b2fn2.cpp:246
df1b2variable & operator=(const df3_one_variable &v)
Definition: df3fun.cpp:779
double * get_u() const
Definition: df1b2fun.h:228
smartlist(unsigned int bufsize, const adstring &filename)
Constructor.
Definition: df1b2fn2.cpp:648
virtual ~df1b2variable()
Destructor.
Definition: df1b2fn2.cpp:279
static unsigned int n
Definition: df1b2fun.h:843
#define x
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
double(* d3f111)(double, double)
Definition: df1b2fun.h:440
re_df1b2_init_bounded_vector * pv
Definition: df1b2fun.h:1610
init_df1b2variable & operator()(int i)
Definition: df1b2fun.h:392
double(* d3f112)(double, double)
Definition: df1b2fun.h:441
static char ** argv
Definition: fvar.hpp:8866
static void set_blocksize(void)
Description not yet available.
Definition: df1b2fn2.cpp:89
static int passnumber
Definition: df1b2fun.h:289
double(* f)(double, double)
Definition: df1b2fun.h:434
df1b2_gradlist(unsigned int bufsize, unsigned int nbufsize, unsigned int bufsize1, unsigned int nbufsize1, unsigned int bufsize2, unsigned int nbufsize2, const adstring &filename)
Description not yet available.
Definition: df1b2fn2.cpp:597
double(* d2f22)(double, double)
Definition: df1b2fun.h:439
static re_objective_function_value * pobjfun
Definition: df1b2fun.h:1693
adstring filename
Definition: df1b2fun.h:509
int adptr_diff(void *x, void *y)
Definition: df1b2fn2.cpp:110
void reset(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: df1b2f13.cpp:22
exitptr ad_exit
Definition: gradstrc.cpp:53
void allocate(void)
Do not allocate, but just initialize class members.
Definition: df1b2fn2.cpp:403
#define AD_ALLOCATE(ptr, type, n, classname)
Definition: df1b2fun.h:179
Description not yet available.
Definition: df1b2fun.h:745
char * bptr
Definition: df1b2fun.h:506
static init_df1b2variable ** list
Definition: df1b2fun.h:363
double * u_tilde
Definition: df1b2fun.h:199
static unsigned int get_nvar()
Definition: df1b2fun.h:298
void set_u_dot(void)
Description not yet available.
Definition: df1b2fn2.cpp:158
df1b2function2(double(*_f)(double, double), double(*_df1)(double, double), double(*_df2)(double, double), double(*d2f11)(double, double), double(*d2f12)(double, double), double(*d2f22)(double, double), double(*_d3f111)(double, double), double(*_d3f112)(double, double), double(*_d3f122)(double, double), double(*_d3f222)(double, double), const adstring &funame="unnamed")
Description not yet available.
Definition: df1b2fn2.cpp:486
static int maxder
Definition: df1b2fun.h:292
adkludge1 * adkludgexxx
Definition: df1b2fn2.cpp:238
Description not yet available.
Definition: df1b2fun.h:266
int atoi(adstring &s)
Returns a integer converted from input s.
Definition: atoi.cpp:20
void set_size(const size_t)
Set size of adpool.
Definition: adpool.cpp:304
Description not yet available.
Definition: adpool.h:59
fixed_smartlist nlist
Definition: df1b2fun.h:754
double(* f)(double)
Definition: df1b2fun.h:410
~init_df1b2vector()
Destructor.
Definition: df1b2fn2.cpp:415
double * get_u_dot() const
Definition: df1b2fun.h:229
void deallocate(void)
If no other copies exist, free df1b2variable::ptr.
Definition: df1b2fn2.cpp:286
double * ptr
Definition: df1b2fun.h:269
int fp
Definition: df1b2fun.h:510
double * u_dot_bar_tilde
Definition: df1b2fun.h:202
unsigned int bufsize
Definition: df1b2fun.h:508
void operator=(double x)
Description not yet available.
Definition: df1b2fn2.cpp:180
df1b2variable operator()(const df1b2variable &x)
Description not yet available.
Definition: df1b2fn2.cpp:520
~ad_dstar(void)
Description not yet available.
Definition: df1b2fn2.cpp:60
void reset(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: df1b2f10.cpp:22
adstring funname
Definition: df1b2fun.h:444
prnstream & endl(prnstream &)
double * u_dot_bar
Definition: df1b2fun.h:198
test_smartlist list
Definition: df1b2fun.h:753
int max_num_init_df1b2variable
Definition: df1b2fn2.cpp:30
void allocate(void)
Description not yet available.
Definition: df1b2fn2.cpp:926
dmatrix check_second_derivatives(const init_df1b2vector &x)
Description not yet available.
Definition: df1b2fn2.cpp:807
#define O_BINARY
Definition: fvar.hpp:163
df1b2variable operator()(const df1b2variable &x, const df1b2variable &y)
Description not yet available.
Definition: df1b2fn2.cpp:552
fixed_smartlist2 nlist3
Definition: df1b2fun.h:758
static int argc
Definition: fvar.hpp:8863
static int no_derivatives
Definition: df1b2fun.h:759
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
fixed_smartlist2 nlist2
Definition: df1b2fun.h:756
static int num_variables
Definition: df1b2fun.h:362
init_df1b2variable * PINIT_DF1B2VARIABLE
Definition: df1b2fn2.cpp:240
ad_dstar(void)
Description not yet available.
Definition: df1b2fn2.cpp:685
double(* d2f11)(double, double)
Definition: df1b2fun.h:437
double(* df2)(double, double)
Definition: df1b2fun.h:436
dmatrix get_hessian(const init_df1b2vector &_x)
Description not yet available.
Definition: df1b2fn2.cpp:713
double d2F(P_USER_FUNCTION pu, const init_df1b2vector &_x, int i, int j, double delta)
Description not yet available.
Definition: df1b2fn2.cpp:765
d3_array check_third_derivatives(const init_df1b2vector &x)
Description not yet available.
Definition: df1b2fn2.cpp:834
static unsigned int blocksize
Definition: df1b2fun.h:293
void reallocate(void)
Description not yet available.
Definition: df1b2fn2.cpp:391
void * pchecker
Description not yet available.
Definition: fvar.hpp:2819
double d3F(P_USER_FUNCTION pu, const init_df1b2vector &_x, int i, int j, int k, double delta)
Description not yet available.
Definition: df1b2fn2.cpp:789
adstring funname
Definition: df1b2fun.h:414
char * buffend
Definition: df1b2fun.h:505
#define ADMB_ARRAY_BOUNDS_ERROR(message, function, lower_bounds, upper_bounds, index)
Definition: admb_messages.h:47
init_df1b2variable * trueptr
Definition: df1b2fun.h:378
int option_match(int argc, char *argv[], const char *string)
Checks if the program has been invoked with a particular command line argument (&quot;string&quot;).
Definition: optmatch.cpp:25
double(* d2f12)(double, double)
Definition: df1b2fun.h:438
int write_pass1(const df1b2variable *px, const df1b2variable *py, df1b2variable *pz, df1b2function2 *pf)
Description not yet available.
Definition: df1b2f12.cpp:17
void reset(void)
Definition: df1b2fun.h:702
re_objective_function_value(void)
Description not yet available.
Definition: df1b2fn2.cpp:886
test_smartlist list3
Definition: df1b2fun.h:757
static void allocate(const unsigned int _n)
Definition: df1b2fn2.cpp:676
void initialize(int sl, int sh, int nrl, const ivector &nrh, int ncl, const ivector &nch)
double(* d2f)(double)
Definition: df1b2fun.h:412
void initialize(void)
Initialize.
Definition: df1b2fn2.cpp:129
Description not yet available.
Definition: df1b2fun.h:373
double d1F(P_USER_FUNCTION pu, const init_df1b2vector &_x, int i, double _delta)
Description not yet available.
Definition: df1b2fn2.cpp:740
static unsigned int get_blocksize(void)
Description not yet available.
Definition: df1b2fn2.cpp:70
static unsigned int nvar
Definition: df1b2fun.h:290
void set_value(const dvector &)
Description not yet available.
Definition: df1b2fn2.cpp:318
int write_pass1x(const df1b2variable *_px, df1b2variable *pz, df1b2function1 *pf)
Description not yet available.
Definition: df1b2f27.cpp:30
Description not yet available.
Definition: df1b2fun.h:79
PTDF tan_address()
Description not yet available.
Definition: df1b2fn2.cpp:511
static int minder
Definition: df1b2fun.h:291
~re_objective_function_value()
Description not yet available.
Definition: df1b2fn2.cpp:895
double * u_dot_tilde
Definition: df1b2fun.h:200
init_df1b2variable & operator[](int i)
Definition: df1b2fun.h:393
int & get_ind_index()
Definition: df1b2fun.h:236
Description not yet available.
void deallocate(void)
Similar to destructor.
Definition: df1b2fn2.cpp:436
df1b2variable(void)
Default constructor.
Definition: df1b2fn5.cpp:81
Description not yet available.
Definition: df1b2fun.h:357
short int * ncopies
Definition: df1b2fun.h:304
df1b2function1(double(*_f)(double), double(*_df)(double), double(*d2f)(double), double(*_d3f)(double), const adstring &s="unnamed")
Description not yet available.
Definition: df1b2fn2.cpp:46
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
double * u
Definition: df1b2fun.h:195
#define max(a, b)
Definition: cbivnorm.cpp:189
double(* df1)(double, double)
Definition: df1b2fun.h:435
Description not yet available.
Definition: fvar.hpp:3727
int indexmin(void) const
Definition: df1b2fun.h:388
double(* d3f)(double)
Definition: df1b2fun.h:413
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat7.cpp:12
int write_save_pass2_tilde_values(const df1b2variable *px)
Description not yet available.
Definition: df1b2fn7.cpp:32
void reset(void)
Description not yet available.
Definition: df1b2fn2.cpp:581
test_smartlist list2
Definition: df1b2fun.h:755
double * u_dot
Definition: df1b2fun.h:196
Description not yet available.
Definition: df1b2fun.h:1393
df1b2variable(* P_USER_FUNCTION)(const init_df1b2vector &x)
Definition: df1b2fn2.cpp:734
unsigned int nvar
Definition: adpool.h:77