diff --git a/lightmotif/src/dense.rs b/lightmotif/src/dense.rs index 7487b2afe3a57cf56efae09b264805e14314ef4f..f16ef3a79d3f2cd0743a2dc1a57635574869e48b 100644 --- a/lightmotif/src/dense.rs +++ b/lightmotif/src/dense.rs @@ -42,7 +42,7 @@ impl MatrixCoordinates { // --- DenseMatrix ------------------------------------------------------------- /// A memory-aligned dense matrix with a constant number of columns. -#[derive(Clone, Eq)] +#[derive(Eq)] pub struct DenseMatrix<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo = DefaultAlignment> { data: Vec<T>, @@ -202,6 +202,18 @@ impl<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> DenseMatrix<T, C, } } +impl<T: Default + Copy + Debug, C: Unsigned, A: Unsigned + PowerOfTwo> Clone + for DenseMatrix<T, C, A> +{ + fn clone(&self) -> Self { + let mut clone = unsafe { Self::uninitialized(self.rows) }; + let l = self.rows() * self.stride(); + clone.data[clone.offset..clone.offset + l] + .copy_from_slice(&self.data[self.offset..self.offset + l]); + clone + } +} + impl<T: Default + Copy + Debug, C: Unsigned, A: Unsigned + PowerOfTwo> Debug for DenseMatrix<T, C, A> {