11#ifndef STAN_MATH_PRIM_FUN_CHOLESKY_DECOMPOSE_HPP
22#define STAN_MATH_PRIM_FUN_CHOLESKY_DECOMPOSE_HPP
33
4- #include < stan/math/prim/fun/Eigen.hpp>
54#include < stan/math/prim/meta.hpp>
65#include < stan/math/prim/err.hpp>
6+ #include < stan/math/prim/fun/Eigen.hpp>
7+
8+ #include < cmath>
79
810namespace stan {
911namespace math {
@@ -26,14 +28,11 @@ namespace math {
2628 */
2729template <typename EigMat, require_eigen_t <EigMat>* = nullptr ,
2830 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);
3433 check_symmetric (" cholesky_decompose" , " m" , m_eval);
3534 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 ();
3736 check_pos_definite (" cholesky_decompose" , " m" , llt);
3837 return llt.matrixL ();
3938}
0 commit comments