| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/fun/identity_free.hpp>
5 #include <stan/math/prim/scal/err/check_less_or_equal.hpp>
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
stan
Definition: log_sum_exp.hpp:8
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
check_less_or_equal.hpp
stan::math::ub_free
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
identity_free.hpp
stan::math::identity_free
T identity_free(const T y)
Returns the result of applying the inverse of the identity constraint transform to the input...
Definition: identity_free.hpp:20
stan::math::check_less_or_equal
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.
Definition: check_less_or_equal.hpp:81

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