File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import numpy as np
2+ import matplotlib .pyplot as plt
3+
4+
5+ def main ():
6+ plt .imshow (mandelbrot (400 , 400 ))
7+ plt .show ()
8+
9+
10+ def mandelbrot (w , h , maxit = 200 ):
11+ y , x = np .ogrid [- 1.4 :1.4 :h * 1j , - 2 :0.8 :w * 1j ]
12+ c = x + y * 1j
13+ z = c
14+ divtime = maxit + np .zeros (z .shape , dtype = int )
15+
16+ for i in range (maxit ):
17+ z = z ** 2 + c
18+ diverge = z * np .conj (z ) > 2 ** 2
19+ div_now = diverge & (divtime == maxit )
20+ divtime [div_now ] = i
21+ z [diverge ] = 2
22+ return divtime
23+
24+
25+ if __name__ == "__main__" :
26+ main ()
Original file line number Diff line number Diff line change 1+ import numpy as np
2+
3+
4+ def main ():
5+ first_ogid ()
6+
7+
8+ def first_ogid ():
9+ x , y = np .ogrid [1 :4 :1 , 1 :5 :2 ]
10+ print (x )
11+ print (y )
12+ x , y = np .ogrid [1 :4 :3j , 1 :5 :2j ]
13+ print (x )
14+ print (y )
15+ x = np .ogrid [1 :5 :2 ]
16+ print (x )
17+
18+
19+ if __name__ == "__main__" :
20+ main ()
You can’t perform that action at this time.
0 commit comments