1 #ifndef STAN_MATH_REV_MAT_FUN_LOG_DETERMINANT_HPP
2 #define STAN_MATH_REV_MAT_FUN_LOG_DETERMINANT_HPP
12 template <
int R,
int C>
18 Matrix<double, R, C> m_d(m.rows(), m.cols());
19 for (
int i = 0; i < m.size(); ++i)
22 Eigen::FullPivHouseholderQR<Matrix<double, R, C> > hh
23 = m_d.fullPivHouseholderQr();
25 double val = hh.logAbsDeterminant();
29 for (
int i = 0; i < m.size(); ++i)
32 Matrix<double, R, C> m_inv_transpose = hh.inverse().transpose();
35 for (
int i = 0; i < m.size(); ++i)
36 gradients[i] = m_inv_transpose(i);
static stack_alloc memalloc_
The variable implementation base class.
fvar< T > log_determinant(const Eigen::Matrix< fvar< T >, R, C > &m)
Independent (input) and dependent (output) variables for gradients.
A variable implementation taking a sequence of operands and partial derivatives with respect to the o...
T * alloc_array(size_t n)
Allocate an array on the arena of the specified size to hold values of the specified template paramet...
bool check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is square.