Stan Math Library  2.20.0
reverse mode automatic differentiation
ub_free.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_UB_FREE_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_UB_FREE_HPP
3 
8 #include <boost/math/tools/promotion.hpp>
9 #include <limits>
10 
11 namespace stan {
12 namespace math {
13 
36 template <typename T, typename U>
37 inline typename boost::math::tools::promote_args<T, U>::type ub_free(
38  const T& y, const U& ub) {
39  using std::log;
40  if (ub == INFTY)
41  return identity_free(y);
42  check_less_or_equal("ub_free", "Upper bounded variable", y, ub);
43  return log(ub - y);
44 }
45 
46 } // namespace math
47 } // namespace stan
48 #endif
void check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high)
Check if y is less or equal to high.
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:12
T identity_free(const T &y)
Returns the result of applying the inverse of the identity constraint transform to the input...
boost::math::tools::promote_args< T, U >::type ub_free(const T &y, const U &ub)
Return the free scalar that corresponds to the specified upper-bounded value with respect to the spec...
Definition: ub_free.hpp:37
const double INFTY
Positive infinity.
Definition: constants.hpp:48

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