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));
302 const Type &slope_asc,
303 const Type &inflection_point_desc,
304 const Type &slope_desc,
const Type &x) {
305 return (
static_cast<Type
>(1.0)) /
306 (
static_cast<Type
>(1.0) +
307 exp(Type(-1.0) * slope_asc * (x - inflection_point_asc))) *
308 (
static_cast<Type
>(1.0) -
309 (
static_cast<Type
>(1.0)) /
310 (
static_cast<Type
>(1.0) +
311 exp(Type(-1.0) * slope_desc * (x - inflection_point_desc))));
328const Type
ad_fabs(
const Type &x, Type C = 1e-5) {
329 return sqrt((x * x) + C);
347template <
typename Type>
348inline const Type
ad_min(
const Type &a,
const Type &b, Type C = 1e-5) {
364template <
typename Type>
365inline const Type
ad_max(
const Type &a,
const Type &b, Type C = 1e-5) {
378T
sum(
const std::vector<T> &v) {
380 for (
size_t i = 0; i < v.size(); i++) {
397 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:378
const Type ad_min(const Type &a, const Type &b, Type C=1e-5)
Definition fims_math.hpp:348
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:301
const Type ad_max(const Type &a, const Type &b, Type C=1e-5)
Definition fims_math.hpp:365
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:328
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.