pub fn assert_matrix_derivativefd_rel(
fd: &Array2<f64>,
analytic: &Array2<f64>,
rel_tol: f64,
label: &str,
)Expand description
Asserts that a finite difference dense matrix matches an analytically
computed directional derivative matrix to a relative tolerance
rel_tol·(1 + |analytic|), plus component-wise sign agreement.
Use this (rather than the absolute-tolerance assert_matrix_derivativefd)
when the comparison’s dominant components are O(0.1–1) and the finite
difference is contaminated by a small, non-smooth solver channel — e.g. an
adaptive PIRLS stabilization ridge whose magnitude shifts discontinuously
across the ± FD re-solves. There the exact analytic IFT derivative (which
correctly excludes that solver-only ridge) and the FD disagree by a fixed
fraction of the component magnitude, not a fixed absolute amount, so an
absolute bound tuned for the small components is spuriously tight on the
large ones. The two underlying derivative channels are validated separately
against their own FDs, so this asserts the composite to the achievable
relative precision rather than weakening the per-channel checks (gam#855).