-
Notifications
You must be signed in to change notification settings - Fork 9
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
Added Linear() extrapolation method #93
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #93 +/- ##
==========================================
- Coverage 95.61% 94.91% -0.71%
==========================================
Files 35 35
Lines 2237 2224 -13
==========================================
- Hits 2139 2111 -28
- Misses 98 113 +15 ☔ View full report in Codecov by Sentry. |
Thanks, this can be useful indeed! I'd just be a bit careful about using finite differences with First, because calling The second problem is that, if one takes two "consecutive" numbers julia> x = 2.0
2.0
julia> y = x + eps(x) # or y = nextfloat(x)
2.0000000000000004
julia> sqrt(x) == sqrt(y) # true!
true A solution would be to use the actual derivatives of the spline at the boundary locations to perform the extrapolations. Right now BSplineKit.jl doesn't allow to get a derivative at a single point This will be clearer with an example: using BSplineKit
xs = 0.2:0.2:10.2
ys = sqrt.(xs)
S = interpolate(xs, ys, BSplineOrder(4))
a, b = boundaries(basis(S)) To obtain the derivative of S′ = Derivative() * S
S′(a) # 1.0738781882215265 But this is actually overkill as it requires first computing the spline derivative using ForwardDiff
ForwardDiff.derivative(S, a) # 1.0738781882215263 In my opinion we can follow that last strategy. This will require adding ForwardDiff.jl as a dependency, but that's fine for me. |
Thanks, I agree that using ForwardDiff is a much better solution. I've pushed an update Linear() function but for some reason can't get the dependencies to work properly when I do a test run in the interpolations.jl file in the examples. Probably something to do with building the package locally. Does it work properly if you pull my changes in? |
Not sure, but it may be related to the other changes made in |
Yup, that'll do it. Everything is working on my end now, I think it's ready for review. |
hopefully this fixes the CI error
Looks good to me, thanks! |
Excellent, thank you too! |
Added linear extrapolation method. The slope at the boundaries is calculated via finite differences.
(Hope the pull request is OK and this is helpful. Thanks for creating this package!)