File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44#include < stan/math/prim/err.hpp>
55#include < stan/math/prim/fun/Eigen.hpp>
6- #include < stan/math/prim/fun/dot_self.hpp>
7- #include < stan/math/prim/fun/dot_product.hpp>
86#include < stan/math/prim/fun/mdivide_left_tri.hpp>
97#include < stan/math/prim/fun/inv_square.hpp>
8+ #include < stan/math/prim/fun/crossprod.hpp>
109
1110namespace stan {
1211namespace math {
@@ -35,17 +34,7 @@ plain_type_t<T> chol2inv(const T& L) {
3534 X.coeffRef (0 ) = inv_square (L_ref.coeff (0 , 0 ));
3635 return X;
3736 }
38- T_result L_inv = mdivide_left_tri<Eigen::Lower>(L_ref);
39- T_result X (K, K);
40- for (int k = 0 ; k < K; ++k) {
41- X.coeffRef (k, k) = dot_self (L_inv.col (k).tail (K - k).eval ());
42- for (int j = k + 1 ; j < K; ++j) {
43- int Kmj = K - j;
44- X.coeffRef (k, j) = X.coeffRef (j, k) = dot_product (
45- L_inv.col (k).tail (Kmj).eval (), L_inv.col (j).tail (Kmj).eval ());
46- }
47- }
48- return X;
37+ return crossprod (mdivide_left_tri<Eigen::Lower>(L_ref));
4938}
5039
5140} // namespace math
You can’t perform that action at this time.
0 commit comments