Stan Math Library  2.14.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 
7 #include <limits>
8 
9 namespace stan {
10  namespace math {
11 
53  template<typename T1, typename T2>
54  inline typename boost::math::tools::promote_args<T1, T2>::type
55  log_falling_factorial(const T1 x, const T2 n) {
56  if (is_nan(x) || is_nan(n))
57  return std::numeric_limits<double>::quiet_NaN();
58  static const char* fun = "log_falling_factorial";
59  check_positive(fun, "first argument", x);
60  return lgamma(x + 1) - lgamma(x - n + 1);
61  }
62 
63  }
64 }
65 
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:20
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
int is_nan(const fvar< T > &x)
Returns 1 if the input&#39;s value is NaN and 0 otherwise.
Definition: is_nan.hpp:21

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