Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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>
22 auto&& y_ref = to_ref(y);
23 const Eigen::Index M = y_ref.cols();
24 plain_type_t<Mat> ret(y_ref.rows() - 1, M);
25 for (Eigen::Index i = 0; i < M; ++i) {
26 ret.col(i) = simplex_free(y_ref.col(i));
27 }
28 return ret;
29}
30
38template <typename T, require_std_vector_t<T>* = nullptr>
39inline auto stochastic_column_free(const T& y) {
41 y, [](auto&& v) { return stochastic_column_free(v); });
42}
43
44} // namespace math
45} // namespace stan
46
47#endif
plain_type_t< Mat > stochastic_column_free(const Mat &y)
Return an unconstrained matrix that when transformed produces the specified columnwise stochastic mat...
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 ...