{"id":1000,"date":"2012-12-03T23:18:10","date_gmt":"2012-12-03T15:18:10","guid":{"rendered":"http:\/\/www.hsyyf.me\/?p=1000"},"modified":"2012-12-03T23:18:10","modified_gmt":"2012-12-03T15:18:10","slug":"pythonxy%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.hsyyf.me\/?p=1000","title":{"rendered":"Pythonxy\u6d4b\u8bd5"},"content":{"rendered":"<p>\u6700\u8fd1\u8bd5\u4e86\u4e00\u4e0bPythonxy\uff0c\u96c6\u6210\u4e86Numpy\u548cScipy\u5305\u7684Py\uff0c\u5728\u529f\u80fd\u65b9\u9762\u57fa\u672c\u4e0a\u80fd\u548cMatlab\u76f8\u5ab2\u7f8e\u4e86\u3002\u9664\u4e86\u4e00\u4e9b\u4e13\u6709\u7684\u529f\u80fd\uff0cPy\u548cmatlab\u76f8\u5dee\u4e5f\u5c31\u5728\u901f\u5ea6\u4e0a\u4e86\uff0c\u6bd5\u7adf\u4e00\u4e2a\u662f\u7f16\u8bd1\u578b\u7a0b\u5e8f\uff0c\u4e00\u4e2a\u662f\u89e3\u91ca\u6027\u8bed\u8a00\uff0c\u5728\u901f\u5ea6\u65b9\u9762\u6709\u7740\u672c\u8d28\u4e0a\u7684\u533a\u522b\u3002\u4e0d\u8fc7Py\u7684Numpy\u5305\u91cc\u7684wave\u548cf2py\u6a21\u5757\uff0c\u80fd\u8ba9Py\u6709\u7740C\u548cFortran\u7684\u8fd0\u7b97\u901f\u5ea6\u3002<\/p>\n<p>\u95f2\u8bdd\u5c11\u8bf4\uff0c\u4e0b\u8fb9\u662f\u751f\u6210\u8568\u7c7b\u690d\u7269\u53f6\u5b50\u7684\u4e00\u6bb5\u7a0b\u5e8f\uff0c\u4e3b\u8981\u662f\u751f\u6210\u5206\u5f62\u56fe\u5f62\u3002\u8568\u7c7b\u690d\u7269\u7684\u5c40\u90e8\u81ea\u76f8\u4f3c\u6027\u8f83\u9002\u5408\u505a\u5206\u5f62\u56fe\u5f62\uff0c\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u50cf\u7d20\u70b9\u9009\u62e9\u6709\u4e9b\u5c11\uff0c\u7b97\u51fa\u6765\u7684\u56fe\u7247\u771f\u5b9e\u611f\u5e76\u4e0d\u5f3a\u3002\u6e90\u7801\u6765\u81ea\u4e8e\u300aPython\u79d1\u5b66\u8ba1\u7b97\u300b<code lang=\"python\">import numpy as np<br \/>\nimport matplotlib.pyplot as pl<br \/>\nimport time<\/p>\n<p>ep1=np.array([[0,0,0],[0,0.16,0]])<br \/>\np1=0.01<\/p>\n<p>ep2=np.array([[0.2,-0.26,0],[0.23,0.24,0.44]])<br \/>\np2=0.7<\/p>\n<p>ep3=np.array([[-0.15,0.28,0],[0.26,0.24,0.44]])<br \/>\np3=0.07<\/p>\n<p>ep4=np.array([[0.85,0.04,0],[-0.04,0.85,1.6]])<br \/>\np4=0.85<\/p>\n<p>def ifs(p,eq,init,n):<br \/>\n      pos=np.ones(3,dtype=np.float)<br \/>\n      pos[:2]=init<\/p>\n<p>      p=np.add.accumulate(p)<br \/>\n      rands=np.random.rand(n)<br \/>\n      select=np.ones(n,dtype=np.int)*(n-1)<br \/>\n      for i,x in enumerate(p[::-1]):<br \/>\n            select[rands<x]=len(p)-i-1\n\n      result=np.zeros((n,2),dtype=np.float)\n      c=np.zeros(n,dtype=np.float)\n\n      for i in xrange(n):\n            eqidx=select[i]\n            tmp=np.dot(eq[eqidx],pos)\n            pos[:2]=tmp\n\n            result[i]=tmp\n            c[i]=eqidx\n\n      return result[:,0],result[:,1],c\n\nstart=time.clock()\nx,y,c=ifs([p1,p2,p3,p4],[ep1,ep2,ep3,ep4],[0,0],1000000)\nprint time.clock()-start\n\npl.figure(figsize=(6,6))\npl.subplot(121)\npl.scatter(x,y,s=1,c=\"g\",marker=\"s\",linewidth=0)\npl.axis(\"equal\")\npl.axis(\"off\")\npl.subplot(122)\npl.scatter(x,y,s=1,c=c,marker=\"s\",linewidth=0)\npl.axis(\"equal\")\npl.axis(\"off\")\npl.subplots_adjust(left=0,right=1,bottom=0,top=1,wspace=0,hspace=0)\npl.gcf().patch.set_facecolor(\"white\")\npl.show()\n<\/code><\/p>\n<p>\u8ba1\u7b97\u7684\u7ed3\u679c\uff1a<\/p>\n<p><a href=\"http:\/\/www.hsyyf.me\/wp-content\/uploads\/2012\/12\/image.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1003\" title=\"image\" src=\"http:\/\/www.hsyyf.me\/wp-content\/uploads\/2012\/12\/image-300x298.png\" alt=\"\" width=\"300\" height=\"298\" srcset=\"https:\/\/www.hsyyf.me\/wp-content\/uploads\/2012\/12\/image-300x298.png 300w, https:\/\/www.hsyyf.me\/wp-content\/uploads\/2012\/12\/image.png 600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n&nbsp;PS\uff1a \u4e3a\u4e86\u8fd9\u4e2a\u4e1c\u897f\uff0c\u8fd8\u662f\u56de\u5230\u4e86Py2.7\u3002=_=!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u8bd5\u4e86\u4e00\u4e0bPythonxy\uff0c\u96c6\u6210\u4e86Numpy\u548cScipy\u5305\u7684Py\uff0c\u5728\u529f\u80fd\u65b9\u9762\u57fa\u672c\u4e0a\u80fd\u548cMatlab\u76f8\u5ab2\u7f8e\u4e86\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[3],"tags":[87,136],"class_list":["post-1000","post","type-post","status-publish","format-standard","hentry","category-3","tag-python","tag-pythonxy"],"_links":{"self":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts\/1000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1000"}],"version-history":[{"count":0,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts\/1000\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}