Last active
November 8, 2017 13:09
-
-
Save mchouza/2f74e3343c1848f6f6c6e7ff43563e98 to your computer and use it in GitHub Desktop.
Type promotion
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
In [1]: import numpy as np | |
In [2]: A = np.random.normal(size=(5000, 5000)) | |
In [3]: x = np.random.normal(size=5000) + 1j * np.random.normal(size=5000) | |
In [4]: %timeit np.dot(A, x) | |
1 loop, best of 3: 280 ms per loop | |
In [5]: %timeit np.dot(A, x.real) + 1j * np.dot(A, x.imag) | |
10 loops, best of 3: 22.1 ms per loop | |
In [6]: np.allclose(np.dot(A, x), np.dot(A, x.real) + 1j * np.dot(A, x.imag)) | |
Out[6]: True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment