Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/LinearAlgebra/clenshaw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,20 @@ sineshaw(c::AbstractVector,θ::AbstractMatrix) = promote_type(eltype(c),eltype(


function chebyshev_clenshaw(c::AbstractVector, x)
N,T = length(c),promote_type(eltype(c),typeof(x))
N,T = length(c),promote_type(eltype(c),float(typeof(x)))
if N == 0
return zero(float(x) * oneunit(eltype(c)))
return zero(T)
elseif N == 1 # avoid issues with NaN x
return first(c) * oneunit(float(x))
end

x = 2x
y = 2x
bk1,bk2 = zero(T),zero(T)
@inbounds for k = N:-1:2
bk2, bk1 = bk1, muladd(x,bk1,c[k]-bk2)
bk2, bk1 = bk1, muladd(y,bk1,c[k]-bk2)
end

muladd(x/2,bk1,c[1]-bk2)
muladd(x,bk1,c[1]-bk2)
end


Expand Down