Created
March 19, 2017 01:07
-
-
Save MikaelSlevinsky/09c43db2652d18a94483188a0099f373 to your computer and use it in GitHub Desktop.
Timings and errors between hierarchical, Toeplitz-dot-Hankel, and asymptotic methods for converting Legendre expansions to Chebyshev expansions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FastTransforms, PyPlot | |
N = 40 | |
t = Matrix{Float64}(N,6) | |
err = Matrix{Float64}(N,3) | |
for i in 1:N | |
n = round(Int64, 10.0^(1 + 5*((i-1)/(N-1)))) | |
v = rand(n) | |
println("n = ",n) | |
leg2cheb(v); | |
FastTransforms.th_leg2cheb(v); | |
cjt(v,0.,0.); | |
t[i,1] = @elapsed c1 = leg2cheb(v); | |
t[i,2] = @elapsed c2 = FastTransforms.th_leg2cheb(v); | |
t[i,3] = @elapsed c3 = cjt(v,0.,0.); | |
p = plan_leg2cheb(v); | |
p*v; | |
t[i,4] = @elapsed p*v; | |
p = FastTransforms.th_leg2chebplan(eltype(v),length(v)); | |
p*v; | |
t[i,5] = @elapsed p*v; | |
p = plan_cjt(v,0.,0.); | |
p*v; | |
t[i,6] = @elapsed p*v; | |
gc() | |
err[i,1] = norm(c1-c2,Inf) | |
err[i,2] = norm(c1-c3,Inf) | |
err[i,3] = norm(c2-c3,Inf) | |
end | |
NN = round.(Int,logspace(1,6,N)) | |
clf(); | |
loglog(NN,t[:,1],"^r",NN,t[:,2],"sg",NN,t[:,3],"pb") | |
loglog(NN,t[:,4],"vr",NN,t[:,5],"og",NN,t[:,6],"hb") | |
legend(["HODLR Total","T.*H Total","ASY Total","HODLR Execution","T.*H Execution","ASY Execution"],loc="upper left") | |
xlabel("\$N\$");ylabel("Execution Time (s)");grid(true) | |
savefig("Timings.png";bbox_inches="tight",dpi=300) | |
clf(); | |
loglog(NN,err[:,1],"^r",NN,err[:,2],"sg",NN,err[:,3],"pb") | |
legend(["\$\|\|\$HODLR-T.*H\$\|\|_{\\infty}\$","\$\|\|\$HODLR-ASY\$\|\|_{\\infty}\$","\$\|\|\$T.*H-ASY\$\|\|_{\\infty}\$"],loc="upper left") | |
xlabel("\$N\$");ylabel("Maximum Absolute Error");grid(true) | |
savefig("Error.png";bbox_inches="tight",dpi=300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it already known how transforms based on Potts, Steidl and Tasche (https://doi.org/10.1090/S0025-5718-98-00975-2) will fare in a comparison like this?