Stan Math Library  2.12.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 
6 #include <boost/math/tools/promotion.hpp>
7 #include <cmath>
8 #include <limits>
9 
10 namespace stan {
11  namespace math {
12 
35  template <typename T, typename TU>
36  inline
37  typename boost::math::tools::promote_args<T, TU>::type
38  ub_free(const T y, const TU ub) {
39  using std::log;
40  if (ub == std::numeric_limits<double>::infinity())
41  return identity_free(y);
42  check_less_or_equal("ub_free",
43  "Upper bounded variable", y, ub);
44  return log(ub - y);
45  }
46 
47  }
48 }
49 #endif
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
boost::math::tools::promote_args< T, TU >::type ub_free(const T y, const TU ub)
Return the free scalar that corresponds to the specified upper-bounded value with respect to the spec...
Definition: ub_free.hpp:38
T identity_free(const T y)
Returns the result of applying the inverse of the identity constraint transform to the input...
bool check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high)
Return true if y is less or equal to high.

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