Stan Math Library  2.20.0
reverse mode automatic differentiation
lub_free.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LUB_FREE_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LUB_FREE_HPP
3 
9 #include <limits>
10 
11 namespace stan {
12 namespace math {
13 
46 template <typename T, typename L, typename U>
47 inline typename boost::math::tools::promote_args<T, L, U>::type lub_free(
48  const T& y, const L& lb, const U& ub) {
49  check_bounded<T, L, U>("lub_free", "Bounded variable", y, lb, ub);
50  if (lb == NEGATIVE_INFTY)
51  return ub_free(y, ub);
52  if (ub == INFTY)
53  return lb_free(y, lb);
54  return logit((y - lb) / (ub - lb));
55 }
56 
57 } // namespace math
58 } // namespace stan
59 #endif
boost::math::tools::promote_args< T, L >::type lb_free(const T &y, const L &lb)
Return the unconstrained value that produces the specified lower-bound constrained value...
Definition: lb_free.hpp:30
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
fvar< T > logit(const fvar< T > &x)
Definition: logit.hpp:14
const double INFTY
Positive infinity.
Definition: constants.hpp:48
const double NEGATIVE_INFTY
Negative infinity.
Definition: constants.hpp:53
boost::math::tools::promote_args< T, L, U >::type lub_free(const T &y, const L &lb, const U &ub)
Return the unconstrained scalar that transforms to the specified lower- and upper-bounded scalar give...
Definition: lub_free.hpp:47

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