diff --git a/NEWS.md b/NEWS.md index 47c710a84..4b83d51be 100644 --- a/NEWS.md +++ b/NEWS.md @@ -35,6 +35,7 @@ Also allow the method to be used on models with categorical data ([#315](https: Now heavily utilizing [snapshots](https://testthat.r-lib.org/articles/snapshotting.html) on a large set of benchmark calls to `explain`, also using [vdiffr](https://vdiffr.r-lib.org/) for plot tests. Test functions are only written for exported core functions. Internal functions are only tested through the exported ones. * Update GitHub actions ([#335](https://github.com/NorskRegnesentral/shapr/pull/335)). +* Avoid unnecessary computation of inverse for weight matrix ([#280](https://github.com/NorskRegnesentral/shapr/issues/280)) ## Minor improvements and bug fixes diff --git a/src/weighted_matrix.cpp b/src/weighted_matrix.cpp index 334ae17dc..8b71520ad 100644 --- a/src/weighted_matrix.cpp +++ b/src/weighted_matrix.cpp @@ -69,7 +69,7 @@ arma::mat weight_matrix_cpp(List subsets, int m, int n, NumericVector w){ } } - R = inv(X.t() * Z) * X.t(); + R = solve(X.t() * Z, X.t()); return R; }