Automatic Differentiation
 
Loading...
Searching...
No Matches
Phi.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_PHI_HPP
2#define STAN_MATH_PRIM_FUN_PHI_HPP
3
11
12namespace stan {
13namespace math {
14
32inline double Phi(double x) {
33 check_not_nan("Phi", "x", x);
34 if (x < -37.5) {
35 return 0;
36 } else if (x < -5.0) {
37 return 0.5 * erfc(-INV_SQRT_TWO * x);
38 } else if (x > 8.25) {
39 return 1;
40 } else {
41 return 0.5 * (1.0 + erf(INV_SQRT_TWO * x));
42 }
43}
44
52struct Phi_fun {
53 template <typename T>
54 static inline auto fun(const T& x) {
55 return Phi(x);
56 }
57};
58
66template <
67 typename T,
70inline auto Phi(const T& x) {
72}
73
74} // namespace math
75} // namespace stan
76
77#endif
require_all_not_t< is_nonscalar_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_all_not_nonscalar_prim_or_rev_kernel_expression_t
Require none of the types satisfy is_nonscalar_prim_or_rev_kernel_expression.
require_not_t< is_var_matrix< std::decay_t< T > > > require_not_var_matrix_t
Require type does not satisfy is_var_matrix.
fvar< T > erf(const fvar< T > &x)
Definition erf.hpp:16
static constexpr double INV_SQRT_TWO
The value of 1 over the square root of 2, .
fvar< T > Phi(const fvar< T > &x)
Definition Phi.hpp:16
fvar< T > erfc(const fvar< T > &x)
Definition erfc.hpp:16
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static auto fun(const T &x)
Definition Phi.hpp:54
Structure to wrap Phi() so it can be vectorized.
Definition Phi.hpp:52
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...