-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching of the LU decomposition computed by _InverseLinearOperator
#737
Caching of the LU decomposition computed by _InverseLinearOperator
#737
Conversation
@JonathanWenger This PR should be reviewed after #735 is merged, since it branches off of it. |
1a45b57
to
3cb5808
Compare
Codecov Report
@@ Coverage Diff @@
## main #737 +/- ##
==========================================
- Coverage 90.40% 90.36% -0.05%
==========================================
Files 197 197
Lines 7454 7431 -23
Branches 966 964 -2
==========================================
- Hits 6739 6715 -24
- Misses 481 482 +1
Partials 234 234
|
3cb5808
to
5250482
Compare
5250482
to
d5fffce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Elegant solution of the circular dependency issue.
Returns | ||
------- | ||
sol | ||
The solutions :math:`A^{-1} X` of the linear systems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solutions :math:`A^{-1} X` of the linear systems. | |
The solution(s) :math:`A^{-1} X` of the linear system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually always have multiple solutions here, since this method only works if x.ndim == 2
.
I added an appropriate assertion.
3762db8
to
f206691
Compare
In a Nutshell
Currently, executing
runs
scipy.linalg.lu_factor
onA.dense
twice.In principle, it would be possible to cache the return value of
A.inv()
, but that would introduce cyclic references,which might cause memory overhead before being collected by the garbage collector.
An elegant solution is to cache all expensive quantities in the linear operator
A
itself, and then create "throwaway" objects like_InverseLinearOperator
andTransposeLinearOperator
, which are essentially views ofA
, accessing these quantities through the base linear operator.Detailed Description
LinearOperator
s_InverseLinearOperator.__rmatmul__
_InverseLinearOperator
LinearOperator.broadcast_matmul
withnp.vectorize
-based implementationRelated Issues
None