17#include "../interface/interface.hpp"
32inline const Type exp(
const Type &x) {
43inline const Type log(
const Type &x) {
48inline const Type cos(
const Type &x) {
53inline const Type sqrt(
const Type &x) {
58inline const Type pow(
const Type &x,
const Type &y) {
59 return std::pow(x, y);
63inline const Type lgamma(
const Type &x) {
64 return std::lgamma(x);
67inline double Value(
const double &x) {
return x; }
79inline const Type pnorm(
const Type &x,
const Type &mean,
const Type &sd) {
80 const double z =
static_cast<double>(x - mean) /
81 (
static_cast<double>(sd) * std::sqrt(2.0));
82 return static_cast<Type
>(0.5 * (1.0 + std::erf(z)));
89inline double Value(
const TMBAD_FIMS_TYPE &x) {
return x.Value(); }
91inline double Value(
const double &x) {
return x; }
109inline const Type exp(
const Type &x) {
128inline const Type log(
const Type &x) {
147inline const Type cos(
const Type &x) {
165inline const Type sqrt(
const Type &x) {
184inline const Type pow(
const Type &x,
const Type &y) {
206inline const Type lgamma(
const Type &x) {
216inline const Type pnorm(
const Type &x,
const Type &mean,
const Type &sd) {
220 return ::pnorm(x, mean, sd);
243inline const Type
logistic(
const Type &inflection_point,
const Type &slope,
245 return static_cast<Type
>(1.0) /
246 (
static_cast<Type
>(1.0) +
247 exp(Type(-1.0) * slope * (x - inflection_point)));
261inline const Type
logit(
const Type &a,
const Type &b,
const Type &x) {
262 return -fims_math::log(b - x) + fims_math::log(x - a);
276inline const Type
inv_logit(
const Type &a,
const Type &b,
const Type &logit_x) {
277 return a + (b - a) / (
static_cast<Type
>(1.0) + fims_math::exp(-logit_x));
305 const Type &slope_asc,
306 const Type &inflection_point_desc,
307 const Type &slope_desc,
const Type &x) {
308 return (
static_cast<Type
>(1.0)) /
309 (
static_cast<Type
>(1.0) +
310 exp(Type(-1.0) * slope_asc * (x - inflection_point_asc))) *
311 (
static_cast<Type
>(1.0) /
312 (
static_cast<Type
>(1.0) +
313 exp(slope_desc * (x - inflection_point_desc))));
330const Type
ad_fabs(
const Type &x, Type C = 1e-5) {
331 return sqrt((x * x) + C);
349template <
typename Type>
350inline const Type
ad_min(
const Type &a,
const Type &b, Type C = 1e-5) {
366template <
typename Type>
367inline const Type
ad_max(
const Type &a,
const Type &b, Type C = 1e-5) {
380T
sum(
const std::vector<T> &v) {
382 for (
size_t i = 0; i < v.size(); i++) {
399 for (
size_t i = 0; i < v.
size(); i++) {
Definition fims_vector.hpp:27
size_type size() const
Returns the number of elements.
Definition fims_vector.hpp:299
Platform macros and the core FIMS logging system.
const Type logit(const Type &a, const Type &b, const Type &x)
A logit function for bounding of parameters.
Definition fims_math.hpp:261
T sum(const std::vector< T > &v)
Definition fims_math.hpp:380
const Type ad_min(const Type &a, const Type &b, Type C=1e-5)
Definition fims_math.hpp:350
const Type double_logistic(const Type &inflection_point_asc, const Type &slope_asc, const Type &inflection_point_desc, const Type &slope_desc, const Type &x)
The general double logistic function.
Definition fims_math.hpp:304
const Type ad_max(const Type &a, const Type &b, Type C=1e-5)
Definition fims_math.hpp:367
const Type inv_logit(const Type &a, const Type &b, const Type &logit_x)
An inverse logit function for bounding of parameters.
Definition fims_math.hpp:276
const Type ad_fabs(const Type &x, Type C=1e-5)
Definition fims_math.hpp:330
const Type logistic(const Type &inflection_point, const Type &slope, const Type &x)
The general logistic function.
Definition fims_math.hpp:243
Establishes the FIMS Vector class.