1#ifndef STAN_MATH_REV_FUN_LOG_DETERMINANT_LDLT_HPP
2#define STAN_MATH_REV_FUN_LOG_DETERMINANT_LDLT_HPP
21template <
typename T, require_rev_matrix_t<T>* =
nullptr>
23 if (A.matrix().size() == 0) {
27 var log_det =
sum(
log(A.ldlt().vectorD().array()));
31 = Eigen::MatrixXd::Identity(A.matrix().rows(), A.matrix().cols());
33 A.ldlt().solveInPlace(arena_A_inv);
36 arena_A.adj() += log_det.adj() * arena_A_inv;
LDLT_factor is a structure that holds a matrix of type T and the LDLT of its values.
value_type_t< T > log_determinant_ldlt(LDLT_factor< T > &A)
Returns log(abs(det(A))) given a LDLT_factor of A.
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
fvar< T > log(const fvar< T > &x)
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
typename internal::arena_type_impl< std::decay_t< T > >::type arena_t
Determines a type that can be used in place of T that does any dynamic allocations on the AD stack.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...