add sqrt_fast_f16/f32/f64
[vector-math.git] / src / scalar.rs
index 4eb5b985627f03f3e9a75761437e1923b4f279c8..b15388b24ef6473abab300da2fcfea8e5a3a83f1 100644 (file)
@@ -1,5 +1,6 @@
 use crate::{
     f16::F16,
+    prim::{PrimSInt, PrimUInt},
     traits::{Bool, Compare, Context, ConvertFrom, Float, Int, Make, SInt, Select, UInt},
 };
 use core::ops::{
@@ -230,7 +231,10 @@ macro_rules! impl_uint {
     ($($ty:ident),*) => {
         $(
             impl_int!($ty);
-            impl UInt for Value<$ty> {}
+            impl UInt for Value<$ty> {
+                type PrimUInt = $ty;
+                type SignedType = Value<<$ty as PrimUInt>::SignedType>;
+            }
         )*
     };
 }
@@ -241,7 +245,10 @@ macro_rules! impl_sint {
     ($($ty:ident),*) => {
         $(
             impl_int!($ty);
-            impl SInt for Value<$ty> {}
+            impl SInt for Value<$ty> {
+                type PrimSInt = $ty;
+                type UnsignedType = Value<<$ty as PrimSInt>::UnsignedType>;
+            }
         )*
     };
 }
@@ -336,38 +343,44 @@ macro_rules! impl_float {
     ($ty:ident, $bits:ty, $signed_bits:ty) => {
         impl_float_ops!($ty);
         impl Float for Value<$ty> {
-            type FloatEncoding = $ty;
+            type PrimFloat = $ty;
             type BitsType = Value<$bits>;
             type SignedBitsType = Value<$signed_bits>;
             fn abs(self) -> Self {
                 #[cfg(feature = "std")]
                 return Value(self.0.abs());
                 #[cfg(not(feature = "std"))]
-                todo!();
+                return crate::algorithms::base::abs(Scalar, self);
+            }
+            fn copy_sign(self, sign: Self) -> Self {
+                #[cfg(feature = "std")]
+                return Value(self.0.copysign(sign.0));
+                #[cfg(not(feature = "std"))]
+                return crate::algorithms::base::copy_sign(Scalar, self, sign);
             }
             fn trunc(self) -> Self {
                 #[cfg(feature = "std")]
                 return Value(self.0.trunc());
                 #[cfg(not(feature = "std"))]
-                todo!();
+                return crate::algorithms::base::trunc(Scalar, self);
             }
             fn ceil(self) -> Self {
                 #[cfg(feature = "std")]
                 return Value(self.0.ceil());
                 #[cfg(not(feature = "std"))]
-                todo!();
+                return crate::algorithms::base::ceil(Scalar, self);
             }
             fn floor(self) -> Self {
                 #[cfg(feature = "std")]
                 return Value(self.0.floor());
                 #[cfg(not(feature = "std"))]
-                todo!();
+                return crate::algorithms::base::floor(Scalar, self);
             }
             fn round(self) -> Self {
                 #[cfg(feature = "std")]
                 return Value(self.0.round());
                 #[cfg(not(feature = "std"))]
-                todo!();
+                return crate::algorithms::base::round_to_nearest_ties_to_even(Scalar, self);
             }
             #[cfg(feature = "fma")]
             fn fma(self, a: Self, b: Self) -> Self {