Skip to content

Instantly share code, notes, and snippets.

@MikaelSlevinsky
Last active August 29, 2015 14:21
Show Gist options
  • Save MikaelSlevinsky/e53237fcf4064bc577c7 to your computer and use it in GitHub Desktop.
Save MikaelSlevinsky/e53237fcf4064bc577c7 to your computer and use it in GitHub Desktop.
Test coefficient- and value-based multiplication
using PyCall
pygui(:tk)
using PyPlot
using ApproxFun
gc()
gc_disable()
N = 36
M_coefficient = zeros(N,N)
M_fft = zeros(N,N)
for i = 1:N, j = 1:N
ci,cj = rand(round(Int64,10^(i/9))),rand(round(Int64,10^(j/9)))
if log10(length(ci))*log10(length(cj)) < 8
Fi,Fj = Fun(ci,[-1,1]),Fun(cj,[-1,1])
Fi*Fj;Fi*Fj
ApproxFun.transformtimes(Fi,Fj);ApproxFun.transformtimes(Fi,Fj)
M_coefficient[i,j] = @elapsed for k = 1:10
Fi*Fj
end
M_fft[i,j] = @elapsed for k = 1:10
ApproxFun.transformtimes(Fi,Fj)
end
else
M_fft[i,j] = 1.0
M_coefficient[i,j] = 20.0
end
gc_enable()
gc()
gc_disable()
end
gc_enable()
gc()
C = 324
t = linspace(0,36,101)
clf()
contourf(log10(M_coefficient./M_fft),20;cmap="seismic",vmin=-1.8,vmax=1.8)
plot(t,C./t,"-k")
xlim([0,N-1]);ylim([0,N-1])
xticks(0:2:N-1,round(Int64,10.^((0:2:N-1)/9)))
yticks(0:2:N-1,round(Int64,10.^((0:2:N-1)/9)))
xlabel("\$ i \$");ylabel("\$ j \$")
colorbar();
savefig("Multplot.png";bbox_inches="tight")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment