ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
Functions
"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 $x$ and sets a penalty for $x<0$.
dvariable posfun (const dvariable &x, const double eps, const dvariable &_pen)
 Retuns a positive function of the argument $x$ and sets a penalty for $x<0$.
double posfun (const double &x, const double eps, const double &_pen)
 Retuns a positive function of the argument $x$ and sets a penalty for $x<0$.
double posfun2 (const double &x, const double eps, const double &_pen)
 Retuns a positive function of the argument $x$ and sets a penalty for $x<0$.
dvariable posfun2 (const dvariable &x, const double eps, const prevariable &_pen)
 Retuns a positive function of the argument $x$ and sets a penalty for $x<0$.
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 ()
 Get ADMB library mode.

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:
xA double
yA double
Returns:
$0.5*(x+y)$

Definition at line 42 of file dvector.cpp.

prevariable& cube ( const prevariable v1)

Cube of a number; variable object.

Optimized for derivative computations.

Parameters:
mnumber to be cubed
Returns:
$m^3$

Definition at line 19 of file fvar_op8.cpp.

double cube ( const double  m)

Cube of a number; constant objects.

Parameters:
mNumber to be cubed
Returns:
$m^3$

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:
v1Indpendent variable $x$
Returns:
$|x|$

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:
mnumber to be cubed
Returns:
$m^4$

Definition at line 37 of file fvar_op8.cpp.

double fourth ( const double  m)

Fourth power of a number; constant objects.

Parameters:
mNumber to be taken to the fourth power.
Returns:
$m^4$

Definition at line 723 of file dvector.cpp.

Referenced by gammlnguts().

dvariable max ( const dvar_vector t1)

Maximum of a dvar_vector.

Parameters:
Advar_vector
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:
aAn integer
bAn integer
Returns:
A integer containing $ z = \max(a,b)$

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:
xdvariable exponent.
bdouble user specified function domain bound.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x > b & e^b\frac{(1+2(x-b))}{1+x-b}\\ x < b & e^{-b}\frac{(1-x-b)}{1+2(-x-b)}\\ {\rm else} & e^x \end{array}\right.$

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:
xexponent.
bouble user specified function domain bound.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x > b & e^b\frac{(1+2(x-b))}{1+x-b}\\ x < b & e^{-b}\frac{(1-x-b)}{1+2(-x-b)}\\ {\rm else} & e^x \end{array}\right.$

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: $e^{60} > 10^{26}$.)

Parameters:
xdvariable exponent.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x > 60 & e^{60}\frac{(1+2(x-60))}{1+x-60}\\ x < 60 & e^{-60}\frac{(1-x-60)}{1+2(-x-60)}\\ {\rm else} & e^x \end{array}\right.$

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: $e^{60} > 10^{26}$.)

Parameters:
xexponent.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x > 60 & e^{60}\frac{(1+2(x-60))}{1+x-60}\\ x < 60 & e^{-60}\frac{(1-x-60)}{1+2(-x-60)}\\ {\rm else} & e^x \end{array}\right.$

Definition at line 47 of file mfexpcon.cpp.

dvariable min ( const dvar_vector t1)

Minimum of a dvar_vector.

Parameters:
Advar_vector
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 $x$ and sets a penalty for $x<0$.

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 $\epsilon$.)

Parameters:
xArgument, $x$.
epsThreshold, $\epsilon$, a double constant. The choice of a value for $\epsilon$ is model dependent, but $10^{-3}$ is sufficient for some applications.
_penThe penalty value incremented by $ 0.01(x-\epsilon)^2 $ if $x<\epsilon$.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x\ge\epsilon & x\\ x<\epsilon & \frac{\epsilon}{2-x/\epsilon} \end{array}\right.$

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 $x$ and sets a penalty for $x<0$.

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 $\epsilon$.)

Parameters:
xArgument, $x$.
epsThreshold, $\epsilon$, a double constant. The choice of a value for $\epsilon$ is model dependent, but $10^{-3}$ is sufficient for some applications.
_penThe penalty value incremented by $ 0.01(x-\epsilon)^2 $ if $x<\epsilon$.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x\ge\epsilon & x\\ x<\epsilon & \frac{\epsilon}{2-x/\epsilon} \end{array}\right.$

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 $x$ and sets a penalty for $x<0$.

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 $\epsilon$.)

