Skip to main content

anofox_ml_core/
float.rs

1use ndarray::NdFloat;
2use num_traits::{Float as NumFloat, FromPrimitive};
3use serde::de::DeserializeOwned;
4use serde::Serialize;
5use std::fmt::{Debug, Display};
6use std::iter::Sum;
7
8/// Trait bound for floating-point types used throughout anofox-ml.
9///
10/// Combines ndarray's `NdFloat` (for array operations), `num_traits::Float`
11/// (for math functions), `FromPrimitive` (for numeric conversions), and
12/// serde's `Serialize + Deserialize` (for model serialization).
13pub trait Float:
14    NdFloat
15    + NumFloat
16    + FromPrimitive
17    + Debug
18    + Display
19    + Sum
20    + Default
21    + Serialize
22    + DeserializeOwned
23    + 'static
24{
25}
26
27impl Float for f32 {}
28impl Float for f64 {}