Stan Math Library  2.20.0
reverse mode automatic differentiation
log_rising_factorial.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOG_RISING_FACTORIAL_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOG_RISING_FACTORIAL_HPP
3 
9 #include <limits>
10 
11 namespace stan {
12 namespace math {
13 
52 template <typename T1, typename T2>
53 inline typename return_type<T1, T2>::type log_rising_factorial(const T1& x,
54  const T2& n) {
55  if (is_any_nan(x, n))
56  return std::numeric_limits<double>::quiet_NaN();
57  static const char* function = "log_rising_factorial";
58  check_positive(function, "first argument", x);
59  return lgamma(x + n) - lgamma(x);
60 }
61 
62 } // namespace math
63 } // namespace stan
64 
65 #endif
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
Definition: lgamma.hpp:21
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
fvar< T > log_rising_factorial(const fvar< T > &x, const fvar< T > &n)
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.