use std::cmp;
use ndarray::NdFloat;
use ndarray_linalg::Lapack;
pub trait Float: NdFloat + Lapack {
fn half() -> Self;
fn two() -> Self;
fn sign(self) -> Self {
if self == Self::zero() {
Self::zero()
} else {
self.signum()
}
}
fn total_cmp(&self, other: &Self) -> cmp::Ordering;
}
impl Float for f32 {
fn half() -> Self {
0.5
}
fn two() -> Self {
2.0
}
fn total_cmp(&self, other: &Self) -> cmp::Ordering {
self.total_cmp(other)
}
}
impl Float for f64 {
fn half() -> Self {
0.5
}
fn two() -> Self {
2.0
}
fn total_cmp(&self, other: &Self) -> cmp::Ordering {
self.total_cmp(other)
}
}