Skip to content

Add convexity-constrained fitting and knot insertion#43

Merged
perazz merged 1 commit intomainfrom
convex-curve-knot-insertion
Feb 17, 2026
Merged

Add convexity-constrained fitting and knot insertion#43
perazz merged 1 commit intomainfrom
convex-curve-knot-insertion

Conversation

@perazz
Copy link
Owner

@perazz perazz commented Feb 17, 2026

Summary

  • New fitpack_convex_curve type wrapping concon (automatic knots) and cocosp (least-squares with given knots) for local convexity/concavity constraints on cubic splines — a unique FITPACK capability that SciPy has never wrapped
  • Add insert_knot method to fitpack_curve (single and multiple knots, with automatic storage growth and periodic curve support via insert_inplace)
  • Add FP_BOOL comm helpers (FP_BOOL_COMM_SIZE_1D, PACK_1D, EXPAND_1D) for logical array round-trip communication
  • Add CONCON_MAXBIN, CONCON_MAXTR, CONCON_QP_FAIL error constants with FITPACK_MESSAGE support

New files

  • src/fitpack_convex_curves.f90fitpack_convex_curve type with fit (concon), least_squares (cocosp), set_convexity, full comm support

Test plan

  • test_convex_fit — mncoco data, concave constraints, 3 smoothing levels, verifies s''(x) <= 0
  • test_convex_least_squares — mncosp data, convex and concave cases via cocosp
  • test_insert_knot — sine curve, verifies knot count +1 and values unchanged to machine precision
  • test_insert_knot_periodic — periodic curve, same verification
  • All 55 existing tests pass (21 interface + 29 legacy + 5 C++)

- New fitpack_convex_curve type wrapping concon (automatic knots) and
  cocosp (least-squares with given knots) for local convexity/concavity
  constraints on cubic splines
- Add insert_knot method to fitpack_curve (single and multiple, with
  automatic storage growth and periodic curve support)
- Add FP_BOOL comm helpers (size/pack/expand) for logical array
  round-trip communication
- Add CONCON_MAXBIN, CONCON_MAXTR, CONCON_QP_FAIL error constants
- 4 new tests: convex fit, convex least-squares, knot insertion,
  periodic knot insertion
@perazz perazz merged commit 851238a into main Feb 17, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant