Mandelbrot set: Difference between revisions

m
→‎Normalized Counting, Distance Estimation, Mercator Maps and Deep Zoom: Removed local variables (slightly slower but more readable)
m (→‎Normalized Counting, Distance Estimation, Mercator Maps and Deep Zoom: Replaced slow abs function with faster abs2 calculation)
m (→‎Normalized Counting, Distance Estimation, Mercator Maps and Deep Zoom: Removed local variables (slightly slower but more readable))
Line 8,979:
D, I, J = np.zeros(C.shape), np.zeros(C.shape, dtype=np.int64), np.zeros(C.shape, dtype=np.int64)
 
abs2_r = r ** 2
for k in range(n): # you can also try range(2*n) due to rebasing
abs2_ZM, abs2_ER = Z.real ** 2 + Z.imag ** 2 < r ** 2, Z.real ** 2 + Z.imag ** 2 < E.real ** 2 + E.imag ** 2
M, R = abs2_Z < abs2_r, abs2_Z < abs2_E
E[R], I[R] = Z[R], J[R] # rebase if z is closer to zero
E[M], I[M] = (2 * S[I[M]] + E[M]) * E[M] + C[M], I[M] + 1
305

edits