Skip to content

Commit

Permalink
Merge pull request #2981 from stan-dev/optimization-chol2inv
Browse files Browse the repository at this point in the history
Optimization for chol2inv
  • Loading branch information
spinkney authored Dec 6, 2023
2 parents 754e94e + fe5dc6d commit ffeedb5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stan/math/prim/fun/chol2inv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/dot_self.hpp>
#include <stan/math/prim/fun/dot_product.hpp>
#include <stan/math/prim/fun/mdivide_left_tri_low.hpp>
#include <stan/math/prim/fun/mdivide_left_tri.hpp>
#include <stan/math/prim/fun/inv_square.hpp>

namespace stan {
Expand Down Expand Up @@ -35,7 +35,7 @@ plain_type_t<T> chol2inv(const T& L) {
X.coeffRef(0) = inv_square(L_ref.coeff(0, 0));
return X;
}
T_result L_inv = mdivide_left_tri_low(L_ref, T_result::Identity(K, K));
T_result L_inv = mdivide_left_tri<Eigen::Lower>(L_ref);
T_result X(K, K);
for (int k = 0; k < K; ++k) {
X.coeffRef(k, k) = dot_self(L_inv.col(k).tail(K - k).eval());
Expand Down

0 comments on commit ffeedb5

Please sign in to comment.