Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1146a94

Browse files
mandelbrot start
1 parent689a015 commit1146a94

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

‎ufo/mandelbrot0.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
importnumpyasnp
2+
importmatplotlib.pyplotasplt
3+
4+
5+
defmain():
6+
plt.imshow(mandelbrot(400,400))
7+
plt.show()
8+
9+
10+
defmandelbrot(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+
foriinrange(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+
returndivtime
23+
24+
25+
if__name__=="__main__":
26+
main()

‎ufo/numpyogrid.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
importnumpyasnp
2+
3+
4+
defmain():
5+
first_ogid()
6+
7+
8+
deffirst_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()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp