1#ifndef STAN_MATH_OPENCL_PRIM_POISSON_LOG_LPMF_HPP 
    2#define STAN_MATH_OPENCL_PRIM_POISSON_LOG_LPMF_HPP 
   27template <
bool propto, 
typename T_n_cl, 
typename T_log_rate_cl,
 
   29                                                      T_log_rate_cl>* = 
nullptr,
 
   30          require_any_not_stan_scalar_t<T_n_cl, T_log_rate_cl>* = 
nullptr>
 
   32    const T_n_cl& n, 
const T_log_rate_cl& alpha) {
 
   33  static constexpr const char* function = 
"poisson_log_lpmf(OpenCL)";
 
   50  const auto& alpha_val = 
value_of(alpha_col);
 
   52  T_partials_return logp(0.0);
 
   55  auto check_n_nonnegative
 
   56      = 
check_cl(function, 
"Random variable", n, 
"nonnegative");
 
   57  auto n_nonnegativer = 0 <= n;
 
   58  auto check_alpha_not_nan
 
   59      = 
check_cl(function, 
"Log rate parameter", alpha_val, 
"not nan");
 
   60  auto alpha_not_nan = !isnan(alpha_val);
 
   63      = 
colwise_max(cast<char>(isinf(alpha_val) && (alpha_val > 0 || n != 0)));
 
   64  auto exp_alpha = 
exp(alpha_val);
 
   67  auto logp2 = static_select<include_summand<propto, T_log_rate_cl>::value>(
 
   68      logp1 - exp_alpha, logp1);
 
   70      logp2 - 
lgamma(n + 1.0), logp2));
 
   72  auto deriv = n - exp_alpha;
 
   78  results(check_n_nonnegative, check_alpha_not_nan, return_log_zero_cl, logp_cl,
 
   80      = 
expressions(n_nonnegativer, alpha_not_nan, return_log_zero, logp_expr,
 
   81                    calc_if<is_autodiff_v<T_log_rate_cl>>(deriv));
 
   89  if constexpr (is_autodiff_v<T_log_rate_cl>) {
 
   90    partials<0>(ops_partials) = deriv_cl;
 
   93  return ops_partials.build(logp);
 
Represents an arithmetic matrix on the OpenCL device.
 
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
 
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_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_log_rate_cl > poisson_log_lpmf(const T_n_cl &n, const T_log_rate_cl &alpha)
Returns the log PMF of the Poisson log distribution.
 
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.
 
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
 
static constexpr double LOG_ZERO
The natural logarithm of 0, .
 
constexpr bool any(T x)
Return true if any values in the input are true.
 
T value_of(const fvar< T > &v)
Return the value of the specified variable.
 
T1 static_select(T1 &&a, T2 &&b)
Returns one of the arguments that can be of different type, depending on the compile time condition.
 
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
 
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
 
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
 
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 ...
 
bool isnan(const stan::math::var &a)
Checks if the given number is NaN.
 
bool isinf(const stan::math::var &a)
Return 1 if the specified argument is positive infinity or negative infinity and 0 otherwise.
 
Checks if decayed type is a var, fvar, or arithmetic.
 
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...