!"#$%&'()*(+,-.'%"-% /0-,+".%1,-#2,#'34%
56789%#2'3:%1'.:2('% ;(*)6%<:'='-%>6%?*$-3*-% @AB%C&&1"'/%@,:$'+,:".3D%@AB%;$03".3%
1
!"#$%&'()*(+,-.'%"-% /0-,+".%1,-#2,#'34% - - PowerPoint PPT Presentation
!"#$%&'()*(+,-.'%"-% /0-,+".%1,-#2,#'34% 56789%#2'3:%1'.:2('% ;(*)6%<:'='-%>6%?*$-3*-% @AB%C&&1"'/%@,:$'+,:".3D%@AB%;$03".3% 1 Dynamic languages for interactive math The two-language
1
2
— some problems are impossible or just very awkward to vectorize.
3
0.-,*-*#)1(')"
!-*#"GH$-+*#" L,'*-"MN*N" 2"TUV"F" C$II"J$K*#A(#" M@$I*#"O*'&,#A>," 23$).#"45567"8519:",#"459;7"<=5>"?(++,@A7" 2";5P"H$Q$-(&$'A"%,@N"955P"?(++,@A7" 851B:"'$-$*A$",#"C.#$"459D7" 9555P"$R@$'#*-"&*?>*)$A7"=@N"C.-,*S(#",#"459D"F" 915"'$-$*A$",#"!.).A@"459E"F"
!A"N,)NW-$Q$-"*#H",#@$'*?@,Q$"*A"T*@-*3"('"XY@N(#PUXY@N(#7" *A")$#$'*-W&.'&(A$"*A"XY@N(#7" *A"&'(H.?@,Q$"I('"@$?N#,?*-"%('>"*A"T*@-*3"('"XY@N(#PM?,XY7" 3.@"*A"!"#$%"#%&1"
4
('0"#)1)2)3456)476)896)("#"$%&":)
;<,=>)?numpy.vander@:)!"#$$#%&$'()*+&
=>&A-#).-+") 8B$%C/)D).-+") 8)B$%C/)("#"$%&"+)D).-+") &>C"E("#"$'.)%&)A'(AEF"0"F6)G<&) F-B)F"0"F)F','&"+)&-)/,%FF)/"&)-H)&>C"/I)
J$'&'#()H%/&).-+")K'#L)=>&A-#)-$)M%&F%G)2),'#'#()&A")/&%#+%$+)F'G$%$>) H-$)C$"EB$'&&"#)H<#.&'-#/)?',CF","#&"+)'#)D)-$)N-$&$%#@I) OH)&A")C$-GF",)+-"/#P&)K0".&-$'Q"L)'#&-)G<'F&E'#)H<#.&'-#/6) 'H)>-<)A%0")&-)B$'&")>-<$)-B#)'##"$)F--C/)8)/<.R/)H-$)>-<I)
5
;<,=>)?numpy.vander@:)!"#$$#%&$'()*+&
=>&A-#).-+") 8B$%C/)D).-+") 8)B$%C/)("#"$%&"+)D).-+") &>C"E("#"$'.)%&)A'(AEF"0"F6)G<&) F-B)F"0"F)F','&"+)&-)/,%FF)/"&)-H)&>C"/I)
J<F'%)?&>C"E("#"$'.).-+"@:)
function vander(x, n=length(x)) m = length(x) V = Array(eltype(x), m, n) for j = 1:m V[j,1] = one(x[j]) end for i = 2:n for j = 1:m V[j,i] = x[j] * V[j,i-1] end end return V end
('0"#)1)2)3456)476)896)("#"$%&":)
6
function vander(x, n=length(x)) m = length(x) V = Array(eltype(x), m, n)
#-&"0)1-$2/)3-$)%#4)).-#&%'#"$)
for j = 1:m
V[j,1] = one(x[j]) end
:)5"$3-$,%#.");)'#3<"='>'<'&4)
for i = 2:n for j = 1:m V[j,i] = x[j] * V[j,i-1] end end return V end
7
Special functions s(x): classic case that cannot be vectorized well … switch between various polynomials depending on x
Many of Julia’s special functions come from the usual C/Fortran libraries, but some are written in pure Julia code.
Pure Julia erfinv(x) [ = erf–1(x) ] 3–4× faster than Matlab’s and 2–3× faster than SciPy’s (Fortran Cephes). Pure Julia polygamma(m, z) [ = (m+1)th derivative of the ln Γ function ] ~ 2× faster than SciPy’s (C/Fortran) for real z … and unlike SciPy’s, same code supports complex argument z
8
9
MIT OpenCourseWare https://ocw.mit.edu
6.172 Performance Engineering of Software Systems
Fall 2018 For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.
10