Automatic Differentiation
 
Loading...
Searching...
No Matches
log_determinant_spd.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_LOG_DETERMINANT_SPD_HPP
2#define STAN_MATH_PRIM_FUN_LOG_DETERMINANT_SPD_HPP
3
9#include <cmath>
10
11namespace stan {
12namespace math {
13
23template <typename EigMat, require_eigen_t<EigMat>* = nullptr,
24 require_not_vt_var<EigMat>* = nullptr>
26 const auto& m_ref = to_ref(m);
27 check_symmetric("log_determinant_spd", "m", m_ref);
28 if (m.size() == 0) {
29 return 0;
30 }
31 return sum(log(m_ref.ldlt().vectorD().array()));
32}
33
34} // namespace math
35} // namespace stan
36
37#endif
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
value_type_t< EigMat > log_determinant_spd(const EigMat &m)
Returns the log absolute determinant of the specified square matrix.
fvar< T > log(const fvar< T > &x)
Definition log.hpp:15
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
Definition sum.hpp:22
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...