pub mod bisection;
pub mod newton;
pub mod newton_system;
pub use bisection::Bisection;
pub use newton::Newton;
pub use newton_system::NewtonSystem;
use crate::scalar::Numeric;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum RootTermination {
ResidualTolerance,
StepTolerance,
BracketWidth,
}
#[derive(Debug, Clone, Copy)]
#[must_use]
pub struct RootReport<T = f64> {
pub root: T,
pub residual: T,
pub iterations: usize,
pub termination: RootTermination,
}
#[derive(Debug, Clone, Copy)]
#[must_use]
pub struct RootReportN<const N: usize, T = f64> {
pub root: [T; N],
pub residual_norm: T,
pub iterations: usize,
pub termination: RootTermination,
}
pub(crate) fn same_sign<T: Numeric>(a: T, b: T) -> bool {
(a >= T::ZERO) == (b >= T::ZERO)
}
pub(crate) fn all_finite<const K: usize, T: Numeric>(v: &[T; K]) -> bool {
v.iter().all(|x| x.is_finite())
}