ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
"Helper" Functions

Functions

double avg (double x, double y)
 Average of two numbers; constant objects. More...
 
prevariablecube (const prevariable &v1)
 Returns variable result of v1 cubed. More...
 
double cube (const double m)
 Cube of a number; constant objects. More...
 
prevariablefabs (const prevariable &v1)
 Absolute value. More...
 
prevariablefourth (const prevariable &v1)
 Returns variable result of v1 raised to the power of four. More...
 
double fourth (const double m)
 Fourth power of a number; constant objects. More...
 
dvariable max (const dvar_vector &variables)
 Return a copy of the maximum element in variables vector. More...
 
int max (int a, int b)
 Largest of two integer; constant objects. More...
 
dvariable mfexp (const prevariable &x, double b)
 Robust exponential function for variable argument with user specified domain bound. More...
 
double mfexp (double x, double b)
 Robust exponential function for constant argument with user specified domain bound. More...
 
dvariable mfexp (const prevariable &x)
 Robust exponential function for variable argument > 60 or < -60. More...
 
double mfexp (double x)
 Robust exponential function for constant argument > 60 or < -60. More...
 
dvariable min (const dvar_vector &variables)
 Return a copy of the minimum element in variables vector. More...
 
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$. More...
 
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$. More...
 
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$. More...
 
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$. More...
 
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$. More...
 
prevariablesfabs (const prevariable &v1)
 Smooth absolute value. More...
 
double square (const double value)
 Return square of value; constant object. More...
 
dvector square (const dvector &values)
 Return dvector results of squaring elements in a values; constant vector object. More...
 
ivector square (const ivector &values)
 Return dvector results of squaring elements in a values; constant vector object. More...
 
dmatrix square (const dmatrix &a)
 Square of a elements in a matrix; constant matrix object. More...
 
d3_array square (const d3_array &a)
 Square of elements in a 3-dimensional array; constant 3-dimensionsal array. More...
 
char which_library ()
 Get ADMB library mode. More...
 

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)

Returns variable result of v1 cubed.

Parameters
v1variable base
Returns
$v^3$

Definition at line 18 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 694 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)

Returns variable result of v1 raised to the power of four.

Parameters
v1variable base
Returns
$v^4$

Definition at line 38 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 704 of file dvector.cpp.

Referenced by gammlnguts().

dvariable max ( const dvar_vector variables)

Return a copy of the maximum element in variables vector.

Parameters
variablesis a dvar_vector
Returns
maximum variable

Definition at line 18 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 681 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 variables)

Return a copy of the minimum element in variables vector.

Parameters
variablesis a dvar_vector
Returns
minimum variable

Definition at line 36 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 125 of file fvar_fn.cpp.

double square ( const double  value)

Return square of value; constant object.

Parameters
valueto be squared.
Returns
$value^2$

Definition at line 16 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(), 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(), old_inv_cumd_beta_stable(), posfun(), function_minimizer::prof_minimize(), function_minimizer::prof_minimize_re(), robust_regression(), function_minimizer::rwm_mcmc_routine(), set_derivatives(), df1b2_init_bounded_dev_vector::set_value(), sqrt(), and square().

dvector square ( const dvector values)

Return dvector results of squaring elements in a values; constant vector object.

Parameters
valuesof constant object to be squared.
Returns
vector of the same length as #values containing $values_i^2$

Definition at line 28 of file d3arr4.cpp.

ivector square ( const ivector values)

Return dvector results of squaring elements in a values; constant vector object.

Parameters
valuesof constant object to be squared.
Returns
vector of the same length as #values containing $values_i^2$

Definition at line 54 of file d3arr4.cpp.

dmatrix square ( const dmatrix a)

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 #a containing $a_{ij}^2$

Definition at line 69 of file d3arr4.cpp.

d3_array square ( const d3_array a)

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 #a containing $a_{ijk}^2$

Definition at line 84 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 15 of file libtype.cpp.

Referenced by banner().