Azzera filtri
Azzera filtri

chebyshevT is too slow

4 visualizzazioni (ultimi 30 giorni)
htrh5
htrh5 il 6 Gen 2016
Modificato: htrh5 il 6 Gen 2016
This function takes an eternity to compute. I have written a workaround that works about 75 times faster for me but I am curious why this is so. It is probable that many other special functions compute slower than they need to.
N=4096;
w=(-N/2:N/2-1)/sqrt(N);
n=8;
tic;x1=chebyshevT(n,w);toc;%2.720533
tic;
A=zeros(n+1,n+1);
for i = 1:n+1
for j = 1:n+1
A(i,j)= (i-1).^(j-1);
end
end
coefs = A\chebyshevT(n,(1:n+1)-1)';
x2 = polyval(flipud(coefs),w);
toc;%0.035399
sqrt( sum((x1-x2).^2)/sum(x1.^2) )
max( abs(x1-x2)/x1 )

Risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by