rust ffast-math (defunct, use lower)
add FloatAlone
bendn 2023-10-14
parent 05240fc · commit 762735e
-rw-r--r--Cargo.toml4
-rw-r--r--src/generic_float.rs43
2 files changed, 45 insertions, 2 deletions
diff --git a/Cargo.toml b/Cargo.toml
index ab65a81..890112c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,11 +1,11 @@
[package]
name = "umath"
-version = "0.0.5"
+version = "0.0.6"
description = "ffast-math in rust"
license = "MIT"
repository = "https://github.com/bend-n/umath"
authors = ["bend-n <[email protected]>"]
edition = "2021"
exclude = [".gitignore"]
-categories = ["hardware-support", "mathematics", "no-std", "no-std::no-alloc"]
+categories = ["hardware-support", "mathematics"]
keywords = ["fast", "math", "unsafe", "ffast-math", "float"]
diff --git a/src/generic_float.rs b/src/generic_float.rs
index 5f03ab1..996e62d 100644
--- a/src/generic_float.rs
+++ b/src/generic_float.rs
@@ -126,6 +126,49 @@ pub trait FloatMethods: Trig + Rounding + Log {
fn max(self, other: Self) -> Self;
}
+/// Completely stand-alone [`Float`].
+/// This is comparable to something like [num_traits::Float](https://docs.rs/num-traits/latest/num_traits/float/trait.Float.html).
+pub trait FloatAlone:
+ PartialEq
+ + PartialOrd
+ + Copy
+ + Constructors
+ + FloatMethods
+ + Add<Self, Output = Self>
+ + Sub<Self, Output = Self>
+ + Mul<Self, Output = Self>
+ + Rem<Self, Output = Self>
+ + Div<Self, Output = Self>
+ + Neg<Output = Self>
+ + AddAssign<Self>
+ + SubAssign<Self>
+ + MulAssign<Self>
+ + DivAssign<Self>
+ + RemAssign<Self>
+{
+}
+
+impl<
+ T: PartialEq
+ + PartialOrd
+ + Copy
+ + Constructors
+ + FloatMethods
+ + Add<T, Output = T>
+ + Sub<T, Output = T>
+ + Mul<T, Output = T>
+ + Rem<T, Output = T>
+ + Div<T, Output = T>
+ + Neg<Output = T>
+ + AddAssign<T>
+ + SubAssign<T>
+ + MulAssign<T>
+ + DivAssign<T>
+ + RemAssign<T>,
+ > FloatAlone for T
+{
+}
+
/// Generic float trait, implemented by {[`FFloat`], [`f32`], [`f64`]}. Takes a "base" argument, intended to be set to {[`f32`], [`f64`]}.
/// The main purpose of this is to be taken (generically) by optionally fast functions.
///