Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
log_determinant_spd.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__LOG_DETERMINANT_SPD_HPP
2 #define STAN__MATH__MATRIX__LOG_DETERMINANT_SPD_HPP
3 
4 
5 #include <cmath>
8 
9 namespace stan {
10  namespace math {
11 
19  template <typename T,int R, int C>
20  inline T log_determinant_spd(const Eigen::Matrix<T,R,C>& m) {
21  using std::log;
22  stan::math::check_square("log_determinant_spd(%1%)",m,"m",(double*)0);
23 // Eigen::TriangularView< Eigen::Matrix<T,R,C>, Eigen::Lower > L(m.llt().matrixL());
24 // T ret(0.0);
25 // for (size_t i = 0; i < L.rows(); i++)
26 // ret += log(L(i,i));
27 // return 2*ret;
28  return m.ldlt().vectorD().array().log().sum();
29  }
30 
31  }
32 }
33 #endif
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
bool check_square(const char *function, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name, T_result *result)
Return true if the specified matrix is square.
T log_determinant_spd(const Eigen::Matrix< T, R, C > &m)
Returns the log absolute determinant of the specified square matrix.

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