Skip to content

Commit 0c1b65a

Browse files
committed
Update templating inside cholesky_decompose
1 parent 601a96a commit 0c1b65a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

stan/math/prim/fun/cholesky_decompose.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
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>
45
#include <stan/math/prim/meta.hpp>
56
#include <stan/math/prim/err.hpp>
6-
#include <stan/math/prim/fun/Eigen.hpp>
7-
8-
#include <cmath>
97

108
namespace stan {
119
namespace math {
@@ -31,12 +29,11 @@ template <typename EigMat, require_eigen_t<EigMat>* = nullptr,
3129
inline Eigen::Matrix<value_type_t<EigMat>, EigMat::RowsAtCompileTime,
3230
EigMat::ColsAtCompileTime>
3331
cholesky_decompose(const EigMat& m) {
34-
const eval_return_type_t<EigMat>& m_eval = m.eval();
32+
using PlainMat = plain_type_t<EigMat>;
33+
PlainMat m_eval = m;
3534
check_symmetric("cholesky_decompose", "m", m_eval);
3635
check_not_nan("cholesky_decompose", "m", m_eval);
37-
Eigen::LLT<Eigen::Matrix<value_type_t<EigMat>, EigMat::RowsAtCompileTime,
38-
EigMat::ColsAtCompileTime>>
39-
llt = m_eval.llt();
36+
Eigen::LLT<PlainMat> llt = m_eval.llt();
4037
check_pos_definite("cholesky_decompose", "m", llt);
4138
return llt.matrixL();
4239
}

0 commit comments

Comments
 (0)