Effacer les filtres
Effacer les filtres

chebyshevT is too slow

4 vues (au cours des 30 derniers jours)
htrh5
htrh5 le 6 Jan 2016
Modifié(e) : htrh5 le 6 Jan 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 )

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by