Skip to content

Commit 35eb4f5

Browse files
lxvmstevengj
andauthored
Fix type instability in chebinterp (#19)
* initial commit * Update interp.jl * Update src/interp.jl Co-authored-by: Steven G. Johnson <[email protected]> --------- Co-authored-by: Steven G. Johnson <[email protected]>
1 parent dc4902b commit 35eb4f5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/interp.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function droptol(coefs::Array{<:Any,N}, tol::Real) where {N}
8080
newsize = ntuple(Val{N}()) do dim
8181
n = size(coefs, dim)
8282
while n > 1
83-
r = ntuple(i -> i == dim ? (n:n) : (1:size(coefs,i)), Val{N}())
83+
r = let n=n; ntuple(i -> i == dim ? (n:n) : (1:size(coefs,i)), Val{N}()); end
8484
any(c -> infnorm(c) abstol, @view coefs[CartesianIndices(r)]) && break
8585
n -= 1
8686
end

test/runtests.jl

+5
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,8 @@ end
149149
@test interp([0.1,0.22]) 3.2*cos(0.55)
150150
@test chebgradient(interp, [0.1,0.2])[2] == [2*cos(0.55), 0]
151151
end
152+
153+
@testset "inference" begin
154+
@inferred FastChebInterp.droptol(rand(5,5), 0.0)
155+
@inferred chebinterp(rand(5,5), (0,0), (1,1))
156+
end

0 commit comments

Comments
 (0)