1#ifndef STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP
2#define STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP
36template <
typename T, require_var_vector_t<T>* =
nullptr>
38 size_t k_choose_2 = (k * (k - 1)) / 2;
40 "k_choose_2 + k", k_choose_2 + k);
41 auto arena_x =
to_arena(std::forward<T>(x));
44 internal::cholesky_corr_factor<internal::CorrOrder::column>(
45 arena_x.head(k_choose_2), k)));
62template <
typename T, require_var_vector_t<T>* =
nullptr>
65 size_t k_choose_2 = (k * (k - 1)) / 2;
67 "k_choose_2 + k", k_choose_2 + k);
68 auto arena_x =
to_arena(std::forward<T>(x));
69 auto cpcs = arena_x.head(k_choose_2);
70 auto log_sds = arena_x.tail(k);
76 internal::cholesky_corr_factor<internal::CorrOrder::column>(cpcs, k)));
auto corr_matrix_log_jacobian_coefficients(Eigen::Index K)
Return a lazy expression of the coefficients c for which the log absolute Jacobian determinant of cor...
Eigen::Matrix< value_type_t< EigMat >, EigMat::RowsAtCompileTime, EigMat::RowsAtCompileTime > multiply_lower_tri_self_transpose(const EigMat &m)
auto diag_pre_multiply(const T1 &m1, const T2 &m2)
Return the product of the diagonal matrix formed from the vector or row_vector and a matrix.
auto positive_constrain(T &&x)
Return the positive value for the specified unconstrained input.
static constexpr double LOG_TWO
The natural logarithm of 2, .
arena_t< T > to_arena(const T &a)
Converts given argument into a type that either has any dynamic allocation on AD stack or schedules i...
Eigen::Matrix< value_type_t< T >, Eigen::Dynamic, Eigen::Dynamic > cov_matrix_constrain_lkj(T &&x, size_t k)
Return the k x k covariance matrix (diag(sds) L) (diag(sds) L)^T, with L the Cholesky factor of the c...
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
fvar< T > log_cosh(const fvar< T > &x)
Return the natural logarithm of the hyperbolic cosine of the argument.
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
auto dot_product(const T_a &a, const T_b &b)
Returns the dot product of the specified vectors.
typename scalar_type< T >::type scalar_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...