Advertisement
morty0505

Untitled

Oct 9th, 2016
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. def mandel_iter_vectorized(a,b,Nx,Ny,max_escape_time):
  2. escape_times = np.empty((Ny,Nx))
  3. escape_times[:] = -1
  4.  
  5. x = np.zeros([Ny,Nx])
  6. y = np.zeros([Ny,Nx])
  7.  
  8.  
  9. for count in range(max_escape_time+1):
  10. print("count",count)
  11. print("escape",escape_times)
  12. x_pow_2 = x**2
  13. y_pow_2 = y**2
  14. below = x_pow_2 + y_pow_2 <= 4 #get the points the are not diverging
  15.  
  16. xtemp=x[below]
  17. x[below] = x_pow_2[below] - y_pow_2[below] + a[below]
  18. y[below] = 2*xtemp*(y[below]) + b[below]
  19. # print(below)
  20. escape_times += below
  21.  
  22. print("res",escape_times)
  23. return escape_times
  24.  
  25.  
  26.  
  27.  
  28.  
  29. 3 3 -2 1 -1 1 5 2 1
  30. count 0
  31. escape [[-1. -1. -1.]
  32. [-1. -1. -1.]
  33. [-1. -1. -1.]]
  34. count 1
  35. escape [[ 0. 0. 0.]
  36. [ 0. 0. 0.]
  37. [ 0. 0. 0.]]
  38. count 2
  39. escape [[ 0. 1. 1.]
  40. [ 1. 1. 1.]
  41. [ 0. 1. 1.]]
  42. count 3
  43. escape [[ 0. 2. 1.]
  44. [ 2. 2. 2.]
  45. [ 0. 2. 1.]]
  46. count 4
  47. escape [[ 0. 3. 1.]
  48. [ 3. 3. 2.]
  49. [ 0. 3. 1.]]
  50. count 5
  51. escape [[ 0. 3. 1.]
  52. [ 4. 4. 2.]
  53. [ 0. 3. 1.]]
  54. res [[ 0. 3. 1.]
  55. [ 5. 5. 2.]
  56. [ 0. 3. 1.]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement