"Helper" Functions

## Functions

double avg (double x, double y)
Average of two numbers; constant objects.
prevariablecube (const prevariable &v1)
Cube of a number; variable object.
double cube (const double m)
Cube of a number; constant objects.
prevariablefabs (const prevariable &v1)
Absolute value.
prevariablefourth (const prevariable &v1)
Cube of a number; variable object.
double fourth (const double m)
Fourth power of a number; constant objects.
dvariable max (const dvar_vector &t1)
Maximum of a dvar_vector.
int max (int a, int b)
Largest of two integer; constant objects.
dvariable mfexp (const prevariable &x, double b)
Robust exponential function for variable argument with user specified domain bound.
double mfexp (double x, double b)
Robust exponential function for constant argument with user specified domain bound.
dvariable mfexp (const prevariable &x)
Robust exponential function for variable argument > 60 or < -60.
double mfexp (double x)
Robust exponential function for constant argument > 60 or < -60.
dvariable min (const dvar_vector &t1)
Minimum of a dvar_vector.
dvariable posfun (const dvariable &x, const double eps, const prevariable &_pen)
Retuns a positive function of the argument and sets a penalty for .
dvariable posfun (const dvariable &x, const double eps, const dvariable &_pen)
Retuns a positive function of the argument and sets a penalty for .
double posfun (const double &x, const double eps, const double &_pen)
Retuns a positive function of the argument and sets a penalty for .
double posfun2 (const double &x, const double eps, const double &_pen)
Retuns a positive function of the argument and sets a penalty for .
dvariable posfun2 (const dvariable &x, const double eps, const prevariable &_pen)
Retuns a positive function of the argument and sets a penalty for .
prevariablesfabs (const prevariable &v1)
Smooth absolute value.
double square (const double m)
Square of a number; constant object.
dvector square (const dvector &m)
Square of elements in a vector; constant vector object.
dmatrix square (const dmatrix &m)
Square of a elements in a matrix; constant matrix object.
d3_array square (const d3_array &m)
Square of elements in a 3-dimensional array; constant 3-dimensionsal array.
char which_library ()

## Detailed Description

ADMB functions to perform common operations. These functions are typically optimized for automatic differentiation and automatically invoke custom adjoint code.

## Function Documentation

 double avg ( double x, double y )

Average of two numbers; constant objects.

Parameters:
 x A double y A double
Returns:

Definition at line 42 of file dvector.cpp.

 prevariable& cube ( const prevariable & v1 )

Cube of a number; variable object.

Optimized for derivative computations.

Parameters:
 m number to be cubed
Returns:

Definition at line 19 of file fvar_op8.cpp.

 double cube ( const double m )

Cube of a number; constant objects.

Parameters:
 m Number to be cubed
Returns:

Definition at line 713 of file dvector.cpp.

 prevariable& fabs ( const prevariable & v1 )

Absolute value.

Simple overload of standard C library function. Not differentiable and should not be used in cases where an independent variable is expected to change sign. Use sfabs in such cases.

Parameters:
 v1 Indpendent variable
Returns:

Definition at line 105 of file fvar_fn.cpp.

 prevariable& fourth ( const prevariable & v1 )

Cube of a number; variable object.

Optimized for derivative computations.

Parameters:
 m number to be cubed
Returns:

Definition at line 37 of file fvar_op8.cpp.

 double fourth ( const double m )

Fourth power of a number; constant objects.

Parameters:
 m Number to be taken to the fourth power.
Returns:

Definition at line 723 of file dvector.cpp.

Referenced by gammlnguts().

 dvariable max ( const dvar_vector & t1 )

Maximum of a dvar_vector.

Parameters:
Returns:
The maximum of the vector

Definition at line 19 of file fvar_a11.cpp.

 int max ( int a, int b )

Largest of two integer; constant objects.

Parameters:
 a An integer b An integer
Returns:
A integer containing

Definition at line 700 of file dvector.cpp.

 dvariable mfexp ( const prevariable & x, double b )

Robust exponential function for variable argument with user specified domain bound.

Prevents overflow and underflow for arguments outside of the domain

Parameters:
 x dvariable exponent. b double user specified function domain bound.
Returns:

Definition at line 22 of file mfexp.cpp.

 double mfexp ( double x, double b )

Robust exponential function for constant argument with user specified domain bound.

Prevents overflow and underflow for arguments outside of the domain

Parameters:
 x exponent. b ouble user specified function domain bound.
Returns:

Definition at line 22 of file mfexpcon.cpp.

 dvariable mfexp ( const prevariable & x )

Robust exponential function for variable argument > 60 or < -60.

Prevents overflow and underflow for arguments outside of the domain of exp(). (Note: .)

