diff --git a/Project.toml b/Project.toml index e4f7aa67..ab15e6db 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "0.17.3" ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838" +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/src/BSplineKit.jl b/src/BSplineKit.jl index f23be67e..78e96a0d 100644 --- a/src/BSplineKit.jl +++ b/src/BSplineKit.jl @@ -2,7 +2,8 @@ module BSplineKit using Reexport using PrecompileTools -using LinearAlgebra: LinearAlgebra # needed for docs +using LinearAlgebra: LinearAlgebra +using ForwardDiff # needed for docs include("BandedTensors/BandedTensors.jl") @reexport using .BandedTensors diff --git a/src/SplineExtrapolations/SplineExtrapolations.jl b/src/SplineExtrapolations/SplineExtrapolations.jl index 4496952e..2f923872 100644 --- a/src/SplineExtrapolations/SplineExtrapolations.jl +++ b/src/SplineExtrapolations/SplineExtrapolations.jl @@ -41,14 +41,13 @@ struct Linear <: AbstractExtrapolationMethod end function extrapolate_at_point(::Linear, S::Spline, x) a, b = boundaries(basis(S)) if x < a - slope = (S(a + eps()) - S(a)) / eps() + slope = ForwardDiff.derivative(S, a) S(a) + slope * (x - a) elseif x > b - slope = (S(b) - S(b - eps())) / eps() + slope = ForwardDiff.derivative(S, b) S(b) + slope * (x - b) else - x′ = clamp(x, a, b) - S(x′) + S(x) end end