Skip to content
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/core/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ Same logic as `_series_output_type` but accepts varargs for ND promotion
chains like `promote_type(Tv, Tg, Tq)`.
"""
@inline function _output_eltype(::Type{Tv}, types::Type...) where {Tv}
tn = Base.typename(Tv)
if tn.name === :SArray || tn.name === :MArray
Te = promote_type(eltype(Tv), types...)
params = Tv.parameters
return tn.wrapper{params[1], Te, params[3], params[4]}
end
Tr = promote_type(Tv, types...)
Tc = isconcretetype(Tr) ? Tr : Tv
# Ensure standard numerics produce Float coefficients (Int→Float64).
Expand Down
9 changes: 9 additions & 0 deletions test/ext/test_autodiff_ForwardDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1403,4 +1403,13 @@ const FI = FastInterpolations
@test cache_pb isa CubicSplineCache{DualT}
end

@testset "SVector / StaticArray AD support" begin
using StaticArrays
x = 1.0:10.0
y = [SA[t^2, 2.0 * t, 3.0] for t in x]
itp = linear_interp(x, y)
res = ForwardDiff.derivative(t -> itp(t)[1], 2.5)
@test res ≈ 5.0 atol = 1.0e-10
end

end # testset "AutoDiff Support"
Loading