3 ms·
You can speed up the numpy code by 2x by replacing the line: M_old = np.exp(1j*k*(np.tile(a,(N,1))**2 + np.tile(a.reshape(N,1),(1,N))**2)) with a_squ
by rahimiali 5y ago
You can speed up the numpy code by 2x by replacing the line:
M_old = np.exp(1j*k*(np.tile(a,(N,1))**2 + np.tile(a.reshape(N,1),(1,N))**2))
with
a_squared = a ** 2
M = np.exp(1j * k * (a_squared[:, None] + a_squared[None, :]))
This gets you to the same performance as single-threaded julia.