Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: eltype of N in spline_coefficients to allow working with dual numbers #242

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

sathvikbhagavan
Copy link
Member

This would allow to use ForwardDiff for derivatives of BSplines

MWE:

using DataInterpolations, ForwardDiff

u = [14.7, 11.51, 10.41, 14.95, 12.24, 11.22]
t = [0.0, 62.25, 109.66, 162.66, 205.8, 252.3]

sd = t -> ForwardDiff.derivative(Base.Fix1(DataInterpolations.derivative, A), t)
sd(0.0)

Stacktrace:

ERROR: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{Base.Fix1{typeof(DataInterpolations.derivative), BSplineInterpolation{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, true, Float64}}, Float64}, Float64, 1})

Closest candidates are:
  (::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat
   @ Base rounding.jl:207
  (::Type{T})(::T) where T<:Number
   @ Core boot.jl:792
  Float64(::Float32)
   @ Base float.jl:261
  ...

This PR should fix it.

@sathvikbhagavan
Copy link
Member Author

CI failures are all codecov related.

@ChrisRackauckas ChrisRackauckas merged commit 36f9dc0 into SciML:master Apr 19, 2024
7 of 10 checks passed
@sathvikbhagavan sathvikbhagavan deleted the sb/bspline_derivative branch May 7, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants