1 #ifndef STAN_MATH_PRIM_FUN_POSITIVE_FREE_HPP 2 #define STAN_MATH_PRIM_FUN_POSITIVE_FREE_HPP 3 4 #include <stan/math/prim/meta.hpp> 5 #include <stan/math/prim/err.hpp> 6 #include <stan/math/prim/fun/log.hpp> 7 #include <cmath> 8 9 namespace stan { 10 namespace math { 11 12 /** 13 * Return the unconstrained value corresponding to the specified 14 * positive-constrained value. 15 * 16 * <p>The transform is the inverse of the transform \f$f\f$ applied by 17 * <code>positive_constrain(T)</code>, namely 18 * 19 * <p>\f$f^{-1}(x) = \log(x)\f$. 20 * 21 * <p>The input is validated using <code>check_positive()</code>. 22 * 23 * @param y Input scalar. 24 * @return Unconstrained value that produces the input when constrained. 25 * @tparam T Type of scalar. 26 * @throw std::domain_error if the variable is negative 27 */ 28 template <typename T> positive_free(const T & y)29inline T positive_free(const T& y) { 30 check_positive("positive_free", "Positive variable", y); 31 return log(y); 32 } 33 34 } // namespace math 35 } // namespace stan 36 #endif 37