Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
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 
12  namespace math {
13 
36  template <typename T, typename TU>
37  inline
38  typename boost::math::tools::promote_args<T, TU>::type
39  ub_free(const T y, const TU ub) {
40  using std::log;
41  if (ub == std::numeric_limits<double>::infinity())
42  return identity_free(y);
43  stan::math::check_less_or_equal("stan::math::ub_free",
44  "Upper bounded variable", y, ub);
45  return log(ub - y);
46  }
47 
48 
49  }
50 
51 }
52 
53 #endif
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
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:39
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–2015, Stan Development Team.