Stan
1.3
probability, sampling & optimization
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
Pages
src
stan
math
matrix
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>
6
#include <
stan/math/matrix/Eigen.hpp
>
7
#include <
stan/math/matrix/validate_square.hpp
>
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::validate_square
(m,
"log_determinant_spd"
);
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
[
Stan Home Page
]
© 2011–2013, Stan Development Team.