Parameters:
 x dvariable exponent.
Returns:

Definition at line 47 of file mfexp.cpp.

 double mfexp ( double x )

Robust exponential function for constant argument > 60 or < -60.

Prevents overflow and underflow for arguments outside of the domain of exp(). (Note: .)

Parameters:
 x exponent.
Returns:

Definition at line 47 of file mfexpcon.cpp.

 dvariable min ( const dvar_vector & t1 )

Minimum of a dvar_vector.

Parameters:
Returns:
The minimum of the vector

Definition at line 39 of file fvar_a11.cpp.

 dvariable posfun ( const dvariable & x, const double eps, const prevariable & _pen )

Retuns a positive function of the argument and sets a penalty for .

This function will add the penalty (when applicable) onto the existing value of pen. Somewhere in the code after using posfun, the penalty should be added to the objective function. This function is intended to keep model state variables in the positive domain to avoid mathematical errors. See Section 2.3 of the ADMB Manual. (Note, the returned value is less than .)

Parameters:
 x Argument, . eps Threshold, , a double constant. The choice of a value for is model dependent, but is sufficient for some applications. _pen The penalty value incremented by if .
Returns:

Definition at line 32 of file posfunv.cpp.

 dvariable posfun ( const dvariable & x, const double eps, const dvariable & _pen )

Retuns a positive function of the argument and sets a penalty for .

This function will add the penalty (when applicable) onto the existing value of pen. Somewhere in the code after using posfun, the penalty should be added to the objective function. This function is intended to keep model state variables in the positive domain to avoid mathematical errors. See Section 2.3 of the ADMB Manual. (Note, the returned value is less than .)

Parameters:
 x Argument, . eps Threshold, , a double constant. The choice of a value for is model dependent, but is sufficient for some applications. _pen The penalty value incremented by if .
Returns:

Definition at line 52 of file posfunv.cpp.

 double posfun ( const double & x, const double eps, const double & _pen )

Retuns a positive function of the argument and sets a penalty for .

This function will add the penalty (when applicable) onto the existing value of pen. Somewhere in the code after using posfun, the penalty should be added to the objective function. This function is intended to keep model state variables in the positive domain to avoid mathematical errors. See Section 2.3 of the ADMB Manual. (Note, the returned value is less than .)

Parameters:
 x Argument, . eps Threshold, , a double constant. The choice of a value for is model dependent, but is sufficient for some applications. _pen The penalty value incremented by if .
Returns:

Definition at line 57 of file posfunc.cpp.

 double posfun2 ( const double & x, const double eps, const double & _pen )

Retuns a positive function of the argument and sets a penalty for .

A more coersive version. The penalty should be added to the objective function. This function is intended to keep model state variables in the positive domain to avoid mathematical errors. See Section 2.3 of the ADMB Manual.

Parameters:
 x Argument, . eps Threshold, , a double constant containing the minimum allowed value of . _pen The penalty value incremented by if . The choice of a value for is model dependent, but is sufficient for some applications.
Returns:

Definition at line 77 of file posfunc.cpp.

 dvariable posfun2 ( const dvariable & x, const double eps, const prevariable & _pen )

Retuns a positive function of the argument and sets a penalty for .

A more coersive version. The penalty should be added to the objective function. This function is intended to keep model state variables in the positive domain to avoid mathematical errors. See Section 2.3 of the ADMB Manual.

Parameters:
 x Argument, . eps Threshold, , a double constant containing the minimum allowed value of . _pen The penalty value incremented by if . The choice of a value for is model dependent, but is sufficient for some applications.
Returns:

Definition at line 88 of file posfunv.cpp.

 prevariable& sfabs ( const prevariable & v1 )

Smooth absolute value.

Uses thrid order polynomial to interpolate between += 0.001. Derivatives correct for all values of indpendent variable != 0.

Parameters:
 v1 Indpendent variable
Returns:

Definition at line 135 of file fvar_fn.cpp.

 double square ( const double m )
 dvector square ( const dvector & m )

Square of elements in a vector; constant vector object.

Parameters:
 m Vector of constant object to be squared.
Returns:
vector of the same length as #m containing

Definition at line 28 of file d3arr4.cpp.

 dmatrix square ( const dmatrix & m )

Square of a elements in a matrix; constant matrix object.

Parameters:
 m matrix of numbers to be squared.
Returns:
A matrix of the same rank as #m containing

Definition at line 55 of file d3arr4.cpp.

 d3_array square ( const d3_array & m )

Square of elements in a 3-dimensional array; constant 3-dimensionsal array.

Parameters:
 m d3_array of numbers to be squared.
Returns:
A d3_array of the same shape as #m containing

Definition at line 71 of file d3arr4.cpp.

 char which_library ( )