Remove incorrect solve
usage in psd_solve_with_chol
rewrite
#575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
To invert a positive semi-definite matrix, it is faster to first cholesky factorize the matrix then use two triangular solves rather than directly using solve. Here's a lazy benchmark:
The triangular method is about 1s faster. I've read it also more numerically stable too, but I don't know how to demonstrate that.
Anyway, there's a rewrite to change
pt.linalg.solve
to something like thetri_solve
function above if theA
matrix has a"psd"
tag. This rewrite is actually useless -- as far as I can tell, the psd is never used in the code base. But it is potentially useful in light of #573. It's also currently wrong: as pointed out in #382,solve(tri_A, b, assume_a='sym', lower=True)
does NOT use the correct algorithm to solve a triangular matrix, and results in an incorrect computation.This PR corrects the rewrite to use the correct computations, but does nothing else to make it used anywhere in the code base.
Related Issue
tag_solve_triangular
doesn't use a triangular solver #382Checklist
Type of change