mod bisection;
mod brent;
mod newton;
pub use bisection::bisection;
pub use brent::brent_root;
pub use newton::newton;
use scivex_core::Float;
#[cfg_attr(
feature = "serde-support",
derive(serde::Serialize, serde::Deserialize)
)]
#[derive(Debug, Clone)]
pub struct RootResult<T: Float> {
pub root: T,
pub f_root: T,
pub iterations: usize,
pub converged: bool,
}
#[cfg_attr(
feature = "serde-support",
derive(serde::Serialize, serde::Deserialize)
)]
#[derive(Debug, Clone)]
pub struct RootOptions<T: Float> {
pub xtol: T,
pub ftol: T,
pub max_iter: usize,
}
impl<T: Float> Default for RootOptions<T> {
fn default() -> Self {
Self {
xtol: T::from_f64(1e-12),
ftol: T::from_f64(1e-12),
max_iter: 100,
}
}
}