diff --git a/src/DataInterpolations.jl b/src/DataInterpolations.jl index 7e998519..18249393 100644 --- a/src/DataInterpolations.jl +++ b/src/DataInterpolations.jl @@ -29,7 +29,7 @@ include("show.jl") (interp::AbstractInterpolation)(t::Number) = _interpolate(interp, t) (interp::AbstractInterpolation)(t::Number, i::Integer) = _interpolate(interp, t, i) -(interp::AbstractInterpolation)(t::AbstractVector) = interp(similar(t, eltype(interp)), t) +(interp::AbstractInterpolation)(t::AbstractVector) = interp(similar(t, promote_type(eltype(interp), eltype(t))), t) function (interp::AbstractInterpolation)(u::AbstractVector, t::AbstractVector) iguess = firstindex(interp.t) @inbounds for i in eachindex(u, t) diff --git a/test/derivative_tests.jl b/test/derivative_tests.jl index 241a4fc2..a3f08ddf 100644 --- a/test/derivative_tests.jl +++ b/test/derivative_tests.jl @@ -219,3 +219,15 @@ end ts = 0.0:0.1:1.0 @test all(map(ti -> symfunc(ti) == derivative(f, ti), ts)) end + +@testset "Jacobian tests" begin + u = rand(5) + t = 0:4 + interp = LinearInterpolation(u, t,extrapolate=true) + grad1 = ForwardDiff.derivative(interp,2.4) + + myvec = rand(20).*4.0 + interp(myvec) + + grad = ForwardDiff.jacobian(interp,myvec) +end