Created
January 26, 2018 15:59
-
-
Save DavidButts/bda3aae9b11e7f6328f0eda408839fa1 to your computer and use it in GitHub Desktop.
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 #timing | |
import numpy as np #arrays | |
import numba as nb #speed | |
x_dim = 1000 | |
y_dim = 1000 | |
x_min = -1.8 | |
x_max = 1.8 | |
y_min = -1.8j | |
y_max = 1.8j | |
z = np.zeros((y_dim,x_dim),dtype='complex128') | |
for l in range(y_dim): | |
z[l] = np.linspace(x_min,x_max,x_dim) -np.linspace(y_min,y_max,y_dim)[l] | |
def julia_numpy(c,z): | |
it = 0 | |
max_iter = 100 | |
while(it < max_iter): | |
z[np.absolute(z) < 10] = z[np.absolute(z) < 10]**2 + c #the logic in [] replaces our if statement. This line | |
it += 1 #updates the whole matrix at once, no need for loops! | |
return z | |
start = time.perf_counter() | |
julia_numpy(-.4+.6j,z) #arbitrary choice of c | |
end = time.perf_counter() | |
print(end-start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment