linfa_linear/
float.rs

1use argmin::core::ArgminFloat;
2use ndarray::NdFloat;
3use num_traits::float::FloatConst;
4use num_traits::FromPrimitive;
5
6// A Float trait that captures the requirements we need for the various places
7// we need floats. There requirements are imposed y ndarray and argmin
8pub trait Float:
9    ArgminFloat + FloatConst + NdFloat + Default + Clone + FromPrimitive + linfa::Float
10{
11    const POSITIVE_LABEL: Self;
12    const NEGATIVE_LABEL: Self;
13}
14
15impl Float for f32 {
16    const POSITIVE_LABEL: Self = 1.0;
17    const NEGATIVE_LABEL: Self = -1.0;
18}
19
20impl Float for f64 {
21    const POSITIVE_LABEL: Self = 1.0;
22    const NEGATIVE_LABEL: Self = -1.0;
23}