Stan Math Library  2.20.0
reverse mode automatic differentiation
log_falling_factorial.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOG_FALLING_FACTORIAL_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOG_FALLING_FACTORIAL_HPP
3 
9 
10 namespace stan {
11 namespace math {
12 
54 template <typename T1, typename T2>
56  const T2 n) {
57  if (is_any_nan(x, n))
58  return NOT_A_NUMBER;
59  static const char* function = "log_falling_factorial";
60  check_positive(function, "first argument", x);
61  return lgamma(x + 1) - lgamma(x - n + 1);
62 }
63 
64 } // namespace math
65 } // namespace stan
66 #endif
fvar< T > log_falling_factorial(const fvar< T > &x, const fvar< T > &n)
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
Definition: lgamma.hpp:21
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:58
bool is_any_nan(const T &x)
Returns true if the input is NaN and false otherwise.
Definition: is_any_nan.hpp:21
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type
Definition: return_type.hpp:36
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.

     [ Stan Home Page ] © 2011–2018, Stan Development Team.