ENH: Native Simpson, deprecate vnl integral classes, retire netlib quadrature#6470
ENH: Native Simpson, deprecate vnl integral classes, retire netlib quadrature#6470hjmjohnson wants to merge 3 commits into
Conversation
Phase 5 performance proof — native Simpson vs netlib
|
| case | err_native | err_netlib | ms_native | ms_netlib | Eigen/native ≤ |
|---|---|---|---|---|---|
| x/(1+x²) [0,1], n=50 | 1.202e-09 | 1.202e-09 | 0.0001 | 0.0001 | both |
| x/(1+x²) [0,1], n=5000 | 9.610e-16 | 9.610e-16 | 0.0084 | 0.0084 | both |
| gaussian [-6,6], n=500 | 0.000e+00 | 0.000e+00 | 0.0025 | 0.0025 | both |
| gaussian [-6,6], n=50000 | 3.012e-15 | 3.012e-15 | 0.2520 | 0.2519 | both |
| sin(50x)·e⁻ˣ [0,3], n=20000 | 1.095e-12 | 1.095e-12 | 0.2312 | 0.3816 | both |
Error = |approx − exact| / |exact| against analytic references
(½ln2; √(2π)·erf; closed form for the oscillatory case).
Environment & reproducer
- OS: Darwin 25.5.0 arm64 — Apple M3 Max — Apple clang 21.0.0
- Single-threaded; median of 15 reps per case;
-O2 -std=c++17 - Both engines exercised in one process on identical integrands (fairest
same-compiler/same-CPU/same-integrand-cost comparison); netlib arm is a
verbatim copy ofv3p/netlib/mathews/simpson.c:simpru_. - Reproducer:
/tmp/simpson_bench/bench.cxx, built with
c++ -O2 -std=c++17 bench.cxx -o bench, run with
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 ./bench.
This comment was marked as resolved.
This comment was marked as resolved.
|
@dzenanz TLDR; These functions are not used in ITK or any of the downstream BRAINSTools/ANTs/Remote Modules/Slicer/SlicerExtentions code bases. It is deprecated immediately, and only here in the very unlikely case of a downstream user who may have needed it. NOTE: The re-implementation was a trivial rewrite in C++. No ITK-dependent tool that uses these functions. 2 of the 3 functions were provably unreachable or not compiled. |
dzenanz
left a comment
There was a problem hiding this comment.
No objections after a glance.
Compute the composite Simpson rule (Mathews Algorithm 7.2) directly in C++ instead of delegating to the f2c-translated v3p_netlib_simpru_. The loop bounds and accumulation order match the Fortran exactly, so results are bit-identical; this removes the only live dependency on the vendored netlib/mathews sources.
The Mathews netlib routines (simpru_/xsimpru_, trapru_/xtrapru_, the orphaned adaquad.f) have no remaining caller: vnl_simpson_integral now computes Simpson natively, vnl_adaptsimpson_integral was always pure C++, and the trapezoid/adaptive-quadrature symbols were never wired into any vnl class. Remove the sources, their mangle/unmangle/prototype entries, the standalone netlib_integral_test, and the mathews entry in the f2c regeneration recipe.
Gate both headers with the standard ITK three-state legacy guard (silent default, ITK_LEGACY_REMOVE warning, ITK_FUTURE_LEGACY_REMOVE error), inert unless itkConfigure.h is present so the upstream VXL build is unaffected. test_integral defines ITK_LEGACY_TEST so it keeps exercising the classes under the ITK_LEGACY_REMOVE build.
97fafe8 to
b2e2407
Compare
Reimplements
vnl_simpson_integralwith a native composite-Simpson loop, deprecates it andvnl_adaptsimpson_integralbehind ITK's three-state legacy guard, and retires the now-unusedv3p/netlib/mathews/*sources. Advances the VNL→native numerics direction (#6403, #6230); follows the deprecation pattern of #6441 and #6454.What changed (3 commits)
COMP:Reimplement vnl_simpson_integralv3p_netlib_simpru_. Loop bounds/accumulation order match the Fortran exactly → bit-identical results.COMP:Retire unused netlib/mathewssimpson.*,trapezod.*,adaquad.f, the standalonenetlib_integral_test, and the mangle/unmangle/prototype/CMake/README entries.trapru_/adaquadhad no caller;simpru_was the only live one.ENH:Deprecate both integral classes__has_include(<itkConfigure.h>)-gated three-state guard (silent default /ITK_LEGACY_REMOVEwarning /ITK_FUTURE_LEGACY_REMOVEerror), inert for the upstream VXL build.test_integral.cxxdefinesITK_LEGACY_TEST.vnl_adaptsimpson_integralwas already pure C++ (it never used the Fortran).Verification
ctest -R test_integralpasses against the native engine (analytic checks to 1e-6).ITK_LEGACY_REMOVEwarns /ITK_FUTURE_LEGACY_REMOVEerrors);+ITK_LEGACY_TESTopt-out keeps the in-tree test silent.pre-commit run --all-filesclean.