forked from M-Labs/nalgebra
Implement DeviceCopy for UnitComplex, UnitQuaternion, and Unit<Matrix> instead of using a blanket impl
This commit is contained in:
parent
e8c6a7c0a2
commit
9297cc5754
@ -26,10 +26,10 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
||||
/// in their documentation, read their dedicated pages directly.
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Hash, Copy)]
|
||||
#[cfg_attr(
|
||||
all(not(target_os = "cuda"), feature = "cuda"),
|
||||
derive(cust::DeviceCopy)
|
||||
)]
|
||||
// #[cfg_attr(
|
||||
// all(not(target_os = "cuda"), feature = "cuda"),
|
||||
// derive(cust::DeviceCopy)
|
||||
// )]
|
||||
pub struct Unit<T> {
|
||||
pub(crate) value: T,
|
||||
}
|
||||
@ -122,6 +122,17 @@ mod rkyv_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))]
|
||||
unsafe impl<T: cust::memory::DeviceCopy, R, C, S> cust::memory::DeviceCopy
|
||||
for Unit<Matrix<T, R, C, S>>
|
||||
where
|
||||
T: Scalar,
|
||||
R: Dim,
|
||||
C: Dim,
|
||||
S: RawStorage<T, R, C> + Copy,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T, R, C, S> PartialEq for Unit<Matrix<T, R, C, S>>
|
||||
where
|
||||
T: Scalar + PartialEq,
|
||||
|
@ -1068,6 +1068,9 @@ impl<T: RealField + fmt::Display> fmt::Display for Quaternion<T> {
|
||||
/// A unit quaternions. May be used to represent a rotation.
|
||||
pub type UnitQuaternion<T> = Unit<Quaternion<T>>;
|
||||
|
||||
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))]
|
||||
unsafe impl<T: cust::memory::DeviceCopy> cust::memory::DeviceCopy for UnitQuaternion<T> {}
|
||||
|
||||
impl<T: Scalar + ClosedNeg + PartialEq> PartialEq for UnitQuaternion<T> {
|
||||
#[inline]
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
|
@ -31,6 +31,9 @@ use std::cmp::{Eq, PartialEq};
|
||||
/// * [Conversion to a matrix <span style="float:right;">`to_rotation_matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix)
|
||||
pub type UnitComplex<T> = Unit<Complex<T>>;
|
||||
|
||||
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))]
|
||||
unsafe impl<T: cust::memory::DeviceCopy> cust::memory::DeviceCopy for UnitComplex<T> {}
|
||||
|
||||
impl<T: Scalar + PartialEq> PartialEq for UnitComplex<T> {
|
||||
#[inline]
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user