diff --git a/CHANGELOG b/CHANGELOG index e2aad14..5656327 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,8 @@ - Add the `portable_simd` feature for supporting `std::simd`. - The `ClosedAdd, ClosedMul, etc.` traits no longer require `AddAssign, MulAssign`. Instead they are required for new traits named `ClosedAddAssign, ClosedMulAssign, etc.` +- The `ComplexField` and `SimdComplexField` (and, by extension, `RealField` and `SimdRealField`) traits now depend on the + `SupersetOf` trait in addition to `SupersetOf`. ## Release v0.8.1 (04 Apr. 2023) - Add implementation of `rkyv` serialization/deserialization to the `Wide*` wrapper types. diff --git a/src/scalar/complex.rs b/src/scalar/complex.rs index 1c3c739..e28d94e 100644 --- a/src/scalar/complex.rs +++ b/src/scalar/complex.rs @@ -161,6 +161,7 @@ macro_rules! complex_trait_methods ( #[allow(missing_docs)] pub trait ComplexField: SubsetOf ++ SupersetOf + SupersetOf + FromPrimitive + Field diff --git a/src/scalar/fixed_impl.rs b/src/scalar/fixed_impl.rs index ed3ceaf..9f84c82 100644 --- a/src/scalar/fixed_impl.rs +++ b/src/scalar/fixed_impl.rs @@ -316,6 +316,28 @@ macro_rules! impl_fixed_type ( } } + impl SubsetOf<$FixedI> for f32 { + #[inline] + fn to_superset(&self) -> $FixedI { + $FixedI(fixed::$FixedI::from_num(*self)) + } + + #[inline] + fn from_superset(element: &$FixedI) -> Option { + Some(Self::from_superset_unchecked(element)) + } + + #[inline] + fn from_superset_unchecked(element: &$FixedI) -> Self { + element.0.to_num::() + } + + #[inline] + fn is_in_subset(_: &$FixedI) -> bool { + true + } + } + impl SubsetOf<$FixedI> for $FixedI { #[inline] fn to_superset(&self) -> $FixedI { diff --git a/src/simd/simd_complex.rs b/src/simd/simd_complex.rs index 5bdd02e..0d73326 100644 --- a/src/simd/simd_complex.rs +++ b/src/simd/simd_complex.rs @@ -12,24 +12,25 @@ use crate::simd::{SimdRealField, SimdValue}; /// Each lane of an SIMD complex field should contain one complex field. #[allow(missing_docs)] pub trait SimdComplexField: - SubsetOf - + SupersetOf - + Field - + Clone - + Neg +SubsetOf ++ SupersetOf ++ SupersetOf ++ Field ++ Clone ++ Neg // + MeetSemilattice // + JoinSemilattice - + Send - + Sync - + Any - + 'static - + Debug - + NumAssignOps - + NumOps - + PartialEq ++ Send ++ Sync ++ Any ++ 'static ++ Debug ++ NumAssignOps ++ NumOps ++ PartialEq { /// Type of the coefficients of a complex number. - type SimdRealField: SimdRealField::SimdBool>; + type SimdRealField: SimdRealField::SimdBool>; complex_trait_methods!(SimdRealField, simd_); /// Computes the sum of all the lanes of `self`.