Automatic Differentiation
 
Loading...
Searching...
No Matches
stochastic_column_free.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_COLUMN_FREE_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_COLUMN_FREE_HPP
3
7
8namespace stan {
9namespace math {
10
20template <typename Mat, require_eigen_matrix_dynamic_t<Mat>* = nullptr,
21 require_not_st_var<Mat>* = nullptr>
23 auto&& y_ref = to_ref(y);
24 const Eigen::Index M = y_ref.cols();
25 plain_type_t<Mat> ret(y_ref.rows() - 1, M);
26 for (Eigen::Index i = 0; i < M; ++i) {
27 ret.col(i) = simplex_free(y_ref.col(i));
28 }
29 return ret;
30}
31
39template <typename T, require_std_vector_t<T>* = nullptr>
40inline auto stochastic_column_free(const T& y) {
42 y, [](auto&& v) { return stochastic_column_free(v); });
43}
44
45} // namespace math
46} // namespace stan
47
48#endif
plain_type_t< Vec > simplex_free(const Vec &x)
Return an unconstrained vector that when transformed produces the specified simplex.
plain_type_t< Mat > stochastic_column_free(const Mat &y)
Return an unconstrained matrix that when transformed produces the specified columnwise stochastic mat...
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 ...