Loading [MathJax]/extensions/TeX/AMSsymbols.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
offset_multiplier_free.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_FREE_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_FREE_HPP
3
10#include <cmath>
11
12namespace stan {
13namespace math {
14
42template <typename T, typename M, typename S>
43inline auto offset_multiplier_free(const T& y, const M& mu, const S& sigma) {
44 auto&& mu_ref = to_ref(mu);
45 auto&& sigma_ref = to_ref(sigma);
47 check_matching_dims("offset_multiplier_constrain", "y", y, "mu", mu);
48 }
50 check_matching_dims("offset_multiplier_constrain", "y", y, "sigma", sigma);
52 check_matching_dims("offset_multiplier_constrain", "mu", mu, "sigma",
53 sigma);
54 }
55
56 check_finite("offset_multiplier_constrain", "offset", value_of(mu_ref));
57 check_positive_finite("offset_multiplier_constrain", "multiplier",
58 value_of(sigma_ref));
59 return stan::math::eval(divide(subtract(y, mu_ref), sigma_ref));
60}
61
65template <typename T, typename M, typename S,
67inline auto offset_multiplier_free(const std::vector<T>& x, const M& mu,
68 const S& sigma) {
69 std::vector<plain_type_t<decltype(offset_multiplier_free(x[0], mu, sigma))>>
70 ret;
71 ret.reserve(x.size());
72 const auto& mu_ref = to_ref(mu);
73 const auto& sigma_ref = to_ref(sigma);
74 for (size_t i = 0; i < x.size(); ++i) {
75 ret.emplace_back(offset_multiplier_free(x[i], mu_ref, sigma_ref));
76 }
77 return ret;
78}
79
83template <typename T, typename M, typename S,
85inline auto offset_multiplier_free(const std::vector<T>& x, const M& mu,
86 const std::vector<S>& sigma) {
87 check_matching_dims("offset_multiplier_free", "x", x, "sigma", sigma);
88 std::vector<
89 plain_type_t<decltype(offset_multiplier_free(x[0], mu, sigma[0]))>>
90 ret;
91 ret.reserve(x.size());
92 const auto& mu_ref = to_ref(mu);
93 for (size_t i = 0; i < x.size(); ++i) {
94 ret.emplace_back(offset_multiplier_free(x[i], mu_ref, sigma[i]));
95 }
96 return ret;
97}
98
102template <typename T, typename M, typename S,
104inline auto offset_multiplier_free(const std::vector<T>& x,
105 const std::vector<M>& mu, const S& sigma) {
106 check_matching_dims("offset_multiplier_free", "x", x, "mu", mu);
107 std::vector<
108 plain_type_t<decltype(offset_multiplier_free(x[0], mu[0], sigma))>>
109 ret;
110 ret.reserve(x.size());
111 const auto& sigma_ref = to_ref(sigma);
112 for (size_t i = 0; i < x.size(); ++i) {
113 ret.emplace_back(offset_multiplier_free(x[i], mu[i], sigma_ref));
114 }
115 return ret;
116}
117
121template <typename T, typename M, typename S>
122inline auto offset_multiplier_free(const std::vector<T>& x,
123 const std::vector<M>& mu,
124 const std::vector<S>& sigma) {
125 check_matching_dims("offset_multiplier_free", "x", x, "mu", mu);
126 check_matching_dims("offset_multiplier_free", "x", x, "sigma", sigma);
127 std::vector<
128 plain_type_t<decltype(offset_multiplier_free(x[0], mu[0], sigma[0]))>>
129 ret;
130 ret.reserve(x.size());
131 for (size_t i = 0; i < x.size(); ++i) {
132 ret.emplace_back(offset_multiplier_free(x[i], mu[i], sigma[i]));
133 }
134 return ret;
135}
136
137} // namespace math
138} // namespace stan
139#endif
subtraction_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > subtract(T_a &&a, T_b &&b)
auto divide(T_a &&a, double d)
Returns the elementwise division of the kernel generator expression.
Definition divide.hpp:20
require_not_t< is_std_vector< std::decay_t< T > > > require_not_std_vector_t
Require type does not satisfy is_std_vector.
require_all_not_t< is_std_vector< std::decay_t< Types > >... > require_all_not_std_vector_t
Require none of the types satisfy is_std_vector.
T eval(T &&arg)
Inputs which have a plain_type equal to the own time are forwarded unmodified (for Eigen expressions ...
Definition eval.hpp:20
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition value_of.hpp:18
auto offset_multiplier_free(const T &y, const M &mu, const S &sigma)
Return the unconstrained variable that transforms to the specified offset and multiplier constrained ...
void check_matching_dims(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the two containers have the same dimensions.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Check if a type is derived from Eigen::EigenBase or is a var_value whose value_type is derived from E...
Definition is_matrix.hpp:18