Parameters:
xArgument, $x$.
epsThreshold, $\epsilon$, a double constant. The choice of a value for $\epsilon$ is model dependent, but $10^{-3}$ is sufficient for some applications.
_penThe penalty value incremented by $ 0.01(x-\epsilon)^2 $ if $x<\epsilon$.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x\ge\epsilon & x\\ x<\epsilon & \frac{\epsilon}{2-x/\epsilon} \end{array}\right.$

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 $x$ and sets a penalty for $x<0$.

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:
xArgument, $x$.
epsThreshold, $\epsilon$, a double constant containing the minimum allowed value of $x$.
_penThe penalty value incremented by $ 0.01(x-\epsilon)^3 $ if $x<\epsilon$. The choice of a value for $\epsilon$ is model dependent, but $10^{-3}$ is sufficient for some applications.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x\ge\epsilon & x\\ x<\epsilon & \frac{\epsilon}{1+x/\epsilon +(x/\epsilon)^2 +(x/\epsilon)^3} \end{array}\right.$

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 $x$ and sets a penalty for $x<0$.

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:
xArgument, $x$.
epsThreshold, $\epsilon$, a double constant containing the minimum allowed value of $x$.
_penThe penalty value incremented by $ 0.01(x-\epsilon)^3 $ if $x<\epsilon$. The choice of a value for $\epsilon$ is model dependent, but $10^{-3}$ is sufficient for some applications.
Returns:
$\left\{\begin{array} {r@{\quad:\quad}l} x\ge\epsilon & x\\ x<\epsilon & \frac{\epsilon}{1+x/\epsilon +(x/\epsilon)^2 +(x/\epsilon)^3} \end{array}\right.$

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:
v1Indpendent variable $x$
Returns:
$|x|$

Definition at line 135 of file fvar_fn.cpp.

double square ( const double  m)

Square of a number; constant object.

Parameters:
mNumber to be squared.
Returns:
$m^2$

Definition at line 18 of file d3arr4.cpp.

Referenced by AD_df1_atan(), AD_df1_tan(), AD_df2_atan(), AD_df2_tan(), AD_df3_atan(), AD_df3_tan(), AD_pow_22(), atan(), betacf(), calculate_importance_sample_block_diagonal(), calculate_importance_sample_block_diagonal_funnel(), calculate_importance_sample_block_diagonal_option2(), calculate_importance_sample_block_diagonal_option_antithetical(), calculate_importance_sample_funnel(), cube(), df_cumd_normal_logistic_mixture(), dfboundp(), dfcholeski_sparse(), dflogistic(), dfposfun(), dlnorm(), dmultinom(), dnorm(), do_gauss_hermite_block_diagonal(), do_gauss_hermite_block_diagonal_multi(), dstudent_t(), exp(), fcomp1(), gammlnguts(), get_ft(), param_init_bounded_vector::get_jacobian(), inv(), inv_cumd_beta_stable(), inv_cumd_gamma(), inv_cumd_norm_logistic(), inv_cumd_normal_logistic_mixture(), inv_cumd_normal_mixture(), laplace_approximation_calculator::local_minimization_routine(), log(), log_der_logistic(), function_minimizer::mcmc_routine(), mf_upper_bound(), mf_upper_bound2(), multifan(), ndfboundp(), nllLognormal(), nllLognormal2(), nllNormal(), nllNormal2(), norm(), norm2(), normalize_p(), function_minimizer::normalize_posterior_distribution(), normalized_gauss_hermite(), posfun(), function_minimizer::prof_minimize(), function_minimizer::prof_minimize_re(), robust_regression(), set_derivatives(), df1b2_init_bounded_dev_vector::set_value(), sqrt(), and square().

dvector square ( const dvector m)

Square of elements in a vector; constant vector object.

Parameters:
mVector of constant object to be squared.
Returns:
vector of the same length as #m containing $m_i^2$

Definition at line 28 of file d3arr4.cpp.

dmatrix square ( const dmatrix m)

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

Parameters:
mmatrix of numbers to be squared.
Returns:
A matrix of the same rank as #m containing $m_{ij}^2$

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:
md3_array of numbers to be squared.
Returns:
A d3_array of the same shape as #m containing $m_{ijk}^2$

Definition at line 71 of file d3arr4.cpp.

char which_library ( )

Get ADMB library mode.

Returns:
char containing 'o' if compiled with the OPT_LIB macro; contains 's' otherwise.

Definition at line 17 of file libtype.cpp.

Referenced by banner().