Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Fix monotonic cubic interpolation #69

Open
magnusw opened this issue Jul 31, 2013 · 1 comment
Open

Fix monotonic cubic interpolation #69

magnusw opened this issue Jul 31, 2013 · 1 comment
Assignees

Comments

@magnusw
Copy link
Collaborator

magnusw commented Jul 31, 2013

if (delta_k == static_cast(0)) {
d_k = static_cast(0);
d_k1 = static_cast(0);
}

should really be

if (delta_k == static_cast(0) ||
(sign(d_k) != sign(delta_k) || sign(d_k1) != sign(delta_k))) {
d_k = static_cast(0);
d_k1 = static_cast(0);
}

@ghost ghost assigned magnusw Jul 31, 2013
@jbrd
Copy link

jbrd commented Jan 2, 2021

I ended up running into this issue when reading the book, and it inspired a bit of personal investigation into monotone cubic interpolation, so thanks for this - https://jbrd.github.io/2020/12/27/monotone-cubic-interpolation.html. I end up mentioning this issue in the post because the suggested fix mentioned above doesn't guarantee monotonicity either - that is, if you have gradients with matching signs that happen to be extreme enough, you may still end up with overshoot. As part of my post, I knocked up a quick example of this here: https://www.desmos.com/calculator/sppxx0thx3. Hope its useful :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants