Stan Math Library  2.20.0
reverse mode automatic differentiation
determinant.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_MAT_FUN_DETERMINANT_HPP
2 #define STAN_MATH_FWD_MAT_FUN_DETERMINANT_HPP
3 
5 #include <stan/math/fwd/core.hpp>
7 
8 namespace stan {
9 namespace math {
10 
11 template <typename T, int R, int C>
12 inline fvar<T> determinant(const Eigen::Matrix<fvar<T>, R, C>& m) {
13  check_square("determinant", "m", m);
14 
15  const T vals = m.val().determinant();
16  return fvar<T>(vals, vals * (m.val().inverse() * m.d()).trace());
17 }
18 
19 } // namespace math
20 } // namespace stan
21 #endif
void check_square(const char *function, const char *name, const matrix_cl &y)
Check if the matrix_cl is square.
fvar< T > determinant(const Eigen::Matrix< fvar< T >, R, C > &m)
Definition: determinant.hpp:12
T trace(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
Returns the trace of the specified matrix.
Definition: trace.hpp:19
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.