Created
July 24, 2020 11:02
-
-
Save yoshipon/4d2e5c7aca17bfa7fbcc82d9733dafa5 to your computer and use it in GitHub Desktop.
A tiny benchmark script
This file contains 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 time | |
import numpy as np | |
def make_psd_matrix(M, T): | |
tmp = np.random.randn(T, M, M) + 1j * np.random.randn(T, M, M) | |
return np.einsum("tmn,tno->tmo", tmp, tmp.conj()) | |
if __name__ == "__main__": | |
M = 10 | |
T = 1000 | |
elapsed_times = [] | |
for _ in range(100): | |
A = make_psd_matrix(M, T) | |
B = make_psd_matrix(M, T) | |
start = time.time() | |
C = np.einsum("tmn,tmo->tmo", np.linalg.inv(A), B) | |
elapsed_times.append(time.time() - start) | |
print(np.mean(elapsed_times)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment