working on adding sin_cos_pi
[vector-math.git] / src / traits.rs
index ffc766b81007113f57da2355fcba0330cc25b332..6555016d98793e1c70b8715fe85e5f3f3a5878cf 100644 (file)
@@ -187,9 +187,18 @@ pub trait Float: Number + Neg<Output = Self> {
     fn trunc(self) -> Self;
     fn ceil(self) -> Self;
     fn floor(self) -> Self;
     fn trunc(self) -> Self;
     fn ceil(self) -> Self;
     fn floor(self) -> Self;
+    /// round to nearest integer, unspecified which way half-way cases are rounded
     fn round(self) -> Self;
     fn round(self) -> Self;
+    /// returns `self * a + b` but only rounding once
     #[cfg(feature = "fma")]
     fn fma(self, a: Self, b: Self) -> Self;
     #[cfg(feature = "fma")]
     fn fma(self, a: Self, b: Self) -> Self;
+    /// returns `self * a + b` either using `fma` or `self * a + b`
+    fn mul_add_fast(self, a: Self, b: Self) -> Self {
+        #[cfg(feature = "fma")]
+        return self.fma(a, b);
+        #[cfg(not(feature = "fma"))]
+        return self * a + b;
+    }
     fn is_nan(self) -> Self::Bool {
         self.ne(self)
     }
     fn is_nan(self) -> Self::Bool {
         self.ne(self)
     }