rust ffast-math (defunct, use lower)
no_std
bendn 2023-10-04
parent 2af65d0 · commit 346c113
-rw-r--r--Cargo.toml3
-rw-r--r--README.md3
-rw-r--r--src/lib.rs19
-rw-r--r--src/trait.rs4
4 files changed, 16 insertions, 13 deletions
diff --git a/Cargo.toml b/Cargo.toml
index fe7ccfb..d9ad25e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,4 +7,5 @@ repository = "https://github.com/bend-n/umath"
authors = ["bend-n <[email protected]>"]
edition = "2021"
exclude = [".gitignore"]
-categories = ["hardware-support", "mathematics",] \ No newline at end of file
+categories = ["hardware-support", "mathematics", "no-std", "no-std::no-alloc"]
+keywords = ["fast", "math", "unsafe", "ffast-math", "float"] \ No newline at end of file
diff --git a/README.md b/README.md
index fcdbe50..e05cc37 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# umath: ffast-math, for rust.
-![MSRV](https://img.shields.io/badge/msrv-nightly-blue?style=for-the-badge&logo=rust)
+[![MSRV](https://img.shields.io/badge/msrv-nightly-blue?style=for-the-badge&logo=rust)](#nightlyness)
+[![DOCS](https://img.shields.io/badge/docs.rs-umath-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs")](https://docs.rs/umath)
Want to make your math *faster*? [<sup>*t&c apply</sup>](https://simonbyrne.github.io/notes/fastmath)
diff --git a/src/lib.rs b/src/lib.rs
index 8b324e0..dbdb90b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,8 +9,9 @@
//! ```
#![feature(core_intrinsics)]
#![warn(clippy::pedantic, clippy::dbg_macro, clippy::use_self, missing_docs)]
-use std::cmp::{PartialEq, PartialOrd};
-use std::ops::{
+#![no_std]
+use core::cmp::{Ordering, PartialEq, PartialOrd};
+use core::ops::{
Add as add, AddAssign as add_assign, Deref, DerefMut, Div as div, DivAssign as div_assign,
Mul as mul, MulAssign as mul_assign, Neg, Rem as rem, RemAssign as rem_assign, Sub as sub,
SubAssign as sub_assign,
@@ -33,14 +34,14 @@ use r#trait::FastFloat;
#[derive(Copy, Clone, PartialEq)]
pub struct FFloat<T>(T);
-impl<T: FastFloat> std::fmt::Debug for FFloat<T> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl<T: FastFloat> core::fmt::Debug for FFloat<T> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:?}", self.0)
}
}
-impl<T: FastFloat> std::fmt::Display for FFloat<T> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl<T: FastFloat> core::fmt::Display for FFloat<T> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.0)
}
}
@@ -184,17 +185,17 @@ impl<T: FastFloat> PartialEq<T> for FFloat<T> {
}
impl<T: FastFloat> Eq for FFloat<T> {}
impl<T: FastFloat> PartialOrd for FFloat<T> {
- fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<T: FastFloat> PartialOrd<T> for FFloat<T> {
- fn partial_cmp(&self, other: &T) -> Option<std::cmp::Ordering> {
+ fn partial_cmp(&self, other: &T) -> Option<Ordering> {
self.0.partial_cmp(other)
}
}
impl<T: FastFloat> Ord for FFloat<T> {
- fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+ fn cmp(&self, other: &Self) -> Ordering {
self.check();
unsafe { self.0.partial_cmp(&other.0).unwrap_unchecked() }
}
diff --git a/src/trait.rs b/src/trait.rs
index 7717cd6..7401848 100644
--- a/src/trait.rs
+++ b/src/trait.rs
@@ -1,9 +1,9 @@
-use std::intrinsics::{
+use core::intrinsics::{
fadd_fast as add, fdiv_fast as div, fmul_fast as mul, frem_fast as rem, fsub_fast as sub,
};
macro_rules! meth {
($($name:ident)|+) => {
- pub trait FastFloat: Copy + std::fmt::Display + std::fmt::Debug + std::ops::Neg<Output = Self> + std::cmp::PartialEq + std::cmp::PartialOrd {
+ pub trait FastFloat: Copy + core::fmt::Display + core::fmt::Debug + core::ops::Neg<Output = Self> + core::cmp::PartialEq + core::cmp::PartialOrd {
$(#[doc(hidden)] unsafe fn $name(a: Self, b: Self) -> Self;)+
#[doc(hidden)]
fn bad(self) -> bool;