All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
ub_constrain.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_FUN_UB_CONSTRAIN_HPP
#define STAN_MATH_PRIM_SCAL_FUN_UB_CONSTRAIN_HPP
#include <boost/math/tools/promotion.hpp>
#include <stan/math/prim/scal/fun/identity_constrain.hpp>
#include <cmath>
#include <limits>
namespace stan {
namespace math {
// UPPER BOUND
template <typename T, typename TU>
inline
typename boost::math::tools::promote_args<T, TU>::type
ub_constrain(const T x, const TU ub) {
using std::exp;
if (ub == std::numeric_limits<double>::infinity())
return identity_constrain(x);
return ub - exp(x);
}
template <typename T, typename TU>
inline
typename boost::math::tools::promote_args<T, TU>::type
ub_constrain(const T x, const TU ub, T& lp) {
using std::exp;
if (ub == std::numeric_limits<double>::infinity())
return identity_constrain(x, lp);
lp += x;
return ub - exp(x);
}
}
}
#endif
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
identity_constrain.hpp
stan::math::ub_constrain
boost::math::tools::promote_args< T, TU >::type ub_constrain(const T x, const TU ub)
Return the upper-bounded value for the specified unconstrained scalar and upper bound.
Definition: ub_constrain.hpp:37
stan::math::identity_constrain
T identity_constrain(T x)
Returns the result of applying the identity constraint transform to the input.
Definition: identity_constrain.hpp:22

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