1
1
#ifndef STAN_MATH_PRIM_FUN_CHOLESKY_DECOMPOSE_HPP
2
2
#define STAN_MATH_PRIM_FUN_CHOLESKY_DECOMPOSE_HPP
3
3
4
- #include < stan/math/prim/fun/Eigen.hpp>
5
4
#include < stan/math/prim/meta.hpp>
6
5
#include < stan/math/prim/err.hpp>
6
+ #include < stan/math/prim/fun/Eigen.hpp>
7
+
8
+ #include < cmath>
7
9
8
10
namespace stan {
9
11
namespace math {
@@ -26,14 +28,11 @@ namespace math {
26
28
*/
27
29
template <typename EigMat, require_eigen_t <EigMat>* = nullptr ,
28
30
require_not_eigen_vt<is_var, EigMat>* = nullptr >
29
- inline Eigen::Matrix<value_type_t <EigMat>, EigMat::RowsAtCompileTime,
30
- EigMat::ColsAtCompileTime>
31
- cholesky_decompose (const EigMat& m) {
32
- using PlainMat = plain_type_t <EigMat>;
33
- PlainMat m_eval = m;
31
+ inline plain_type_t <EigMat> cholesky_decompose (const EigMat& m) {
32
+ auto && m_eval = to_ref (m);
34
33
check_symmetric (" cholesky_decompose" , " m" , m_eval);
35
34
check_not_nan (" cholesky_decompose" , " m" , m_eval);
36
- Eigen::LLT<PlainMat > llt = m_eval.llt ();
35
+ Eigen::LLT<plain_type_t <EigMat> > llt = m_eval.llt ();
37
36
check_pos_definite (" cholesky_decompose" , " m" , llt);
38
37
return llt.matrixL ();
39
38
}
0 commit comments