1#ifndef STAN_MATH_OPENCL_PRIM_STD_NORMAL_CDF_HPP
2#define STAN_MATH_OPENCL_PRIM_STD_NORMAL_CDF_HPP
23template <
typename T_y_cl,
24 require_all_prim_or_rev_kernel_expression_t<T_y_cl>* =
nullptr,
25 require_any_not_stan_scalar_t<T_y_cl>* =
nullptr>
27 static constexpr const char* function =
"std_normal_cdf(OpenCL)";
41 =
check_cl(function,
"Random variable", y_val,
"not NaN");
42 auto y_not_nan_expr = !isnan(y_val);
46 =
select(y_val < -37.5, 0.0,
48 select(y_val > 8.25, 1.0, 0.5 * (1.0 +
erf(scaled_y)))));
51 =
select(y_val < -37.5, 0.0,
65 partials<0>(ops_partials) = y_deriv_cl * cdf;
67 return ops_partials.build(cdf);
Represents an arithmetic matrix on the OpenCL device.
select_< as_operation_cl_t< T_condition >, as_operation_cl_t< T_then >, as_operation_cl_t< T_else > > select(T_condition &&condition, T_then &&then, T_else &&els)
Selection operation on kernel generator expressions.
auto check_cl(const char *function, const char *var_name, T &&y, const char *must_be)
Constructs a check on opencl matrix or expression.
results_cl< T_results... > results(T_results &&... results)
Deduces types for constructing results_cl object.
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
auto colwise_prod(T &&a)
Column wise product - reduction of a kernel generator expression.
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
calc_if_< true, as_operation_cl_t< T > > calc_if(T &&a)
expressions_cl< T_expressions... > expressions(T_expressions &&... expressions)
Deduces types for constructing expressions_cl object.
auto from_matrix_cl(const T &src)
Copies the source matrix that is stored on the OpenCL device to the destination Eigen matrix.
return_type_t< T_y_cl > std_normal_cdf(const T_y_cl &y)
Returns the standard normal cumulative distribution function.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
value_type_t< T > prod(const T &m)
Calculates product of given kernel generator expression elements.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > erf(const fvar< T > &x)
static constexpr double INV_SQRT_TWO
The value of 1 over the square root of 2, .
static constexpr double INV_SQRT_TWO_PI
The value of 1 over the square root of , .
fvar< T > erfc(const fvar< T > &x)
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
fvar< T > square(const fvar< T > &x)
fvar< T > exp(const fvar< T > &x)
typename partials_return_type< Args... >::type partials_return_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
bool isnan(const stan::math::var &a)
Checks if the given number is NaN.
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...