Created
December 22, 2021 17:49
-
-
Save nschloe/4d604c30ac3dda239413de0c2c595f82 to your computer and use it in GitHub Desktop.
np.linalg.solve vs np.linalg.solve (twice)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import perfplot | |
import numpy as np | |
def inv(AX): | |
A, X = AX | |
Ainv = np.linalg.inv(A) | |
return Ainv @ X @ Ainv.T | |
def double_solve(AX): | |
A, X = AX | |
return np.linalg.solve(A, np.linalg.solve(A, X).T).T | |
b = perfplot.bench( | |
setup=lambda n: (np.random.rand(n, n), np.random.rand(n, n)), | |
kernels=[inv, double_solve], | |
n_range=[2 ** k for k in range(10)], | |
) | |
b.save("out.png") | |
b.show() |
Author
nschloe
commented
Dec 22, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment