Skip to main content

conspire/math/assert/fd/
mod.rs

1use crate::math::{Quantity, Scalar};
2
3/// A step to perturb an entry by, in whatever unit that entry carries.
4///
5/// A finite difference divides by the step it took, so the step carries the
6/// unit of the entry it steps rather than being the bare number a tolerance is,
7/// and the quotient comes out in the unit the derivative is actually in.
8pub const fn perturbation<U>(epsilon: Scalar) -> Quantity<U> {
9    Quantity::new(epsilon)
10}
11
12/// Types that can report a finite-difference comparison error against themselves.
13pub trait FiniteDifference {
14    fn error_fd(&self, comparator: &Self, epsilon: Scalar) -> Option<(bool, usize)>;
15}