1#ifndef STAN_MATH_PRIM_FUN_CHOOSE_HPP
2#define STAN_MATH_PRIM_FUN_CHOOSE_HPP
7#include <boost/math/special_functions/binomial.hpp>
35 const double choices = boost::math::binomial_coefficient<double>(n, k);
37 std::numeric_limits<int>::max());
38 return static_cast<int>(std::round(choices));
51template <
typename T1,
typename T2, require_any_container_t<T1, T2>* =
nullptr>
52inline auto choose(
const T1& a,
const T2& b) {
54 a, b, [&](
const auto& c,
const auto& d) {
return choose(c, d); });
void check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high, Idxs... idxs)
Throw an exception if y is not less than high.
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
int choose(int n, int k)
Return the binomial coefficient for the specified integer arguments.
auto apply_scalar_binary(const T1 &x, const T2 &y, const F &f)
Base template function for vectorization of binary scalar functions defined by applying a functor to ...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...