From 67c6e81427a68f9a97adedb74b4e156d8e3e37c3 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Fri, 7 Mar 2025 07:22:10 +0100 Subject: [PATCH] Fix PCHIP du computation --- src/interpolation_utils.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/interpolation_utils.jl b/src/interpolation_utils.jl index 85edac07..ce4f6624 100644 --- a/src/interpolation_utils.jl +++ b/src/interpolation_utils.jl @@ -231,8 +231,8 @@ function get_parameters(A::QuinticHermiteSpline, idx) end function du_PCHIP(u, t) - h = diff(u) - δ = h ./ diff(t) + h = diff(t) + δ = diff(u) ./ h s = sign.(δ) function _du(k) @@ -255,7 +255,7 @@ function du_PCHIP(u, t) else w₁ = 2h[k] + h[k - 1] w₂ = h[k] + 2h[k - 1] - δ[k - 1] * δ[k] * (w₁ + w₂) / (w₁ * δ[k] + w₂ * δ[k - 1]) + (w₁ + w₂) / (w₁ / δ[k - 1] + w₂ / δ[k]) end else zero(eltype(δ))