polycool/
lib.rs

1// Copyright 2025 the Kurbo Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4//! This is a crate for numerical polynomial root-finding.
5//!
6//! Currently, we implement a single solver: Yuksel's iterative algorithm
7//! for finding roots in a bounded interval. We aspire to have
8//! more, with thorough tests and benchmarks.
9
10#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
11mod cubic;
12#[cfg(feature = "libm")]
13mod libm_polyfill;
14mod poly;
15#[cfg(feature = "std")]
16mod poly_dyn;
17mod quadratic;
18mod yuksel;
19
20#[cfg(any(test, feature = "arbitrary"))]
21pub mod arbitrary;
22
23#[cfg(not(any(feature = "std", feature = "libm")))]
24compile_error!("kurbo requires either the `std` or `libm` feature");
25
26// Suppress the unused_crate_dependencies lint when both std and libm are specified.
27#[cfg(all(feature = "std", feature = "libm"))]
28use libm as _;
29
30pub use poly::{Cubic, Poly, Quadratic, Quartic, Quintic};
31#[cfg(feature = "std")]
32pub use poly_dyn::PolyDyn;
33
34fn different_signs(x: f64, y: f64) -> bool {
35    (x < 0.0) != (y < 0.0)
36}