#[cfg(feature = "roots-scalar")]
mod error;
#[cfg(feature = "roots-polynomial")]
pub mod polynomial;
#[cfg(feature = "roots-scalar")]
mod scalar;
#[cfg(feature = "roots-scalar")]
pub use error::RootError;
#[cfg(feature = "roots-polynomial")]
pub use polynomial::{
PolynomialRootError, PolynomialRootMethod, PolynomialRootStatus, PolynomialRoots,
complex_polynomial_roots, complex_polynomial_roots_with_method, real_polynomial_roots,
real_polynomial_roots_with_method,
};
#[cfg(feature = "roots-scalar")]
pub use scalar::{find_root, find_root_f32};
#[cfg(feature = "roots-scalar")]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RootBracket<T = f64> {
pub lower: T,
pub upper: T,
}
#[cfg(feature = "roots-scalar")]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RootOptions<T = f64> {
pub relative_tolerance: T,
pub absolute_tolerance: T,
pub initial_guess: Option<T>,
}
#[cfg(feature = "roots-scalar")]
impl Default for RootOptions<f64> {
fn default() -> Self {
Self {
relative_tolerance: 1.0e-10,
absolute_tolerance: 1.0e-12,
initial_guess: None,
}
}
}
#[cfg(feature = "roots-scalar")]
impl RootOptions<f32> {
pub const fn single_precision() -> Self {
Self {
relative_tolerance: 1.0e-5,
absolute_tolerance: 1.0e-6,
initial_guess: None,
}
}
}
#[cfg(feature = "roots-scalar")]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RootStatus {
Converged,
LowerEndpoint,
UpperEndpoint,
EndpointRoot,
PossibleSingularity,
NoSignChange,
MaximumEvaluations,
}
#[cfg(feature = "roots-scalar")]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RootResult<T = f64> {
pub estimate: T,
pub bracket: RootBracket<T>,
pub evaluations: usize,
pub status: RootStatus,
}