1#ifndef STAN_MATH_PRIM_FUN_CHOL2INV_HPP
2#define STAN_MATH_PRIM_FUN_CHOL2INV_HPP
23template <
typename T, require_eigen_t<T>* =
nullptr>
25 const Eigen::Ref<const plain_type_t<T>>& L_ref = L;
38 T_result L_inv = mdivide_left_tri<Eigen::Lower>(L_ref);
40 for (
int k = 0; k < K; ++k) {
41 X.coeffRef(k, k) =
dot_self(L_inv.col(k).tail(K - k).eval());
42 for (
int j = k + 1; j < K; ++j) {
45 L_inv.col(k).tail(Kmj).eval(), L_inv.col(j).tail(Kmj).eval());
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
fvar< T > inv_square(const fvar< T > &x)
plain_type_t< T > chol2inv(const T &L)
Returns the inverse of the matrix whose Cholesky factor is L.
auto dot_self(const T &a)
Returns squared norm of a vector or matrix.
auto dot_product(const T_a &a, const T_b &b)
Returns the dot product of the specified vectors.
void check_lower_triangular(const char *function, const char *name, const T_y &y)
Check if the specified matrix is lower triangular.
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...