Skip to content

Commit 7cfc72d

Browse files
Merge pull request #400 from SouthEndMusic/fix_pchip
Fix PCHIP du computation
2 parents bfcbae1 + 67c6e81 commit 7cfc72d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/interpolation_utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ function get_parameters(A::QuinticHermiteSpline, idx)
231231
end
232232

233233
function du_PCHIP(u, t)
234-
h = diff(u)
235-
δ = h ./ diff(t)
234+
h = diff(t)
235+
δ = diff(u) ./ h
236236
s = sign.(δ)
237237

238238
function _du(k)
@@ -255,7 +255,7 @@ function du_PCHIP(u, t)
255255
else
256256
w₁ = 2h[k] + h[k - 1]
257257
w₂ = h[k] + 2h[k - 1]
258-
δ[k - 1] * δ[k] * (w₁ + w₂) / (w₁ * δ[k] + w₂ * δ[k - 1])
258+
(w₁ + w₂) / (w₁ / δ[k - 1] + w₂ / δ[k])
259259
end
260260
else
261261
zero(eltype(δ))

0 commit comments

Comments
 (0)