diff --git a/stan/math/rev/fun/cholesky_decompose.hpp b/stan/math/rev/fun/cholesky_decompose.hpp index 01d63b34d56..226674a8aa8 100644 --- a/stan/math/rev/fun/cholesky_decompose.hpp +++ b/stan/math/rev/fun/cholesky_decompose.hpp @@ -137,7 +137,7 @@ inline auto cholesky_decompose(EigMat&& A) { arena_t arena_A = std::forward(A_ref); arena_t> L_A(arena_A.val().eval()); - check_symmetric("cholesky_decompose", "A", A); + check_symmetric("cholesky_decompose", "A", L_A); Eigen::LLT, Eigen::Lower> L_factor(L_A); check_pos_definite("cholesky_decompose", "m", L_factor); diff --git a/stan/math/rev/fun/columns_dot_product.hpp b/stan/math/rev/fun/columns_dot_product.hpp index 704eb3ded9c..dae802002cc 100644 --- a/stan/math/rev/fun/columns_dot_product.hpp +++ b/stan/math/rev/fun/columns_dot_product.hpp @@ -35,11 +35,11 @@ inline Eigen::Matrix, 1, std::decay_t::ColsAtCompileTime> columns_dot_product(Mat1&& v1, Mat2&& v2) { check_matching_dims("check_matching_dims", "v1", v1, "v2", v2); - Eigen::Matrix::ColsAtCompileTime> ret(1, - v1.cols()); + const size_t v1_cols = v1.cols(); + Eigen::Matrix::ColsAtCompileTime> ret(1, v1_cols); decltype(auto) v1_ref = to_ref(std::forward(v1)); decltype(auto) v2_ref = to_ref(std::forward(v2)); - for (size_type j = 0; j < v1.cols(); ++j) { + for (size_type j = 0; j < v1_cols; ++j) { ret.coeffRef(j) = dot_product(v1_ref.col(j), v2_ref.col(j)); } return ret;