mod brent;
mod cholesky;
#[path = "levenberg_marquardt.rs"]
mod lm;
#[path = "nelder_mead.rs"]
mod simplex;
pub(crate) use brent::{BrentRoot, brent_root_with_evidence};
pub(crate) use cholesky::{solve_spd, solve_spd_3};
pub(crate) use lm::levenberg_marquardt;
pub(crate) use simplex::nelder_mead;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum OptimizerTermination {
ObjectiveConverged,
GradientConverged,
StepConverged,
Stagnated,
SingularModel,
NonFiniteEvaluation,
IterationLimit,
}
#[inline]
#[must_use]
pub(crate) fn index_to_f64(index: usize) -> f64 {
let value = index as u64;
let high = u32::try_from(value >> 32).unwrap_or(u32::MAX);
let low = u32::try_from(value & 0xFFFF_FFFF).unwrap_or(u32::MAX);
f64::from(high) * 4_294_967_296.0 + f64::from(low)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn index_conversion_is_exact_on_supported_counts() {
assert!(index_to_f64(0).abs() < f64::EPSILON);
assert!((index_to_f64(401) - 401.0).abs() < f64::EPSILON);
assert!((index_to_f64(1_usize << 32) - 4_294_967_296.0).abs() < f64::EPSILON);
}
}