Stan Math Library  2.20.0
reverse mode automatic differentiation
locscale_free.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOCSCALE_FREE_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOCSCALE_FREE_HPP
3 
8 #include <boost/math/tools/promotion.hpp>
9 #include <cmath>
10 #include <limits>
11 
12 namespace stan {
13 namespace math {
14 
41 template <typename T, typename L, typename S>
42 inline typename boost::math::tools::promote_args<T, L, S>::type locscale_free(
43  const T& y, const L& mu, const S& sigma) {
44  check_finite("locscale_free", "location", mu);
45  if (sigma == 1) {
46  if (mu == 0)
47  return identity_free(y);
48  return y - mu;
49  }
50  check_positive_finite("locscale_free", "scale", sigma);
51  return (y - mu) / sigma;
52 }
53 
54 } // namespace math
55 } // namespace stan
56 #endif
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
boost::math::tools::promote_args< T, L, S >::type locscale_free(const T &y, const L &mu, const S &sigma)
Return the unconstrained scalar that transforms to the specified location and scale constrained scala...
T identity_free(const T &y)
Returns the result of applying the inverse of the identity constraint transform to the input...
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.

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