Skip to content

Instantly share code, notes, and snippets.

@yoshipon
Created July 24, 2020 11:02
Show Gist options
  • Save yoshipon/4d2e5c7aca17bfa7fbcc82d9733dafa5 to your computer and use it in GitHub Desktop.
Save yoshipon/4d2e5c7aca17bfa7fbcc82d9733dafa5 to your computer and use it in GitHub Desktop.
A tiny benchmark script
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