Borrar filtros
Borrar filtros

chebyshevT is too slow

4 visualizaciones (últimos 30 días)
htrh5
htrh5 el 6 de En. de 2016
Editada: htrh5 el 6 de En. de 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 )

Respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by