12 #if !defined(__BORLANDC__) && !defined(_MSC_VER)
25 #if defined(ADDEBUG_PRINT)
36 #if defined(CHECK_COUNT)
37 int df1b2_gradlist::ncount_check=-1;
47 double (*_d2f)(
double),
double (*_d3f)(
double),
const adstring& _s )
109 #if !defined(__BORLANDC__)
112 intptr_t a = (intptr_t)x;
113 intptr_t b = (intptr_t)y;
114 ptrdiff_t diff = a - b;
116 assert(diff <= INT_MAX);
122 #if defined(__CHECK_MEMORY__)
131 #if defined(__CHECK_MEMORY__)
134 df1b2variable::pool->sanity_check();
151 memset(
ptr + 2, 0, nbytes);
161 double uvalue=*
get_u();
164 for (
int i=0;i<nder;i++)
200 #if defined(__CHECK_MEMORY__)
205 cout <<
" copy constructor called " <<
endl;
290 #if defined(__CHECK_MEMORY__)
295 cout <<
"destructor called " <<
endl;
305 if (!df1b2_gradlist::no_derivatives)
324 cerr <<
"incompatible shape in "
325 "init_df1b2vector::set_value(const dvector& v)" <<
endl;
328 for (
int i=mmin;i<=mmax;i++)
353 init_df1b2variable::num_variables= 0;
359 if (init_df1b2variable::list == 0)
364 init_df1b2variable::list =
new PINIT_DF1B2VARIABLE[
static_cast<unsigned int>(
366 if (init_df1b2variable::list == 0)
368 cerr <<
"Error allocating memory for init_df1b2variable::list" <<
endl;
377 cerr <<
"Error allocating memory for init_df1b2variable" <<
endl;
395 for (
int i=mmin;i<=mmax;i++)
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)
505 typedef double (*
PTDF)(double);
524 double xu=*
x.get_u();
525 double * xd=
x.get_u_dot();
528 double dfx=(*df)(xu);
538 if (!df1b2_gradlist::no_derivatives)
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();
563 *z.
get_u()=(*f)(xu,yu);
564 double dfx=(*df1)(xu,yu);
565 double dfy=(*df2)(xu,yu);
568 *zd++ =dfx * *xd++ + dfy * *yd++;
572 if (!df1b2_gradlist::no_derivatives)
598 unsigned int _bs,
unsigned int _nbs,
599 unsigned int _bs2,
unsigned int _nbs2,
600 unsigned int _bs3,
unsigned int _nbs3,
606 list.allocate(bs,_filename);
610 nlist.allocate(nbs,
"n"+_filename);
614 list2.allocate(bs2,_filename+
"2");
617 if (!nbs2) nbs2=_nbs2;
618 nlist2.allocate(nbs2,
"n"+_filename+
"2");
622 list3.allocate(bs3,_filename+
"3");
625 if (!nbs3) nbs3=_nbs3;
626 nlist3.allocate(nbs3,
"n"+_filename+
"3");
628 list3.set_noreadflag(1);
629 nlist3.set_noreadflag(1);
653 assert(
sizeof(
char) == 1);
663 O_RDWR | O_CREAT | O_TRUNC |
O_BINARY, S_IREAD | S_IWRITE);
666 O_RDWR | O_CREAT | O_TRUNC |
O_BINARY, S_IRUSR | S_IWUSR);
670 cerr <<
"Error trying to open file " <<
filename
671 <<
" in class smartlist " <<
endl;
689 cerr <<
"need to initialize size in class ad_dstar" <<
endl;
717 int nvar = (int)df1b2variable::nvar;
720 assert(_nvar <= INT_MAX);
721 int nvar = (int)_nvar;
724 for (
int i=1;i<=nvar;i++)
726 for (
int j=1;j<=nvar;j++)
728 h(i,j)=
x(i).u_bar[j-1];
743 double delta=.3*_delta;
750 double d1fa=(fp-fm)/(2.0*delta);
751 x(i)=xsave+2.0*delta;
753 x(i)=xsave-2.0*delta;
756 double d1fb=(fp-fm)/(4.0*delta);
757 double d1f=(8.0*d1fa-d1fb)/7.0;
771 double fp=
d1F(pu,
x,j,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);
780 double d1fb=(fp-fm)/(4.0*delta);
781 double d1f=(8.0*d1fa-d1fb)/7.0;
795 double fp=
d2F(pu,
x,j,k,delta);
797 double fm=
d2F(pu,
x,j,k,delta);
799 double d1f=(fp-fm)/(2.0*delta);
811 int nvar = (int)df1b2variable::nvar;
814 assert(_nvar <= INT_MAX);
815 int nvar = (int)_nvar;
838 int nvar = (int)df1b2variable::nvar;
841 assert(_nvar <= INT_MAX);
842 int nvar = (int)_nvar;
844 d3_array h(1, nvar, 1, nvar, 1, nvar);
860 #if defined(__DERCHECK__)
866 dercheck_info::dercheck_info(
int _node_number,
double _delta,
int _index) :
867 node_number(_node_number), delta(_delta), index(_index)
875 dercheck_info * derchecker;
941 #if !defined(OPT_LIB)
951 "init_df1b2variable& init_df1b2vector::operator () (int i)",
957 "init_df1b2variable& init_df1b2vector::operator () (int i)",
972 "init_df1b2variable& init_df1b2vector::operator [] (int i)",
978 "init_df1b2variable& init_df1b2vector::operator [] (int i)",
996 cerr <<
"Usage " << s <<
" option needs integer -- ignored" <<
endl;
1003 n = (
unsigned int)i;
init_df1b2vector(void)
Default constructor.
void ad_read_pass2(void)
Description not yet available.
double(* d3f222)(double, double)
d3_array tan(const d3_array &arr3)
Returns d3_array results with computed tan from elements in arr3.
df1b2_gradlist * f1b2gradlist
double(* d3f122)(double, double)
void set_dependent_variable(const df1b2variable &_x)
Description not yet available.
unsigned int get_f1b2buffer_size(const char *s)
Get f1b2buffer size from commandline options.
static void set_no_derivatives(void)
static do_naught_kludge do_naught_kludge_a
void allocate(void)
Description not yet available.
Description not yet available.
char AD_allocation_error_message[]
init_df1b2variable(double v=0.0)
Description not yet available.
df1b2variable & operator=(const df3_one_variable &v)
smartlist(unsigned int bufsize, const adstring &filename)
Constructor.
virtual ~df1b2variable()
Destructor.
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Vector of double precision numbers.
int indexmin() const
Get minimum valid index.
double(* d3f111)(double, double)
re_df1b2_init_bounded_vector * pv
init_df1b2variable & operator()(int i)
double(* d3f112)(double, double)
static void set_blocksize(void)
Description not yet available.
double(* f)(double, double)
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.
double(* d2f22)(double, double)
static re_objective_function_value * pobjfun
int adptr_diff(void *x, void *y)
void reset(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void allocate(void)
Do not allocate, but just initialize class members.
#define AD_ALLOCATE(ptr, type, n, classname)
Description not yet available.
static init_df1b2variable ** list
static unsigned int get_nvar()
void set_u_dot(void)
Description not yet available.
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.
Description not yet available.
int atoi(adstring &s)
Returns a integer converted from input s.
void set_size(const size_t)
Set size of adpool.
Description not yet available.
~init_df1b2vector()
Destructor.
void deallocate(void)
If no other copies exist, free df1b2variable::ptr.
void operator=(double x)
Description not yet available.
df1b2variable operator()(const df1b2variable &x)
Description not yet available.
~ad_dstar(void)
Description not yet available.
void reset(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
prnstream & endl(prnstream &)
int max_num_init_df1b2variable
void allocate(void)
Description not yet available.
dmatrix check_second_derivatives(const init_df1b2vector &x)
Description not yet available.
df1b2variable operator()(const df1b2variable &x, const df1b2variable &y)
Description not yet available.
static int no_derivatives
int indexmax() const
Get maximum valid index.
init_df1b2variable * PINIT_DF1B2VARIABLE
ad_dstar(void)
Description not yet available.
double(* d2f11)(double, double)
double(* df2)(double, double)
dmatrix get_hessian(const init_df1b2vector &_x)
Description not yet available.
double d2F(P_USER_FUNCTION pu, const init_df1b2vector &_x, int i, int j, double delta)
Description not yet available.
d3_array check_third_derivatives(const init_df1b2vector &x)
Description not yet available.
static unsigned int blocksize
void reallocate(void)
Description not yet available.
Description not yet available.
double d3F(P_USER_FUNCTION pu, const init_df1b2vector &_x, int i, int j, int k, double delta)
Description not yet available.
#define ADMB_ARRAY_BOUNDS_ERROR(message, function, lower_bounds, upper_bounds, index)
init_df1b2variable * trueptr
int option_match(int argc, char *argv[], const char *string)
Checks if the program has been invoked with a particular command line argument ("string").
double(* d2f12)(double, double)
int write_pass1(const df1b2variable *px, const df1b2variable *py, df1b2variable *pz, df1b2function2 *pf)
Description not yet available.
re_objective_function_value(void)
Description not yet available.
static void allocate(const unsigned int _n)
void initialize(int sl, int sh, int nrl, const ivector &nrh, int ncl, const ivector &nch)
void initialize(void)
Initialize.
Description not yet available.
double d1F(P_USER_FUNCTION pu, const init_df1b2vector &_x, int i, double _delta)
Description not yet available.
static unsigned int get_blocksize(void)
Description not yet available.
void set_value(const dvector &)
Description not yet available.
int write_pass1x(const df1b2variable *_px, df1b2variable *pz, df1b2function1 *pf)
Description not yet available.
Description not yet available.
PTDF tan_address()
Description not yet available.
~re_objective_function_value()
Description not yet available.
init_df1b2variable & operator[](int i)
Description not yet available.
void deallocate(void)
Similar to destructor.
df1b2variable(void)
Default constructor.
Description not yet available.
df1b2function1(double(*_f)(double), double(*_df)(double), double(*d2f)(double), double(*_d3f)(double), const adstring &s="unnamed")
Description not yet available.
dvector value(const df1_one_vector &v)
double(* df1)(double, double)
Description not yet available.
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int write_save_pass2_tilde_values(const df1b2variable *px)
Description not yet available.
void reset(void)
Description not yet available.
Description not yet available.
df1b2variable(* P_USER_FUNCTION)(const init_df1b2vector &x)