-
-
Notifications
You must be signed in to change notification settings - Fork 46
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 type stability issue with linear interpolation #113 #115
Conversation
I'm not sure if I'm going about this the right way but it works. |
Note this changes how the derivative works. With the fast-path change the derivative of the LinearInterpolation at the exact time point is zero (from ForwardDiff) while previously it was the derivative of the current point and the next. |
Good point. Hopefully people don't rely too much on the derivative here. If they did then they should probably consider a different interpolation. However, you could also consider restricting the branches to when |
The derivative at the exact point is undefined but I think it is better to stay consistent with before and if they depend on the derivative they should probably use a better interpolation scheme. I've seen other tools use the average slope from either side for this but that seems like a different/hack interpolation method to me. |
They do more than they expect. For example, the ODE solver will differentiate at those points if using a stiff ODE solver, and it will step there if it's in a |
The derivative on the right would be preferred due to the ODE solver context. |
@GlenHertz can you do a patch bump? |
@ChrisRackauckas I'm not sure what a patch bump is but I added another commit for the derivative fix. I'm trying to get my code to work with NaNs and I ran into this odd case:
It is because if NaN is given then the |
The tests fail right now because using a NaN input for |
I have another update and this one looks good to me but please take a critical look. Originally, for input |
Test that the derivative at a point gives the derivative to the right? |
The fast path for linear interpolation when no interpolation is needed (time point is provided in vector) returned a different type which caused issues with types/performance with higher level code.
I ran some benchmarks and see no difference in performance.