Repository navigation
Add MonotonicMakimaInterpolation: makima slopes with a Fritsch–Carlson monotonicity limiter - #630
asinghvi17 wants to merge 25 commits into
Conversation
…iter) Adds `MonotonicMakimaInterpolation(u, t; kwargs...)`, a shape-preserving variant of makima. Like `PCHIPInterpolation`, it computes knot slopes and returns a `CubicHermiteSpline`, so extrapolation, derivatives, integrals and `cache_parameters` work as for any Hermite spline. The slopes are: 1. the makima slopes of `AkimaInterpolation(u, t; modified = true)`, reusing the existing kernel (split out of `_akima_init!` as `_akima_slopes!`); 2. a sign pass that zeroes a slope whose sign differs from an adjacent secant, or whose adjacent secant is zero (flat segments stay flat); 3. a square Fritsch-Carlson limiter: per segment, left to right, if max(alpha, beta) > 3 both end slopes are scaled by 3 / max(alpha, beta). Where steps 2 and 3 do not act, the result is identical to makima. Also fixes `AkimaInterpolation` with two points, which read an uninitialized ghost secant; it now gives the straight line through the two points. The per-dimension wrappers of `du_PCHIP` are generalized into `_du_per_dimension` and shared by both slope kernels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Harness: claude Model: claude-opus-5-5 Factory-Task: 22fff5cb-ab23-4f6c-a31f-195f557afeb0 Agent-Harness: Claude 2.1.319 Agent-Model: claude-opus-5-5 Agent-Session: factory task 22fff5cb-ab23-4f6c-a31f-195f557afeb0 on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
…, β) When max(α, β) > 3 on a segment, compute r = 3 / max(α, β) once and multiply both end slopes by it. This is the conventional form of the square rule. Previously the slopes were set to 3s * (α / max(α, β)) and 3s * (β / max(α, β)), which made the larger one exactly 3s; now it is 3s up to rounding (a few ulps). Since r <= 1, a limited slope still never grows. The docstring describes the rounding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Harness: claude Model: claude-opus-5-5 Factory-Task: 8d831c30-b5f6-4950-9cba-449eed9c4c5f Agent-Harness: Claude 2.1.319 Agent-Model: claude-opus-5-5 Agent-Session: factory task 8d831c30-b5f6-4950-9cba-449eed9c4c5f on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
Reduce the MonotonicMakimaInterpolation tests to a compact set: monotone output on a few random tables, equality with makima where the limiter is inactive, flat segments, limiter scaling (checks du == r * makima slope), 2-point tables, and an extrapolation/caching smoke test, plus derivative checks against finite differences for Vector and Matrix data. Drop the 200-case sweep, the redundant edge cases, the integral testset and the second docs example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Harness: claude Model: claude-opus-5-5 Factory-Task: 8d831c30-b5f6-4950-9cba-449eed9c4c5f Agent-Harness: Claude 2.1.319 Agent-Model: claude-opus-5-5 Agent-Session: factory task 8d831c30-b5f6-4950-9cba-449eed9c4c5f on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
Used in the citation "SIAM J. Numer. Anal." in the MonotonicMakimaInterpolation docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Harness: claude Model: claude-opus-5-5 Factory-Task: 8d831c30-b5f6-4950-9cba-449eed9c4c5f Agent-Harness: Claude 2.1.319 Agent-Model: claude-opus-5-5 Agent-Session: factory task 8d831c30-b5f6-4950-9cba-449eed9c4c5f on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
Independent review (Codex CLI v0.164.0 / gpt-6.1-sol), reviewer session 01a1cda4-7034-7830-83b8-cdffb8fe42cb, reviewed head 9356087
This is a blind code-only review by a session other than the PR author's, copied below from the reviewer's report with only the grading metadata removed. The posting agent did not re-run the reviewer's commands. A MERGE verdict is advice; merging is left to the maintainers. CI: green Riskmedium-low (ML7: additive exported interpolation constructor; ML1: two-point Akima correction reproduced against the base). Blocking findings
Non-blocking findings
What I ran
What I did not verify
🤖 Posted by an AI agent — harness: Claude Code 2.1.322 · model: claude-sonnet-5-5 |
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: 031f1039-f80a-483c-925b-8c42fd463210 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task 031f1039-f80a-483c-925b-8c42fd463210 on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: 2ac96216-b848-4d94-88f8-f574017c8dbc Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task 2ac96216-b848-4d94-88f8-f574017c8dbc on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
PR: #630 Reviewed head: b4d3f1b Risk assessment
Review reportVERDICT: CHANGES Riskmedium (M2: The slope storage change turns finite results into The affected users construct scalar or array-valued interpolants through Blocking findings
Nonblocking findings
What I ran
What I did not verify
Head link: b4d3f1b 🤖 Posted by an AI agent — harness: codex-cli 0.172.0 · model: gpt-6.2-sol |
…2e41-47a8-8635-15c5133b4b97 Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: 54ce7f1a-e0fd-4f17-8b5d-7e71282cac53 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task 54ce7f1a-e0fd-4f17-8b5d-7e71282cac53 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: c4e20194-2e41-47a8-8635-15c5133b4b97 Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task c4e20194-2e41-47a8-8635-15c5133b4b97 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: cc4e335e-bc7a-4440-9a18-f13d56d6903b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task cc4e335e-bc7a-4440-9a18-f13d56d6903b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…bc7a-4440-9a18-f13d56d6903b Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: cc4e335e-bc7a-4440-9a18-f13d56d6903b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task cc4e335e-bc7a-4440-9a18-f13d56d6903b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: cc4e335e-bc7a-4440-9a18-f13d56d6903b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task cc4e335e-bc7a-4440-9a18-f13d56d6903b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: cc4e335e-bc7a-4440-9a18-f13d56d6903b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task cc4e335e-bc7a-4440-9a18-f13d56d6903b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: cc4e335e-bc7a-4440-9a18-f13d56d6903b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task cc4e335e-bc7a-4440-9a18-f13d56d6903b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: cc4e335e-bc7a-4440-9a18-f13d56d6903b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task cc4e335e-bc7a-4440-9a18-f13d56d6903b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…tions Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: 8f79f865-240e-43ce-9978-992529c69b9b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task 8f79f865-240e-43ce-9978-992529c69b9b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Co-Authored-By: Codex <noreply@openai.com> Harness: codex Model: gpt-6.1-sol Factory-Task: 8f79f865-240e-43ce-9978-992529c69b9b Agent-Harness: Codex 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: factory task 8f79f865-240e-43ce-9978-992529c69b9b on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
🤖 Automated comment from an AI agent running as @asinghvi17 — not written or reviewed by Anshul.
Adds
MonotonicMakimaInterpolation: makima slopes with a sign pass and the square Fritsch–Carlson (1980) limiter. When max(α, β) > 3, both end slopes of a segment are scaled back into [0, 3]². LikePCHIPInterpolation, it returns aCubicHermiteSpline, so extrapolation, derivatives and caching work as usual.It also fixes
AkimaInterpolationon 2 points, which read an uninitialised value.The slope-buffer change also affects released PCHIP: integer
uwith Dualtnow works, and Float32-matrixuwith Float64tnow stores Float64 slopes.This touches the same Akima tolerance line in
interpolation_caches.jlas #631; whichever merges second must keepoftype(one(T), …)/oneunitfor Unitful.Motivated by #292 (Akima-like slopes without overshoot); it sits next to
PCHIPInterpolation. The 2-point bug dates from the original 2019 implementation, and #601 already declares 2 points valid.🤖 Generated with Claude Code
https://claude.ai/code/session_014mFQHtrhbkjCL96BmvXjDA
🤖 Posted by an AI agent — harness: Claude 2.1.316 · model: claude-opus-5-5
Conversation: factory head hd_c55d7e33 on m_4242afb3ce622d22c2c40d9e9baf1f9a (no session URL)