1#ifndef STAN_MATH_OPENCL_PRIM_BERNOULLI_LCDF_HPP
2#define STAN_MATH_OPENCL_PRIM_BERNOULLI_LCDF_HPP
28 typename T_n_cl,
typename T_prob_cl,
29 require_all_prim_or_rev_kernel_expression_t<T_n_cl, T_prob_cl>* =
nullptr,
30 require_any_not_stan_scalar_t<T_n_cl, T_prob_cl>* =
nullptr>
32 const T_prob_cl& theta) {
33 static constexpr const char* function =
"bernoulli_lcdf(OpenCL)";
39 "Probability parameter", theta);
46 const auto& theta_val =
value_of(theta_col);
48 auto check_theta_bounded =
check_cl(function,
"Probability parameter",
49 theta_val,
"in the interval [0, 1]");
50 auto theta_bounded_expr = 0.0 <= theta_val && theta_val <= 1.0;
52 auto any_n_negative =
colwise_max(cast<char>(n < 0));
53 auto Pi = 1.0 - theta_val;
62 results(check_theta_bounded, any_n_negative_cl, P_cl, deriv_cl)
63 =
expressions(theta_bounded_expr, any_n_negative, P_expr,
74 partials<0>(ops_partials) = std::move(deriv_cl);
77 return ops_partials.build(P);
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.
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
auto colwise_max(T &&a)
Column wise max - reduction of a kernel generator expression.
calc_if_< true, as_operation_cl_t< T > > calc_if(T &&a)
auto colwise_sum(T &&a)
Column wise sum - reduction of a kernel generator expression.
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_prob_cl > bernoulli_lcdf(const T_n_cl &n, const T_prob_cl &theta)
Returns the log CDF of the Bernoulli distribution.
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>>.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > log(const fvar< T > &x)
static constexpr double NEGATIVE_INFTY
Negative infinity.
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
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.
Checks if decayed type is a var, fvar, or arithmetic.
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...