Automatic Differentiation
 
Loading...
Searching...
No Matches
stochastic_row_free.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_ROW_FREE_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_ROW_FREE_HPP
3
7
8namespace stan {
9namespace math {
10
19template <typename Mat, require_eigen_matrix_dynamic_t<Mat>* = nullptr,
20 require_not_st_var<Mat>* = nullptr>
22 auto&& y_ref = to_ref(y);
23 const Eigen::Index N = y_ref.rows();
24 plain_type_t<Mat> ret(N, y_ref.cols() - 1);
25 for (Eigen::Index i = 0; i < N; ++i) {
26 ret.row(i) = simplex_free(y_ref.row(i));
27 }
28 return ret;
29}
30
38template <typename T, require_std_vector_t<T>* = nullptr>
39inline auto stochastic_row_free(const T& y) {
41 y, [](auto&& v) { return stochastic_row_free(v); });
42}
43
44} // namespace math
45} // namespace stan
46
47#endif
plain_type_t< Mat > stochastic_row_free(const Mat &y)
Return an unconstrained matrix that when transformed produces the specified simplex matrix.
plain_type_t< Vec > simplex_free(const Vec &x)
Return an unconstrained vector that when transformed produces the specified simplex.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...