1#ifndef STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_FACTOR_FREE_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_FACTOR_FREE_HPP
25template <
typename T, require_eigen_t<T>* =
nullptr>
30 const auto& y_ref =
to_ref(y);
34 Eigen::Matrix<value_type_t<T>, Eigen::Dynamic, 1> x((N * (N + 1)) / 2
38 for (
int m = 0; m < N; ++m) {
39 x.segment(pos, m) = y_ref.row(m).head(m);
41 x.coeffRef(pos++) =
log(y_ref.coeff(m, m));
44 for (
int m = N; m < M; ++m) {
45 x.segment(pos, N) = y_ref.row(m);
58template <
typename T, require_std_vector_t<T>* =
nullptr>
Eigen::Matrix< value_type_t< T >, Eigen::Dynamic, 1 > cholesky_factor_free(const T &y)
Return the unconstrained vector of parameters corresponding to the specified Cholesky factor.
fvar< T > log(const fvar< T > &x)
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_cholesky_factor(const char *function, const char *name, const Mat &y)
Throw an exception if the specified matrix is not a valid Cholesky factor.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...