Stan Math Library  2.20.0
reverse mode automatic differentiation
offset_multiplier_free.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_OFFSET_MULTIPLIER_FREE_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_OFFSET_MULTIPLIER_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
43 offset_multiplier_free(const T& y, const L& mu, const S& sigma) {
44  check_finite("offset_multiplier_free", "offset", mu);
45  if (sigma == 1) {
46  if (mu == 0)
47  return identity_free(y);
48  return y - mu;
49  }
50  check_positive_finite("offset_multiplier_free", "multiplier", 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 offset_multiplier_free(const T &y, const L &mu, const S &sigma)
Return the unconstrained scalar that transforms to the specified offset and multiplier constrained sc...
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.