Stan Math Library  2.20.0
reverse mode automatic differentiation
log_determinant.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_MAT_FUN_LOG_DETERMINANT_HPP
2 #define STAN_MATH_FWD_MAT_FUN_LOG_DETERMINANT_HPP
3 
5 #include <stan/math/fwd/core.hpp>
10 
11 namespace stan {
12 namespace math {
13 
14 template <typename T, int R, int C>
15 inline fvar<T> log_determinant(const Eigen::Matrix<fvar<T>, R, C>& m) {
16  check_square("log_determinant", "m", m);
17 
18  return log(fabs(determinant(m)));
19 }
20 
21 } // namespace math
22 } // namespace stan
23 #endif
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:12
void check_square(const char *function, const char *name, const matrix_cl &y)
Check if the matrix_cl is square.
fvar< T > log_determinant(const Eigen::Matrix< fvar< T >, R, C > &m)
fvar< T > determinant(const Eigen::Matrix< fvar< T >, R, C > &m)
Definition: determinant.hpp:12
This template class represents scalars used in forward-mode automatic differentiation, which consist of values and directional derivatives of the specified template type.
Definition: fvar.hpp:41

     [ Stan Home Page ] © 2011–2018, Stan Development Team.