aboutsummaryrefslogtreecommitdiff
path: root/src/f32/sse2/vec4.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/f32/sse2/vec4.rs')
-rw-r--r--src/f32/sse2/vec4.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/f32/sse2/vec4.rs b/src/f32/sse2/vec4.rs
index 0e0882c..f1a1311 100644
--- a/src/f32/sse2/vec4.rs
+++ b/src/f32/sse2/vec4.rs
@@ -294,6 +294,18 @@ impl Vec4 {
}
}
+ /// Returns a vector with signs of `rhs` and the magnitudes of `self`.
+ #[inline]
+ pub fn copysign(self, rhs: Self) -> Self {
+ unsafe {
+ let mask = Self::splat(-0.0);
+ Self(_mm_or_ps(
+ _mm_and_ps(rhs.0, mask.0),
+ _mm_andnot_ps(mask.0, self.0),
+ ))
+ }
+ }
+
/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`.
///
/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes