1#ifndef STAN_MATH_OPENCL_PRIM_BINOMIAL_LOGIT_LPMF_HPP
2#define STAN_MATH_OPENCL_PRIM_BINOMIAL_LOGIT_LPMF_HPP
29template <
bool propto,
typename T_n_cl,
typename T_N_cl,
typename T_prob_cl,
31 T_prob_cl>* =
nullptr,
33 T_n_cl, T_N_cl, T_prob_cl>* =
nullptr>
35 const T_prob_cl& alpha) {
36 static constexpr const char* function =
"binomial_logit_lpmf(OpenCL)";
41 "Population size parameter", N,
42 "Probability parameter", alpha);
43 const size_t siz =
max_size(n, N, alpha);
52 const auto& alpha_val =
value_of(alpha_col);
55 =
check_cl(function,
"Successes variable", n,
"in the interval [0, N]");
56 auto n_bounded = 0 <= n && n <= N;
57 auto check_N_nonnegative
58 =
check_cl(function,
"Population size variable", n,
"nonnegative");
59 auto N_nonnegative = N >= 0;
60 auto check_alpha_finite
61 =
check_cl(function,
"Probability parameter", alpha_val,
"finite");
62 auto alpha_finite =
isfinite(alpha_val);
70 = static_select<include_summand<propto, T_n_cl, T_N_cl>::value>(
77 results(check_n_bounded, check_N_nonnegative, check_alpha_finite, logp_cl,
79 =
expressions(n_bounded, N_nonnegative, alpha_finite, logp_expr,
85 partials<0>(ops_partials) = std::move(alpha_deriv_cl);
88 return ops_partials.build(logp);
Represents an arithmetic matrix on the OpenCL device.
require_any_t< is_nonscalar_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_any_nonscalar_prim_or_rev_kernel_expression_t
Require any of the types satisfy is_nonscalar_prim_or_rev_kernel_expression.
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
isfinite_< as_operation_cl_t< T > > isfinite(T &&a)
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.
binomial_coefficient_log_< as_operation_cl_t< T1 >, as_operation_cl_t< T2 > > binomial_coefficient_log(T1 &&a, T2 &&b)
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
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.
return_type_t< T_prob_cl > binomial_logit_lpmf(const T_n_cl &n, const T_N_cl N, const T_prob_cl &alpha)
Binomial log PMF in logit parametrization.
auto from_matrix_cl(const T &src)
Copies the source matrix that is stored on the OpenCL device to the destination Eigen matrix.
require_all_t< is_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_all_prim_or_rev_kernel_expression_t
Require type satisfies is_prim_or_rev_kernel_expression.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > log_inv_logit(const fvar< T > &x)
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
int64_t max_size(const T1 &x1, const Ts &... xs)
Calculate the size of the largest input.
fvar< T > log1m_inv_logit(const fvar< T > &x)
Return the natural logarithm of one minus the inverse logit of the specified argument.
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
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 ...
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...