14年3个月前IP:未同步
456586
6楼
import numpy as np
import pylab as pl
import time
from matplotlib import cm

def draw_mandelbrot(cx, cy, d, N=200):
    global mandelbrot


    x0, x1, y0, y1 = cx+d, cx-d, cy-d, cy+d
    y, x = np.ogrid[y0:y1:N*1j, x0:x1:N*1j]
    c = x + y*1j

    ix, iy = np.mgrid[0:N, 0:N]
    
    mandelbrot = np.ones(c.shape, dtype=XXXXXX)*100

    ix.shape = -1
    iy.shape = -1
    c.shape = -1
    z = c.copy()

    start = time.clock();

    for i in xrange(1, 100):
        z *= z
    z += c

    tmp = np.abs(z) > 2.0
    mandelbrot[ix[tmp], iy[tmp]] = i

    np.logical_not(tmp, tmp)

    ix, iy, c, z = ix[tmp], iy[tmp], c[tmp], z[tmp]

    if len(z) == 0: break

    print "time=", time.clock() - start
    pl.imshow(mandelbrot, cmap=cm.Blues_r, extent=[x0, x1, y0, y1])
    pl.gca().set_axis_off()

x,y = 0.27322626, 0.595153338

draw_mandelbrot(-0.5, 0, 1.5)
for i in range(2, 4):
    draw_mandelbrot(x, y, 0.2**(i-1))
pl.show()
评论
文号 / 456586

百炼成钢
名片发私信
学术分 0
总主题 39 帖总回复 1066 楼拥有证书:进士 机友 笔友
注册于 2008/01/25 20:59:00最后登录 2026/04/28 18:32:57
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:0

个人简介

暂未填写
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的