(c, imax)
| 31 | import numpy as np |
| 32 | import time |
| 33 | def nIter(c, imax): |
| 34 | nR,nC = c.shape |
| 35 | z = np.zeros_like(c) |
| 36 | img = np.zeros(z.shape, |
| 37 | dtype=np.uint8) |
| 38 | Idx = np.ones(z.shape, |
| 39 | dtype=np.bool ) |
| 40 | for i in range(imax): |
| 41 | z[Idx] = z[Idx]*z[Idx] + \ |
| 42 | c[Idx] |
| 43 | New = (z.real**2 + |
| 44 | z.imag**2 <= 4) |
| 45 | .reshape(nR,nC) |
| 46 | if not np.any(New): |
| 47 | break |
| 48 | img[New] = i |
| 49 | Idx *= New |
| 50 | return img |
| 51 | |
| 52 | def main(): |