diff --git a/examples/scalar_genericity.rs b/examples/scalar_genericity.rs index 75f6f9d4..18b5c52a 100644 --- a/examples/scalar_genericity.rs +++ b/examples/scalar_genericity.rs @@ -4,11 +4,11 @@ extern crate nalgebra as na; use alga::general::{RealField, RingCommutative}; use na::{Scalar, Vector3}; -fn print_vector(m: &Vector3) { +fn print_vector(m: &Vector3) { println!("{:?}", m) } -fn print_squared_norm(v: &Vector3) { +fn print_squared_norm(v: &Vector3) { // NOTE: alternatively, nalgebra already defines `v.squared_norm()`. let sqnorm = v.dot(v); println!("{:?}", sqnorm); diff --git a/src/base/allocator.rs b/src/base/allocator.rs index 0ad30981..246f3620 100644 --- a/src/base/allocator.rs +++ b/src/base/allocator.rs @@ -16,7 +16,7 @@ use crate::base::{DefaultAllocator, Scalar}; /// /// Every allocator must be both static and dynamic. Though not all implementations may share the /// same `Buffer` type. -pub trait Allocator: Any + Sized { +pub trait Allocator: Any + Sized { /// The type of buffer this allocator can instanciate. type Buffer: ContiguousStorageMut + Clone; @@ -33,7 +33,7 @@ pub trait Allocator: Any + Sized { /// A matrix reallocator. Changes the size of the memory buffer that initially contains (RFrom × /// CFrom) elements to a smaller or larger size (RTo, CTo). -pub trait Reallocator: +pub trait Reallocator: Allocator + Allocator { /// Reallocates a buffer of shape `(RTo, CTo)`, possibly reusing a previously allocated buffer @@ -65,7 +65,7 @@ where R2: Dim, C1: Dim, C2: Dim, - N: Scalar, + N: Scalar + Copy, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { } @@ -76,7 +76,7 @@ where R2: Dim, C1: Dim, C2: Dim, - N: Scalar, + N: Scalar + Copy, DefaultAllocator: Allocator + Allocator, SameShapeC>, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, {} @@ -88,7 +88,7 @@ pub trait SameShapeVectorAllocator: where R1: Dim, R2: Dim, - N: Scalar, + N: Scalar + Copy, ShapeConstraint: SameNumberOfRows, { } @@ -97,7 +97,7 @@ impl SameShapeVectorAllocator for DefaultAllocator where R1: Dim, R2: Dim, - N: Scalar, + N: Scalar + Copy, DefaultAllocator: Allocator + Allocator>, ShapeConstraint: SameNumberOfRows, {} diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index bebb8740..38144d8a 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -154,7 +154,7 @@ where unsafe impl Storage for ArrayStorage where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, R::Value: Mul, @@ -206,7 +206,7 @@ where unsafe impl StorageMut for ArrayStorage where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, R::Value: Mul, @@ -226,7 +226,7 @@ where unsafe impl ContiguousStorage for ArrayStorage where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, R::Value: Mul, @@ -236,7 +236,7 @@ where unsafe impl ContiguousStorageMut for ArrayStorage where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, R::Value: Mul, @@ -295,7 +295,7 @@ struct ArrayStorageVisitor { #[cfg(feature = "serde-serialize")] impl ArrayStorageVisitor where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, R::Value: Mul, diff --git a/src/base/blas.rs b/src/base/blas.rs index 622761fe..a999b6eb 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -48,7 +48,7 @@ impl> Vector { } } -impl> Vector { +impl> Vector { /// Computes the index and value of the vector component with the largest value. /// /// # Examples: @@ -230,7 +230,7 @@ impl> Matrix { } -impl> Matrix { +impl> Matrix { /// Computes the index of the matrix component with the largest absolute value. /// /// # Examples: @@ -264,7 +264,7 @@ impl> Matri } impl> Matrix -where N: Scalar + Zero + ClosedAdd + ClosedMul +where N: Scalar + Copy + Zero + ClosedAdd + ClosedMul { #[inline(always)] fn dotx(&self, rhs: &Matrix, conjugate: impl Fn(N) -> N) -> N @@ -469,7 +469,7 @@ where N: Scalar + Zero + ClosedAdd + ClosedMul } fn array_axcpy(y: &mut [N], a: N, x: &[N], c: N, beta: N, stride1: usize, stride2: usize, len: usize) -where N: Scalar + Zero + ClosedAdd + ClosedMul { +where N: Scalar + Copy + Zero + ClosedAdd + ClosedMul { for i in 0..len { unsafe { let y = y.get_unchecked_mut(i * stride1); @@ -479,7 +479,7 @@ where N: Scalar + Zero + ClosedAdd + ClosedMul { } fn array_axc(y: &mut [N], a: N, x: &[N], c: N, stride1: usize, stride2: usize, len: usize) -where N: Scalar + Zero + ClosedAdd + ClosedMul { +where N: Scalar + Copy + Zero + ClosedAdd + ClosedMul { for i in 0..len { unsafe { *y.get_unchecked_mut(i * stride1) = a * *x.get_unchecked(i * stride2) * c; @@ -489,7 +489,7 @@ where N: Scalar + Zero + ClosedAdd + ClosedMul { impl Vector where - N: Scalar + Zero + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + ClosedAdd + ClosedMul, S: StorageMut, { /// Computes `self = a * x * c + b * self`. @@ -886,7 +886,7 @@ where } impl> Matrix -where N: Scalar + Zero + ClosedAdd + ClosedMul +where N: Scalar + Copy + Zero + ClosedAdd + ClosedMul { #[inline(always)] fn gerx( @@ -1249,7 +1249,7 @@ where N: Scalar + Zero + ClosedAdd + ClosedMul } impl> Matrix -where N: Scalar + Zero + ClosedAdd + ClosedMul +where N: Scalar + Copy + Zero + ClosedAdd + ClosedMul { #[inline(always)] fn xxgerx( @@ -1396,7 +1396,7 @@ where N: Scalar + Zero + ClosedAdd + ClosedMul } impl> SquareMatrix -where N: Scalar + Zero + One + ClosedAdd + ClosedMul +where N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul { /// Computes the quadratic form `self = alpha * lhs * mid * lhs.transpose() + beta * self`. /// diff --git a/src/base/cg.rs b/src/base/cg.rs index 0822ea27..5908c111 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -23,7 +23,7 @@ use alga::linear::Transformation; impl MatrixN where - N: Scalar + Ring, + N: Scalar + Copy + Ring, DefaultAllocator: Allocator, { /// Creates a new homogeneous matrix that applies the same scaling factor on each dimension. @@ -153,7 +153,7 @@ impl Matrix4 { } } -impl> SquareMatrix { +impl> SquareMatrix { /// Computes the transformation equal to `self` followed by an uniform scaling factor. #[inline] pub fn append_scaling(&self, scaling: N) -> MatrixN @@ -240,7 +240,7 @@ impl> SquareMatrix { } } -impl> SquareMatrix { +impl> SquareMatrix { /// Computes in-place the transformation equal to `self` followed by an uniform scaling factor. #[inline] pub fn append_scaling_mut(&mut self, scaling: N) diff --git a/src/base/componentwise.rs b/src/base/componentwise.rs index e5f4d7ec..5fadcf36 100644 --- a/src/base/componentwise.rs +++ b/src/base/componentwise.rs @@ -14,7 +14,7 @@ use crate::base::{DefaultAllocator, Matrix, MatrixMN, MatrixSum, Scalar}; /// The type of the result of a matrix component-wise operation. pub type MatrixComponentOp = MatrixSum; -impl> Matrix { +impl> Matrix { /// Computes the component-wise absolute value. /// /// # Example @@ -45,7 +45,7 @@ impl> Matrix { macro_rules! component_binop_impl( ($($binop: ident, $binop_mut: ident, $binop_assign: ident, $cmpy: ident, $Trait: ident . $op: ident . $op_assign: ident, $desc:expr, $desc_cmpy:expr, $desc_mut:expr);* $(;)*) => {$( - impl> Matrix { + impl> Matrix { #[doc = $desc] #[inline] pub fn $binop(&self, rhs: &Matrix) -> MatrixComponentOp @@ -70,7 +70,7 @@ macro_rules! component_binop_impl( } } - impl> Matrix { + impl> Matrix { // componentwise binop plus Y. #[doc = $desc_cmpy] #[inline] diff --git a/src/base/construction.rs b/src/base/construction.rs index 228ce114..c28c043b 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -27,7 +27,7 @@ use crate::base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Scalar, Unit, Vec * Generic constructors. * */ -impl MatrixMN +impl MatrixMN where DefaultAllocator: Allocator { /// Creates a new uninitialized matrix. If the matrix has a compile-time dimension, this panics @@ -286,7 +286,7 @@ where DefaultAllocator: Allocator impl MatrixN where - N: Scalar, + N: Scalar + Copy, DefaultAllocator: Allocator, { /// Creates a square matrix with its diagonal set to `diag` and all other entries set to 0. @@ -330,7 +330,7 @@ where */ macro_rules! impl_constructors( ($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => { - impl MatrixMN + impl MatrixMN where DefaultAllocator: Allocator { /// Creates a new uninitialized matrix or vector. @@ -559,7 +559,7 @@ macro_rules! impl_constructors( } } - impl MatrixMN + impl MatrixMN where DefaultAllocator: Allocator, Standard: Distribution { @@ -603,7 +603,7 @@ impl_constructors!(Dynamic, Dynamic; */ macro_rules! impl_constructors_from_data( ($data: ident; $($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => { - impl MatrixMN + impl MatrixMN where DefaultAllocator: Allocator { /// Creates a matrix with its elements filled with the components provided by a slice /// in row-major order. @@ -721,7 +721,7 @@ impl_constructors_from_data!(data; Dynamic, Dynamic; */ impl Zero for MatrixMN where - N: Scalar + Zero + ClosedAdd, + N: Scalar + Copy + Zero + ClosedAdd, DefaultAllocator: Allocator, { #[inline] @@ -737,7 +737,7 @@ where impl One for MatrixN where - N: Scalar + Zero + One + ClosedMul + ClosedAdd, + N: Scalar + Copy + Zero + One + ClosedMul + ClosedAdd, DefaultAllocator: Allocator, { #[inline] @@ -748,7 +748,7 @@ where impl Bounded for MatrixMN where - N: Scalar + Bounded, + N: Scalar + Copy + Bounded, DefaultAllocator: Allocator, { #[inline] @@ -762,7 +762,7 @@ where } } -impl Distribution> for Standard +impl Distribution> for Standard where DefaultAllocator: Allocator, Standard: Distribution, @@ -822,7 +822,7 @@ where macro_rules! componentwise_constructors_impl( ($($R: ty, $C: ty, $($args: ident:($irow: expr,$icol: expr)),*);* $(;)*) => {$( impl MatrixMN - where N: Scalar, + where N: Scalar + Copy, DefaultAllocator: Allocator { /// Initializes this matrix from its components. #[inline] @@ -990,7 +990,7 @@ componentwise_constructors_impl!( */ impl VectorN where - N: Scalar + Zero + One, + N: Scalar + Copy + Zero + One, DefaultAllocator: Allocator, { /// The column vector with a 1 as its first component, and zero elsewhere. diff --git a/src/base/construction_slice.rs b/src/base/construction_slice.rs index 4f745a65..029abc69 100644 --- a/src/base/construction_slice.rs +++ b/src/base/construction_slice.rs @@ -8,7 +8,7 @@ use num_rational::Ratio; * Slice constructors. * */ -impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSliceMN<'a, N, R, C, RStride, CStride> { /// Creates, without bound-checking, a matrix slice from an array and with dimensions and strides specified by generic types instances. @@ -61,7 +61,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> } } -impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSliceMutMN<'a, N, R, C, RStride, CStride> { /// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions and strides specified by generic types instances. @@ -133,7 +133,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> } } -impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> { /// Creates, without bound-checking, a matrix slice from an array and with dimensions specified by generic types instances. /// /// This method is unsafe because the input data array is not checked to contain enough elements. @@ -159,7 +159,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> { } } -impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, N, R, C> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim> MatrixSliceMutMN<'a, N, R, C> { /// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions specified by generic types instances. /// /// This method is unsafe because the input data array is not checked to contain enough elements. @@ -187,7 +187,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, N, R, C> { macro_rules! impl_constructors( ($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => { - impl<'a, N: Scalar, $($DimIdent: $DimBound),*> MatrixSliceMN<'a, N, $($Dims),*> { + impl<'a, N: Scalar + Copy, $($DimIdent: $DimBound),*> MatrixSliceMN<'a, N, $($Dims),*> { /// Creates a new matrix slice from the given data array. /// /// Panics if `data` does not contain enough elements. @@ -203,7 +203,7 @@ macro_rules! impl_constructors( } } - impl<'a, N: Scalar, $($DimIdent: $DimBound, )*> MatrixSliceMN<'a, N, $($Dims,)* Dynamic, Dynamic> { + impl<'a, N: Scalar + Copy, $($DimIdent: $DimBound, )*> MatrixSliceMN<'a, N, $($Dims,)* Dynamic, Dynamic> { /// Creates a new matrix slice with the specified strides from the given data array. /// /// Panics if `data` does not contain enough elements. @@ -244,7 +244,7 @@ impl_constructors!(Dynamic, Dynamic; macro_rules! impl_constructors_mut( ($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => { - impl<'a, N: Scalar, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, N, $($Dims),*> { + impl<'a, N: Scalar + Copy, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, N, $($Dims),*> { /// Creates a new mutable matrix slice from the given data array. /// /// Panics if `data` does not contain enough elements. @@ -260,7 +260,7 @@ macro_rules! impl_constructors_mut( } } - impl<'a, N: Scalar, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, N, $($Dims,)* Dynamic, Dynamic> { + impl<'a, N: Scalar + Copy, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, N, $($Dims,)* Dynamic, Dynamic> { /// Creates a new mutable matrix slice with the specified strides from the given data array. /// /// Panics if `data` does not contain enough elements. diff --git a/src/base/conversion.rs b/src/base/conversion.rs index 7763a086..883f3fb8 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -31,8 +31,8 @@ where C1: Dim, R2: Dim, C2: Dim, - N1: Scalar, - N2: Scalar + SupersetOf, + N1: Scalar + Copy, + N2: Scalar + Copy + SupersetOf, DefaultAllocator: Allocator + Allocator + SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, @@ -75,7 +75,7 @@ where } } -impl<'a, N: Scalar, R: Dim, C: Dim, S: Storage> IntoIterator for &'a Matrix { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: Storage> IntoIterator for &'a Matrix { type Item = &'a N; type IntoIter = MatrixIter<'a, N, R, C, S>; @@ -85,7 +85,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: Storage> IntoIterator for &'a Ma } } -impl<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> IntoIterator +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: StorageMut> IntoIterator for &'a mut Matrix { type Item = &'a mut N; @@ -100,7 +100,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> IntoIterator macro_rules! impl_from_into_asref_1D( ($(($NRows: ident, $NCols: ident) => $SZ: expr);* $(;)*) => {$( impl From<[N; $SZ]> for MatrixMN - where N: Scalar, + where N: Scalar + Copy, DefaultAllocator: Allocator { #[inline] fn from(arr: [N; $SZ]) -> Self { @@ -114,7 +114,7 @@ macro_rules! impl_from_into_asref_1D( } impl Into<[N; $SZ]> for Matrix - where N: Scalar, + where N: Scalar + Copy, S: ContiguousStorage { #[inline] fn into(self) -> [N; $SZ] { @@ -128,7 +128,7 @@ macro_rules! impl_from_into_asref_1D( } impl AsRef<[N; $SZ]> for Matrix - where N: Scalar, + where N: Scalar + Copy, S: ContiguousStorage { #[inline] fn as_ref(&self) -> &[N; $SZ] { @@ -139,7 +139,7 @@ macro_rules! impl_from_into_asref_1D( } impl AsMut<[N; $SZ]> for Matrix - where N: Scalar, + where N: Scalar + Copy, S: ContiguousStorageMut { #[inline] fn as_mut(&mut self) -> &mut [N; $SZ] { @@ -168,7 +168,7 @@ impl_from_into_asref_1D!( macro_rules! impl_from_into_asref_2D( ($(($NRows: ty, $NCols: ty) => ($SZRows: expr, $SZCols: expr));* $(;)*) => {$( - impl From<[[N; $SZRows]; $SZCols]> for MatrixMN + impl From<[[N; $SZRows]; $SZCols]> for MatrixMN where DefaultAllocator: Allocator { #[inline] fn from(arr: [[N; $SZRows]; $SZCols]) -> Self { @@ -181,7 +181,7 @@ macro_rules! impl_from_into_asref_2D( } } - impl Into<[[N; $SZRows]; $SZCols]> for Matrix + impl Into<[[N; $SZRows]; $SZCols]> for Matrix where S: ContiguousStorage { #[inline] fn into(self) -> [[N; $SZRows]; $SZCols] { @@ -194,7 +194,7 @@ macro_rules! impl_from_into_asref_2D( } } - impl AsRef<[[N; $SZRows]; $SZCols]> for Matrix + impl AsRef<[[N; $SZRows]; $SZCols]> for Matrix where S: ContiguousStorage { #[inline] fn as_ref(&self) -> &[[N; $SZRows]; $SZCols] { @@ -204,7 +204,7 @@ macro_rules! impl_from_into_asref_2D( } } - impl AsMut<[[N; $SZRows]; $SZCols]> for Matrix + impl AsMut<[[N; $SZRows]; $SZCols]> for Matrix where S: ContiguousStorageMut { #[inline] fn as_mut(&mut self) -> &mut [[N; $SZRows]; $SZCols] { @@ -229,7 +229,7 @@ impl_from_into_asref_2D!( macro_rules! impl_from_into_mint_1D( ($($NRows: ident => $VT:ident [$SZ: expr]);* $(;)*) => {$( impl From> for MatrixMN - where N: Scalar, + where N: Scalar + Copy, DefaultAllocator: Allocator { #[inline] fn from(v: mint::$VT) -> Self { @@ -243,7 +243,7 @@ macro_rules! impl_from_into_mint_1D( } impl Into> for Matrix - where N: Scalar, + where N: Scalar + Copy, S: ContiguousStorage { #[inline] fn into(self) -> mint::$VT { @@ -257,7 +257,7 @@ macro_rules! impl_from_into_mint_1D( } impl AsRef> for Matrix - where N: Scalar, + where N: Scalar + Copy, S: ContiguousStorage { #[inline] fn as_ref(&self) -> &mint::$VT { @@ -268,7 +268,7 @@ macro_rules! impl_from_into_mint_1D( } impl AsMut> for Matrix - where N: Scalar, + where N: Scalar + Copy, S: ContiguousStorageMut { #[inline] fn as_mut(&mut self) -> &mut mint::$VT { @@ -292,7 +292,7 @@ impl_from_into_mint_1D!( macro_rules! impl_from_into_mint_2D( ($(($NRows: ty, $NCols: ty) => $MV:ident{ $($component:ident),* }[$SZRows: expr]);* $(;)*) => {$( impl From> for MatrixMN - where N: Scalar, + where N: Scalar + Copy, DefaultAllocator: Allocator { #[inline] fn from(m: mint::$MV) -> Self { @@ -310,7 +310,7 @@ macro_rules! impl_from_into_mint_2D( } impl Into> for MatrixMN - where N: Scalar, + where N: Scalar + Copy, DefaultAllocator: Allocator { #[inline] fn into(self) -> mint::$MV { @@ -342,7 +342,7 @@ impl_from_into_mint_2D!( impl<'a, N, R, C, RStride, CStride> From> for Matrix> where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, RStride: Dim, @@ -359,7 +359,7 @@ where impl<'a, N, C, RStride, CStride> From> for Matrix> where - N: Scalar, + N: Scalar + Copy, C: Dim, RStride: Dim, CStride: Dim, @@ -373,7 +373,7 @@ where impl<'a, N, R, RStride, CStride> From> for Matrix> where - N: Scalar, + N: Scalar + Copy, R: DimName, RStride: Dim, CStride: Dim, @@ -386,7 +386,7 @@ where impl<'a, N, R, C, RStride, CStride> From> for Matrix> where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, RStride: Dim, @@ -403,7 +403,7 @@ where impl<'a, N, C, RStride, CStride> From> for Matrix> where - N: Scalar, + N: Scalar + Copy, C: Dim, RStride: Dim, CStride: Dim, @@ -417,7 +417,7 @@ where impl<'a, N, R, RStride, CStride> From> for Matrix> where - N: Scalar, + N: Scalar + Copy, R: DimName, RStride: Dim, CStride: Dim, @@ -430,7 +430,7 @@ where impl<'a, N, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a Matrix> for MatrixSlice<'a, N, RSlice, CSlice, RStride, CStride> where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, RSlice: Dim, @@ -463,7 +463,7 @@ for MatrixSlice<'a, N, RSlice, CSlice, RStride, CStride> impl<'a, N, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix> for MatrixSlice<'a, N, RSlice, CSlice, RStride, CStride> where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, RSlice: Dim, @@ -496,7 +496,7 @@ for MatrixSlice<'a, N, RSlice, CSlice, RStride, CStride> impl<'a, N, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix> for MatrixSliceMut<'a, N, RSlice, CSlice, RStride, CStride> where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, RSlice: Dim, diff --git a/src/base/coordinates.rs b/src/base/coordinates.rs index 832723e3..38c7edac 100644 --- a/src/base/coordinates.rs +++ b/src/base/coordinates.rs @@ -24,7 +24,7 @@ macro_rules! coords_impl( #[repr(C)] #[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] - pub struct $T { + pub struct $T { $(pub $comps: N),* } } @@ -32,7 +32,7 @@ macro_rules! coords_impl( macro_rules! deref_impl( ($R: ty, $C: ty; $Target: ident) => { - impl Deref for Matrix + impl Deref for Matrix where S: ContiguousStorage { type Target = $Target; @@ -42,7 +42,7 @@ macro_rules! deref_impl( } } - impl DerefMut for Matrix + impl DerefMut for Matrix where S: ContiguousStorageMut { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index c07c8708..ee6786c5 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -36,7 +36,7 @@ pub struct DefaultAllocator; // Static - Static impl Allocator for DefaultAllocator where - N: Scalar, + N: Scalar + Copy, R: DimName, C: DimName, R::Value: Mul, @@ -76,7 +76,7 @@ where // Dynamic - Static // Dynamic - Dynamic #[cfg(any(feature = "std", feature = "alloc"))] -impl Allocator for DefaultAllocator { +impl Allocator for DefaultAllocator { type Buffer = VecStorage; #[inline] @@ -107,7 +107,7 @@ impl Allocator for DefaultAllocator { // Static - Dynamic #[cfg(any(feature = "std", feature = "alloc"))] -impl Allocator for DefaultAllocator { +impl Allocator for DefaultAllocator { type Buffer = VecStorage; #[inline] @@ -142,7 +142,7 @@ impl Allocator for DefaultAllocator { * */ // Anything -> Static × Static -impl Reallocator for DefaultAllocator +impl Reallocator for DefaultAllocator where RFrom: Dim, CFrom: Dim, @@ -173,7 +173,7 @@ where // Static × Static -> Dynamic × Any #[cfg(any(feature = "std", feature = "alloc"))] -impl Reallocator for DefaultAllocator +impl Reallocator for DefaultAllocator where RFrom: DimName, CFrom: DimName, @@ -202,7 +202,7 @@ where // Static × Static -> Static × Dynamic #[cfg(any(feature = "std", feature = "alloc"))] -impl Reallocator for DefaultAllocator +impl Reallocator for DefaultAllocator where RFrom: DimName, CFrom: DimName, @@ -231,7 +231,7 @@ where // All conversion from a dynamic buffer to a dynamic buffer. #[cfg(any(feature = "std", feature = "alloc"))] -impl Reallocator +impl Reallocator for DefaultAllocator { #[inline] @@ -247,7 +247,7 @@ impl Reallocator Reallocator +impl Reallocator for DefaultAllocator { #[inline] @@ -263,7 +263,7 @@ impl Reallocator Reallocator +impl Reallocator for DefaultAllocator { #[inline] @@ -279,7 +279,7 @@ impl Reallocator Reallocator +impl Reallocator for DefaultAllocator { #[inline] diff --git a/src/base/edition.rs b/src/base/edition.rs index e473246f..cc4d4295 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -18,7 +18,7 @@ use crate::base::storage::{Storage, StorageMut}; use crate::base::DMatrix; use crate::base::{DefaultAllocator, Matrix, MatrixMN, RowVector, Scalar, Vector}; -impl> Matrix { +impl> Matrix { /// Extracts the upper triangular part of this matrix (including the diagonal). #[inline] pub fn upper_triangle(&self) -> MatrixMN @@ -92,7 +92,7 @@ impl> Matrix { } } -impl> Matrix { +impl> Matrix { /// Sets all the elements of this matrix to `val`. #[inline] pub fn fill(&mut self, val: N) { @@ -253,7 +253,7 @@ impl> Matrix { } } -impl> Matrix { +impl> Matrix { /// Copies the upper-triangle of this matrix to its lower-triangular part. /// /// This makes the matrix symmetric. Panics if the matrix is not square. @@ -291,7 +291,7 @@ impl> Matrix { * FIXME: specialize all the following for slices. * */ -impl> Matrix { +impl> Matrix { /* * * Column removal. @@ -797,7 +797,7 @@ impl> Matrix { } #[cfg(any(feature = "std", feature = "alloc"))] -impl DMatrix { +impl DMatrix { /// Resizes this matrix in-place. /// /// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more @@ -814,7 +814,7 @@ impl DMatrix { } #[cfg(any(feature = "std", feature = "alloc"))] -impl MatrixMN +impl MatrixMN where DefaultAllocator: Allocator { /// Changes the number of rows of this matrix in-place. @@ -835,7 +835,7 @@ where DefaultAllocator: Allocator } #[cfg(any(feature = "std", feature = "alloc"))] -impl MatrixMN +impl MatrixMN where DefaultAllocator: Allocator { /// Changes the number of column of this matrix in-place. @@ -855,7 +855,7 @@ where DefaultAllocator: Allocator } } -unsafe fn compress_rows( +unsafe fn compress_rows( data: &mut [N], nrows: usize, ncols: usize, @@ -895,7 +895,7 @@ unsafe fn compress_rows( // Moves entries of a matrix buffer to make place for `ninsert` emty rows starting at the `i-th` row index. // The `data` buffer is assumed to contained at least `(nrows + ninsert) * ncols` elements. -unsafe fn extend_rows( +unsafe fn extend_rows( data: &mut [N], nrows: usize, ncols: usize, @@ -938,7 +938,7 @@ unsafe fn extend_rows( #[cfg(any(feature = "std", feature = "alloc"))] impl Extend for Matrix where - N: Scalar, + N: Scalar + Copy, R: Dim, S: Extend, { @@ -986,7 +986,7 @@ where #[cfg(any(feature = "std", feature = "alloc"))] impl Extend for Matrix where - N: Scalar, + N: Scalar + Copy, S: Extend, { /// Extend the number of rows of a `Vector` with elements @@ -1007,7 +1007,7 @@ where #[cfg(any(feature = "std", feature = "alloc"))] impl Extend> for Matrix where - N: Scalar, + N: Scalar + Copy, R: Dim, S: Extend>, RV: Dim, diff --git a/src/base/indexing.rs b/src/base/indexing.rs index ca786530..8ce52454 100644 --- a/src/base/indexing.rs +++ b/src/base/indexing.rs @@ -267,7 +267,7 @@ fn dimrange_rangetoinclusive_usize() { } /// A helper trait used for indexing operations. -pub trait MatrixIndex<'a, N: Scalar, R: Dim, C: Dim, S: Storage>: Sized { +pub trait MatrixIndex<'a, N: Scalar + Copy, R: Dim, C: Dim, S: Storage>: Sized { /// The output type returned by methods. type Output : 'a; @@ -303,7 +303,7 @@ pub trait MatrixIndex<'a, N: Scalar, R: Dim, C: Dim, S: Storage>: Sized } /// A helper trait used for indexing operations. -pub trait MatrixIndexMut<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut>: MatrixIndex<'a, N, R, C, S> { +pub trait MatrixIndexMut<'a, N: Scalar + Copy, R: Dim, C: Dim, S: StorageMut>: MatrixIndex<'a, N, R, C, S> { /// The output type returned by methods. type OutputMut : 'a; @@ -432,7 +432,7 @@ pub trait MatrixIndexMut<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut>: /// 4, 7, /// 5, 8))); /// ``` -impl> Matrix +impl> Matrix { /// Produces a view of the data at the given index, or /// `None` if the index is out of bounds. @@ -502,7 +502,7 @@ impl> Matrix impl<'a, N, R, C, S> MatrixIndex<'a, N, R, C, S> for usize where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, S: Storage @@ -524,7 +524,7 @@ where impl<'a, N, R, C, S> MatrixIndexMut<'a, N, R, C, S> for usize where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, S: StorageMut @@ -544,7 +544,7 @@ where impl<'a, N, R, C, S> MatrixIndex<'a, N, R, C, S> for (usize, usize) where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, S: Storage @@ -569,7 +569,7 @@ where impl<'a, N, R, C, S> MatrixIndexMut<'a, N, R, C, S> for (usize, usize) where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, S: StorageMut @@ -607,7 +607,7 @@ macro_rules! impl_index_pair { { impl<'a, N, $R, $C, S, $($RTyP : $RTyPB,)* $($CTyP : $CTyPB),*> MatrixIndex<'a, N, $R, $C, S> for ($RIdx, $CIdx) where - N: Scalar, + N: Scalar + Copy, $R: Dim, $C: Dim, S: Storage, @@ -643,7 +643,7 @@ macro_rules! impl_index_pair { impl<'a, N, $R, $C, S, $($RTyP : $RTyPB,)* $($CTyP : $CTyPB),*> MatrixIndexMut<'a, N, $R, $C, S> for ($RIdx, $CIdx) where - N: Scalar, + N: Scalar + Copy, $R: Dim, $C: Dim, S: StorageMut, diff --git a/src/base/iter.rs b/src/base/iter.rs index 74e4f018..966f97e0 100644 --- a/src/base/iter.rs +++ b/src/base/iter.rs @@ -10,7 +10,7 @@ use crate::base::{Scalar, Matrix, MatrixSlice, MatrixSliceMut}; macro_rules! iterator { (struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => { /// An iterator through a dense matrix with arbitrary strides matrix. - pub struct $Name<'a, N: Scalar, R: Dim, C: Dim, S: 'a + $Storage> { + pub struct $Name<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + $Storage> { ptr: $Ptr, inner_ptr: $Ptr, inner_end: $Ptr, @@ -21,7 +21,7 @@ macro_rules! iterator { // FIXME: we need to specialize for the case where the matrix storage is owned (in which // case the iterator is trivial because it does not have any stride). - impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + $Storage> $Name<'a, N, R, C, S> { + impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + $Storage> $Name<'a, N, R, C, S> { /// Creates a new iterator for the given matrix storage. pub fn new(storage: $SRef) -> $Name<'a, N, R, C, S> { let shape = storage.shape(); @@ -40,7 +40,7 @@ macro_rules! iterator { } } - impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + $Storage> Iterator + impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + $Storage> Iterator for $Name<'a, N, R, C, S> { type Item = $Ref; @@ -83,7 +83,7 @@ macro_rules! iterator { } } - impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + $Storage> ExactSizeIterator + impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + $Storage> ExactSizeIterator for $Name<'a, N, R, C, S> { #[inline] @@ -105,12 +105,12 @@ iterator!(struct MatrixIterMut for StorageMut.ptr_mut -> *mut N, &'a mut N, &'a */ #[derive(Clone)] /// An iterator through the rows of a matrix. -pub struct RowIter<'a, N: Scalar, R: Dim, C: Dim, S: Storage> { +pub struct RowIter<'a, N: Scalar + Copy, R: Dim, C: Dim, S: Storage> { mat: &'a Matrix, curr: usize } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> RowIter<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + Storage> RowIter<'a, N, R, C, S> { pub(crate) fn new(mat: &'a Matrix) -> Self { RowIter { mat, curr: 0 @@ -119,7 +119,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> RowIter<'a, N, R, } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> Iterator for RowIter<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + Storage> Iterator for RowIter<'a, N, R, C, S> { type Item = MatrixSlice<'a, N, U1, C, S::RStride, S::CStride>; #[inline] @@ -144,7 +144,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> Iterator for RowIt } } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator for RowIter<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator for RowIter<'a, N, R, C, S> { #[inline] fn len(&self) -> usize { self.mat.nrows() - self.curr @@ -153,13 +153,13 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator /// An iterator through the mutable rows of a matrix. -pub struct RowIterMut<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> { +pub struct RowIterMut<'a, N: Scalar + Copy, R: Dim, C: Dim, S: StorageMut> { mat: *mut Matrix, curr: usize, phantom: PhantomData<&'a mut Matrix> } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> RowIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + StorageMut> RowIterMut<'a, N, R, C, S> { pub(crate) fn new(mat: &'a mut Matrix) -> Self { RowIterMut { mat, @@ -176,7 +176,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> RowIterMut<'a, } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for RowIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for RowIterMut<'a, N, R, C, S> { type Item = MatrixSliceMut<'a, N, U1, C, S::RStride, S::CStride>; #[inline] @@ -201,7 +201,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for Ro } } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterator for RowIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterator for RowIterMut<'a, N, R, C, S> { #[inline] fn len(&self) -> usize { self.nrows() - self.curr @@ -216,12 +216,12 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterat */ #[derive(Clone)] /// An iterator through the columns of a matrix. -pub struct ColumnIter<'a, N: Scalar, R: Dim, C: Dim, S: Storage> { +pub struct ColumnIter<'a, N: Scalar + Copy, R: Dim, C: Dim, S: Storage> { mat: &'a Matrix, curr: usize } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> ColumnIter<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + Storage> ColumnIter<'a, N, R, C, S> { pub(crate) fn new(mat: &'a Matrix) -> Self { ColumnIter { mat, curr: 0 @@ -230,7 +230,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> ColumnIter<'a, N, } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> Iterator for ColumnIter<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + Storage> Iterator for ColumnIter<'a, N, R, C, S> { type Item = MatrixSlice<'a, N, R, U1, S::RStride, S::CStride>; #[inline] @@ -255,7 +255,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> Iterator for Colum } } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator for ColumnIter<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator for ColumnIter<'a, N, R, C, S> { #[inline] fn len(&self) -> usize { self.mat.ncols() - self.curr @@ -264,13 +264,13 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator /// An iterator through the mutable columns of a matrix. -pub struct ColumnIterMut<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> { +pub struct ColumnIterMut<'a, N: Scalar + Copy, R: Dim, C: Dim, S: StorageMut> { mat: *mut Matrix, curr: usize, phantom: PhantomData<&'a mut Matrix> } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> ColumnIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + StorageMut> ColumnIterMut<'a, N, R, C, S> { pub(crate) fn new(mat: &'a mut Matrix) -> Self { ColumnIterMut { mat, @@ -287,7 +287,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> ColumnIterMut<' } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for ColumnIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for ColumnIterMut<'a, N, R, C, S> { type Item = MatrixSliceMut<'a, N, R, U1, S::RStride, S::CStride>; #[inline] @@ -312,7 +312,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for Co } } -impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterator for ColumnIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterator for ColumnIterMut<'a, N, R, C, S> { #[inline] fn len(&self) -> usize { self.ncols() - self.curr diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 54241436..08c22cbb 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -73,7 +73,7 @@ pub type MatrixCross = /// some concrete types for `N` and a compatible data storage type `S`). #[repr(C)] #[derive(Clone, Copy)] -pub struct Matrix { +pub struct Matrix { /// The data storage that contains all the matrix components and informations about its number /// of rows and column (if needed). pub data: S, @@ -81,7 +81,7 @@ pub struct Matrix { _phantoms: PhantomData<(N, R, C)>, } -impl fmt::Debug for Matrix { +impl fmt::Debug for Matrix { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { formatter .debug_struct("Matrix") @@ -93,7 +93,7 @@ impl fmt::Debug for Matrix #[cfg(feature = "serde-serialize")] impl Serialize for Matrix where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, S: Serialize, @@ -107,7 +107,7 @@ where #[cfg(feature = "serde-serialize")] impl<'de, N, R, C, S> Deserialize<'de> for Matrix where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, S: Deserialize<'de>, @@ -122,7 +122,7 @@ where } #[cfg(feature = "abomonation-serialize")] -impl Abomonation for Matrix { +impl Abomonation for Matrix { unsafe fn entomb(&self, writer: &mut W) -> IOResult<()> { self.data.entomb(writer) } @@ -136,7 +136,7 @@ impl Abomonation for Matrix Matrix { +impl Matrix { /// Creates a new matrix with the given data without statically checking that the matrix /// dimension matches the storage dimension. #[inline] @@ -148,7 +148,7 @@ impl Matrix { } } -impl> Matrix { +impl> Matrix { /// Creates a new matrix with the given data. #[inline] pub fn from_data(data: S) -> Self { @@ -413,7 +413,7 @@ impl> Matrix { /// Returns a matrix containing the result of `f` applied to each of its entries. #[inline] - pub fn map N2>(&self, mut f: F) -> MatrixMN + pub fn map N2>(&self, mut f: F) -> MatrixMN where DefaultAllocator: Allocator { let (nrows, ncols) = self.data.shape(); @@ -434,7 +434,7 @@ impl> Matrix { /// Returns a matrix containing the result of `f` applied to each of its entries. Unlike `map`, /// `f` also gets passed the row and column index, i.e. `f(row, col, value)`. #[inline] - pub fn map_with_location N2>( + pub fn map_with_location N2>( &self, mut f: F, ) -> MatrixMN @@ -462,8 +462,8 @@ impl> Matrix { #[inline] pub fn zip_map(&self, rhs: &Matrix, mut f: F) -> MatrixMN where - N2: Scalar, - N3: Scalar, + N2: Scalar + Copy, + N3: Scalar + Copy, S2: Storage, F: FnMut(N, N2) -> N3, DefaultAllocator: Allocator, @@ -500,9 +500,9 @@ impl> Matrix { mut f: F, ) -> MatrixMN where - N2: Scalar, - N3: Scalar, - N4: Scalar, + N2: Scalar + Copy, + N3: Scalar + Copy, + N4: Scalar + Copy, S2: Storage, S3: Storage, F: FnMut(N, N2, N3) -> N4, @@ -555,7 +555,7 @@ impl> Matrix { #[inline] pub fn zip_fold(&self, rhs: &Matrix, init: Acc, mut f: impl FnMut(Acc, N, N2) -> Acc) -> Acc where - N2: Scalar, + N2: Scalar + Copy, R2: Dim, C2: Dim, S2: Storage, @@ -623,7 +623,7 @@ impl> Matrix { } } -impl> Matrix { +impl> Matrix { /// Mutably iterates through this matrix coordinates. #[inline] pub fn iter_mut(&mut self) -> MatrixIterMut { @@ -797,7 +797,7 @@ impl> Matrix { /// joined with the components from `rhs`. #[inline] pub fn zip_apply(&mut self, rhs: &Matrix, mut f: impl FnMut(N, N2) -> N) - where N2: Scalar, + where N2: Scalar + Copy, R2: Dim, C2: Dim, S2: Storage, @@ -825,11 +825,11 @@ impl> Matrix { /// joined with the components from `b` and `c`. #[inline] pub fn zip_zip_apply(&mut self, b: &Matrix, c: &Matrix, mut f: impl FnMut(N, N2, N3) -> N) - where N2: Scalar, + where N2: Scalar + Copy, R2: Dim, C2: Dim, S2: Storage, - N3: Scalar, + N3: Scalar + Copy, R3: Dim, C3: Dim, S3: Storage, @@ -859,7 +859,7 @@ impl> Matrix { } } -impl> Vector { +impl> Vector { /// Gets a reference to the i-th element of this column vector without bound checking. #[inline] pub unsafe fn vget_unchecked(&self, i: usize) -> &N { @@ -869,7 +869,7 @@ impl> Vector { } } -impl> Vector { +impl> Vector { /// Gets a mutable reference to the i-th element of this column vector without bound checking. #[inline] pub unsafe fn vget_unchecked_mut(&mut self, i: usize) -> &mut N { @@ -879,7 +879,7 @@ impl> Vector { } } -impl> Matrix { +impl> Matrix { /// Extracts a slice containing the entire matrix entries ordered column-by-columns. #[inline] pub fn as_slice(&self) -> &[N] { @@ -887,7 +887,7 @@ impl> Matrix> Matrix { +impl> Matrix { /// Extracts a mutable slice containing the entire matrix entries ordered column-by-columns. #[inline] pub fn as_mut_slice(&mut self) -> &mut [N] { @@ -895,7 +895,7 @@ impl> Matrix> Matrix { +impl> Matrix { /// Transposes the square matrix `self` in-place. pub fn transpose_mut(&mut self) { assert!( @@ -1052,7 +1052,7 @@ impl> Matrix { } } -impl> SquareMatrix { +impl> SquareMatrix { /// The diagonal of this matrix. #[inline] pub fn diagonal(&self) -> VectorN @@ -1064,7 +1064,7 @@ impl> SquareMatrix { /// /// This is a more efficient version of `self.diagonal().map(f)` since this /// allocates only once. - pub fn map_diagonal(&self, mut f: impl FnMut(N) -> N2) -> VectorN + pub fn map_diagonal(&self, mut f: impl FnMut(N) -> N2) -> VectorN where DefaultAllocator: Allocator { assert!( self.is_square(), @@ -1128,7 +1128,7 @@ impl> SquareMatrix { } } -impl + IsNotStaticOne, S: Storage> Matrix { +impl + IsNotStaticOne, S: Storage> Matrix { /// Yields the homogeneous matrix for this matrix, i.e., appending an additional dimension and /// and setting the diagonal element to `1`. @@ -1144,7 +1144,7 @@ impl + IsNotStaticOne, S: Storage } -impl, S: Storage> Vector { +impl, S: Storage> Vector { /// Computes the coordinates in projective space of this vector, i.e., appends a `0` to its /// coordinates. #[inline] @@ -1170,7 +1170,7 @@ impl, S: Storage> Vector { } } -impl, S: Storage> Vector { +impl, S: Storage> Vector { /// Constructs a new vector of higher dimension by appending `element` to the end of `self`. #[inline] pub fn push(&self, element: N) -> VectorN> @@ -1188,7 +1188,7 @@ impl, S: Storage> Vector { impl AbsDiffEq for Matrix where - N: Scalar + AbsDiffEq, + N: Scalar + Copy + AbsDiffEq, S: Storage, N::Epsilon: Copy, { @@ -1209,7 +1209,7 @@ where impl RelativeEq for Matrix where - N: Scalar + RelativeEq, + N: Scalar + Copy + RelativeEq, S: Storage, N::Epsilon: Copy, { @@ -1232,7 +1232,7 @@ where impl UlpsEq for Matrix where - N: Scalar + UlpsEq, + N: Scalar + Copy + UlpsEq, S: Storage, N::Epsilon: Copy, { @@ -1252,7 +1252,7 @@ where impl PartialOrd for Matrix where - N: Scalar + PartialOrd, + N: Scalar + Copy + PartialOrd, S: Storage, { #[inline] @@ -1340,13 +1340,13 @@ where impl Eq for Matrix where - N: Scalar + Eq, + N: Scalar + Copy + Eq, S: Storage, {} impl PartialEq for Matrix where - N: Scalar, + N: Scalar + Copy, S: Storage, { #[inline] @@ -1363,13 +1363,13 @@ macro_rules! impl_fmt { ($trait: path, $fmt_str_without_precision: expr, $fmt_str_with_precision: expr) => { impl $trait for Matrix where - N: Scalar + $trait, + N: Scalar + Copy + $trait, S: Storage, DefaultAllocator: Allocator, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[cfg(feature = "std")] - fn val_width(val: N, f: &mut fmt::Formatter) -> usize { + fn val_width(val: N, f: &mut fmt::Formatter) -> usize { match f.precision() { Some(precision) => format!($fmt_str_with_precision, val, precision).chars().count(), None => format!($fmt_str_without_precision, val).chars().count(), @@ -1377,7 +1377,7 @@ macro_rules! impl_fmt { } #[cfg(not(feature = "std"))] - fn val_width(_: N, _: &mut fmt::Formatter) -> usize { + fn val_width(_: N, _: &mut fmt::Formatter) -> usize { 4 } @@ -1454,7 +1454,7 @@ fn lower_exp() { ") } -impl> Matrix { +impl> Matrix { /// The perpendicular product between two 2D column vectors, i.e. `a.x * b.y - a.y * b.x`. #[inline] pub fn perp(&self, b: &Matrix) -> N @@ -1545,7 +1545,7 @@ impl> Matrix { } } -impl> Vector +impl> Vector where DefaultAllocator: Allocator { /// Computes the matrix `M` such that for all vector `v` we have `M * v == self.cross(&v)`. @@ -1593,7 +1593,7 @@ impl> Matrix { } } -impl> +impl> Vector { /// Returns `self * (1.0 - t) + rhs * t`, i.e., the linear blend of the vectors x and y using the scalar value a. @@ -1683,7 +1683,7 @@ impl> Unit> { impl AbsDiffEq for Unit> where - N: Scalar + AbsDiffEq, + N: Scalar + Copy + AbsDiffEq, S: Storage, N::Epsilon: Copy, { @@ -1702,7 +1702,7 @@ where impl RelativeEq for Unit> where - N: Scalar + RelativeEq, + N: Scalar + Copy + RelativeEq, S: Storage, N::Epsilon: Copy, { @@ -1726,7 +1726,7 @@ where impl UlpsEq for Unit> where - N: Scalar + UlpsEq, + N: Scalar + Copy + UlpsEq, S: Storage, N::Epsilon: Copy, { @@ -1743,7 +1743,7 @@ where impl Hash for Matrix where - N: Scalar + Hash, + N: Scalar + Copy + Hash, R: Dim, C: Dim, S: Storage, diff --git a/src/base/matrix_alga.rs b/src/base/matrix_alga.rs index ac6aced7..330c5f94 100644 --- a/src/base/matrix_alga.rs +++ b/src/base/matrix_alga.rs @@ -25,7 +25,7 @@ use crate::base::{DefaultAllocator, MatrixMN, MatrixN, Scalar}; */ impl Identity for MatrixMN where - N: Scalar + Zero, + N: Scalar + Copy + Zero, DefaultAllocator: Allocator, { #[inline] @@ -36,7 +36,7 @@ where impl AbstractMagma for MatrixMN where - N: Scalar + ClosedAdd, + N: Scalar + Copy + ClosedAdd, DefaultAllocator: Allocator, { #[inline] @@ -47,7 +47,7 @@ where impl TwoSidedInverse for MatrixMN where - N: Scalar + ClosedNeg, + N: Scalar + Copy + ClosedNeg, DefaultAllocator: Allocator, { #[inline] @@ -64,7 +64,7 @@ where macro_rules! inherit_additive_structure( ($($marker: ident<$operator: ident> $(+ $bounds: ident)*),* $(,)*) => {$( impl $marker<$operator> for MatrixMN - where N: Scalar + $marker<$operator> $(+ $bounds)*, + where N: Scalar + Copy + $marker<$operator> $(+ $bounds)*, DefaultAllocator: Allocator { } )*} ); @@ -80,7 +80,7 @@ inherit_additive_structure!( impl AbstractModule for MatrixMN where - N: Scalar + RingCommutative, + N: Scalar + Copy + RingCommutative, DefaultAllocator: Allocator, { type AbstractRing = N; @@ -93,7 +93,7 @@ where impl Module for MatrixMN where - N: Scalar + RingCommutative, + N: Scalar + Copy + RingCommutative, DefaultAllocator: Allocator, { type Ring = N; @@ -101,7 +101,7 @@ where impl VectorSpace for MatrixMN where - N: Scalar + Field, + N: Scalar + Copy + Field, DefaultAllocator: Allocator, { type Field = N; @@ -109,7 +109,7 @@ where impl FiniteDimVectorSpace for MatrixMN where - N: Scalar + Field, + N: Scalar + Copy + Field, DefaultAllocator: Allocator, { #[inline] @@ -329,7 +329,7 @@ where DefaultAllocator: Allocator */ impl Identity for MatrixN where - N: Scalar + Zero + One, + N: Scalar + Copy + Zero + One, DefaultAllocator: Allocator, { #[inline] @@ -340,7 +340,7 @@ where impl AbstractMagma for MatrixN where - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, DefaultAllocator: Allocator, { #[inline] @@ -352,7 +352,7 @@ where macro_rules! impl_multiplicative_structure( ($($marker: ident<$operator: ident> $(+ $bounds: ident)*),* $(,)*) => {$( impl $marker<$operator> for MatrixN - where N: Scalar + Zero + One + ClosedAdd + ClosedMul + $marker<$operator> $(+ $bounds)*, + where N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul + $marker<$operator> $(+ $bounds)*, DefaultAllocator: Allocator { } )*} ); @@ -369,7 +369,7 @@ impl_multiplicative_structure!( */ impl MeetSemilattice for MatrixMN where - N: Scalar + MeetSemilattice, + N: Scalar + Copy + MeetSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -380,7 +380,7 @@ where impl JoinSemilattice for MatrixMN where - N: Scalar + JoinSemilattice, + N: Scalar + Copy + JoinSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -391,7 +391,7 @@ where impl Lattice for MatrixMN where - N: Scalar + Lattice, + N: Scalar + Copy + Lattice, DefaultAllocator: Allocator, { #[inline] diff --git a/src/base/matrix_slice.rs b/src/base/matrix_slice.rs index be53034a..43131680 100644 --- a/src/base/matrix_slice.rs +++ b/src/base/matrix_slice.rs @@ -13,22 +13,22 @@ macro_rules! slice_storage_impl( ($doc: expr; $Storage: ident as $SRef: ty; $T: ident.$get_addr: ident ($Ptr: ty as $Ref: ty)) => { #[doc = $doc] #[derive(Debug)] - pub struct $T<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> { + pub struct $T<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> { ptr: $Ptr, shape: (R, C), strides: (RStride, CStride), _phantoms: PhantomData<$Ref>, } - unsafe impl<'a, N: Scalar + Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send + unsafe impl<'a, N: Scalar + Copy + Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send for $T<'a, N, R, C, RStride, CStride> {} - unsafe impl<'a, N: Scalar + Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync + unsafe impl<'a, N: Scalar + Copy + Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync for $T<'a, N, R, C, RStride, CStride> {} - impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> $T<'a, N, R, C, RStride, CStride> { + impl<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> $T<'a, N, R, C, RStride, CStride> { /// Create a new matrix slice without bound checking and from a raw pointer. #[inline] pub unsafe fn from_raw_parts(ptr: $Ptr, @@ -48,7 +48,7 @@ macro_rules! slice_storage_impl( } // Dynamic is arbitrary. It's just to be able to call the constructors with `Slice::` - impl<'a, N: Scalar, R: Dim, C: Dim> $T<'a, N, R, C, Dynamic, Dynamic> { + impl<'a, N: Scalar + Copy, R: Dim, C: Dim> $T<'a, N, R, C, Dynamic, Dynamic> { /// Create a new matrix slice without bound checking. #[inline] pub unsafe fn new_unchecked(storage: $SRef, start: (usize, usize), shape: (R, C)) @@ -89,12 +89,12 @@ slice_storage_impl!("A mutable matrix data storage for mutable matrix slice. Onl StorageMut as &'a mut S; SliceStorageMut.get_address_unchecked_mut(*mut N as &'a mut N) ); -impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy for SliceStorage<'a, N, R, C, RStride, CStride> { } -impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone +impl<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone for SliceStorage<'a, N, R, C, RStride, CStride> { #[inline] @@ -110,7 +110,7 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone macro_rules! storage_impl( ($($T: ident),* $(,)*) => {$( - unsafe impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage + unsafe impl<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage for $T<'a, N, R, C, RStride, CStride> { type RStride = RStride; @@ -178,7 +178,7 @@ macro_rules! storage_impl( storage_impl!(SliceStorage, SliceStorageMut); -unsafe impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> StorageMut +unsafe impl<'a, N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, CStride: Dim> StorageMut for SliceStorageMut<'a, N, R, C, RStride, CStride> { #[inline] @@ -198,15 +198,15 @@ unsafe impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> StorageMu } } -unsafe impl<'a, N: Scalar, R: Dim, CStride: Dim> ContiguousStorage for SliceStorage<'a, N, R, U1, U1, CStride> { } -unsafe impl<'a, N: Scalar, R: Dim, CStride: Dim> ContiguousStorage for SliceStorageMut<'a, N, R, U1, U1, CStride> { } -unsafe impl<'a, N: Scalar, R: Dim, CStride: Dim> ContiguousStorageMut for SliceStorageMut<'a, N, R, U1, U1, CStride> { } +unsafe impl<'a, N: Scalar + Copy, R: Dim, CStride: Dim> ContiguousStorage for SliceStorage<'a, N, R, U1, U1, CStride> { } +unsafe impl<'a, N: Scalar + Copy, R: Dim, CStride: Dim> ContiguousStorage for SliceStorageMut<'a, N, R, U1, U1, CStride> { } +unsafe impl<'a, N: Scalar + Copy, R: Dim, CStride: Dim> ContiguousStorageMut for SliceStorageMut<'a, N, R, U1, U1, CStride> { } -unsafe impl<'a, N: Scalar, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorage for SliceStorage<'a, N, R, C, U1, R> { } -unsafe impl<'a, N: Scalar, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorage for SliceStorageMut<'a, N, R, C, U1, R> { } -unsafe impl<'a, N: Scalar, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorageMut for SliceStorageMut<'a, N, R, C, U1, R> { } +unsafe impl<'a, N: Scalar + Copy, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorage for SliceStorage<'a, N, R, C, U1, R> { } +unsafe impl<'a, N: Scalar + Copy, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorage for SliceStorageMut<'a, N, R, C, U1, R> { } +unsafe impl<'a, N: Scalar + Copy, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorageMut for SliceStorageMut<'a, N, R, C, U1, R> { } -impl> Matrix { +impl> Matrix { #[inline] fn assert_slice_index( &self, @@ -261,7 +261,7 @@ macro_rules! matrix_slice_impl( pub type $MatrixSlice<'a, N, R, C, RStride, CStride> = Matrix>; - impl> Matrix { + impl> Matrix { /* * * Row slicing. @@ -786,7 +786,7 @@ impl SliceRange for RangeFull { } } -impl> Matrix { +impl> Matrix { /// Slices a sub-matrix containing the rows indexed by the range `rows` and the columns indexed /// by the range `cols`. #[inline] @@ -827,7 +827,7 @@ impl> Matrix { } } -impl> Matrix { +impl> Matrix { /// Slices a mutable sub-matrix containing the rows indexed by the range `rows` and the columns /// indexed by the range `cols`. pub fn slice_range_mut( @@ -871,7 +871,7 @@ impl> Matrix { impl<'a, N, R, C, RStride, CStride> From> for MatrixSlice<'a, N, R, C, RStride, CStride> where - N: Scalar, + N: Scalar + Copy, R: Dim, C: Dim, RStride: Dim, diff --git a/src/base/ops.rs b/src/base/ops.rs index ef0014c5..77b35e94 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -20,7 +20,7 @@ use crate::base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, MatrixSum, Scalar * Indexing. * */ -impl> Index for Matrix { +impl> Index for Matrix { type Output = N; #[inline] @@ -32,7 +32,7 @@ impl> Index for Matrix Index<(usize, usize)> for Matrix where - N: Scalar, + N: Scalar + Copy, S: Storage, { type Output = N; @@ -50,7 +50,7 @@ where } // Mutable versions. -impl> IndexMut for Matrix { +impl> IndexMut for Matrix { #[inline] fn index_mut(&mut self, i: usize) -> &mut N { let ij = self.vector_to_matrix_index(i); @@ -60,7 +60,7 @@ impl> IndexMut for Matr impl IndexMut<(usize, usize)> for Matrix where - N: Scalar, + N: Scalar + Copy, S: StorageMut, { #[inline] @@ -82,7 +82,7 @@ where */ impl Neg for Matrix where - N: Scalar + ClosedNeg, + N: Scalar + Copy + ClosedNeg, S: Storage, DefaultAllocator: Allocator, { @@ -98,7 +98,7 @@ where impl<'a, N, R: Dim, C: Dim, S> Neg for &'a Matrix where - N: Scalar + ClosedNeg, + N: Scalar + Copy + ClosedNeg, S: Storage, DefaultAllocator: Allocator, { @@ -112,7 +112,7 @@ where impl Matrix where - N: Scalar + ClosedNeg, + N: Scalar + Copy + ClosedNeg, S: StorageMut, { /// Negates `self` in-place. @@ -137,7 +137,7 @@ macro_rules! componentwise_binop_impl( $method_to: ident, $method_to_statically_unchecked: ident) => { impl> Matrix - where N: Scalar + $bound { + where N: Scalar + Copy + $bound { /* * @@ -267,7 +267,7 @@ macro_rules! componentwise_binop_impl( impl<'b, N, R1, C1, R2, C2, SA, SB> $Trait<&'b Matrix> for Matrix where R1: Dim, C1: Dim, R2: Dim, C2: Dim, - N: Scalar + $bound, + N: Scalar + Copy + $bound, SA: Storage, SB: Storage, DefaultAllocator: SameShapeAllocator, @@ -285,7 +285,7 @@ macro_rules! componentwise_binop_impl( impl<'a, N, R1, C1, R2, C2, SA, SB> $Trait> for &'a Matrix where R1: Dim, C1: Dim, R2: Dim, C2: Dim, - N: Scalar + $bound, + N: Scalar + Copy + $bound, SA: Storage, SB: Storage, DefaultAllocator: SameShapeAllocator, @@ -303,7 +303,7 @@ macro_rules! componentwise_binop_impl( impl $Trait> for Matrix where R1: Dim, C1: Dim, R2: Dim, C2: Dim, - N: Scalar + $bound, + N: Scalar + Copy + $bound, SA: Storage, SB: Storage, DefaultAllocator: SameShapeAllocator, @@ -318,7 +318,7 @@ macro_rules! componentwise_binop_impl( impl<'a, 'b, N, R1, C1, R2, C2, SA, SB> $Trait<&'b Matrix> for &'a Matrix where R1: Dim, C1: Dim, R2: Dim, C2: Dim, - N: Scalar + $bound, + N: Scalar + Copy + $bound, SA: Storage, SB: Storage, DefaultAllocator: SameShapeAllocator, @@ -341,7 +341,7 @@ macro_rules! componentwise_binop_impl( impl<'b, N, R1, C1, R2, C2, SA, SB> $TraitAssign<&'b Matrix> for Matrix where R1: Dim, C1: Dim, R2: Dim, C2: Dim, - N: Scalar + $bound, + N: Scalar + Copy + $bound, SA: StorageMut, SB: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { @@ -354,7 +354,7 @@ macro_rules! componentwise_binop_impl( impl $TraitAssign> for Matrix where R1: Dim, C1: Dim, R2: Dim, C2: Dim, - N: Scalar + $bound, + N: Scalar + Copy + $bound, SA: StorageMut, SB: Storage, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { @@ -376,7 +376,7 @@ componentwise_binop_impl!(Sub, sub, ClosedSub; impl iter::Sum for MatrixMN where - N: Scalar + ClosedAdd + Zero, + N: Scalar + Copy + ClosedAdd + Zero, DefaultAllocator: Allocator, { fn sum>>(iter: I) -> MatrixMN { @@ -386,7 +386,7 @@ where impl iter::Sum for MatrixMN where - N: Scalar + ClosedAdd + Zero, + N: Scalar + Copy + ClosedAdd + Zero, DefaultAllocator: Allocator, { /// # Example @@ -416,7 +416,7 @@ where impl<'a, N, R: DimName, C: DimName> iter::Sum<&'a MatrixMN> for MatrixMN where - N: Scalar + ClosedAdd + Zero, + N: Scalar + Copy + ClosedAdd + Zero, DefaultAllocator: Allocator, { fn sum>>(iter: I) -> MatrixMN { @@ -426,7 +426,7 @@ where impl<'a, N, C: Dim> iter::Sum<&'a MatrixMN> for MatrixMN where - N: Scalar + ClosedAdd + Zero, + N: Scalar + Copy + ClosedAdd + Zero, DefaultAllocator: Allocator, { /// # Example @@ -466,7 +466,7 @@ macro_rules! componentwise_scalarop_impl( ($Trait: ident, $method: ident, $bound: ident; $TraitAssign: ident, $method_assign: ident) => { impl $Trait for Matrix - where N: Scalar + $bound, + where N: Scalar + Copy + $bound, S: Storage, DefaultAllocator: Allocator { type Output = MatrixMN; @@ -490,7 +490,7 @@ macro_rules! componentwise_scalarop_impl( } impl<'a, N, R: Dim, C: Dim, S> $Trait for &'a Matrix - where N: Scalar + $bound, + where N: Scalar + Copy + $bound, S: Storage, DefaultAllocator: Allocator { type Output = MatrixMN; @@ -502,7 +502,7 @@ macro_rules! componentwise_scalarop_impl( } impl $TraitAssign for Matrix - where N: Scalar + $bound, + where N: Scalar + Copy + $bound, S: StorageMut { #[inline] fn $method_assign(&mut self, rhs: N) { @@ -561,7 +561,7 @@ left_scalar_mul_impl!(u8, u16, u32, u64, usize, i8, i16, i32, i64, isize, f32, f impl<'a, 'b, N, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<&'b Matrix> for &'a Matrix where - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, SA: Storage, SB: Storage, DefaultAllocator: Allocator, @@ -582,7 +582,7 @@ where impl<'a, N, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul> for &'a Matrix where - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -599,7 +599,7 @@ where impl<'b, N, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<&'b Matrix> for Matrix where - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -616,7 +616,7 @@ where impl Mul> for Matrix where - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -638,7 +638,7 @@ where R1: Dim, C1: Dim, R2: Dim, - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: ContiguousStorageMut + Clone, ShapeConstraint: AreMultipliable, @@ -655,7 +655,7 @@ where R1: Dim, C1: Dim, R2: Dim, - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: ContiguousStorageMut + Clone, ShapeConstraint: AreMultipliable, @@ -671,7 +671,7 @@ where // Transpose-multiplication. impl Matrix where - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, SA: Storage, { /// Equivalent to `self.transpose() * rhs`. @@ -826,7 +826,7 @@ where } } -impl> Matrix { +impl> Matrix { /// Adds a scalar to `self`. #[inline] pub fn add_scalar(&self, rhs: N) -> MatrixMN @@ -848,7 +848,7 @@ impl> Matrix iter::Product for MatrixN where - N: Scalar + Zero + One + ClosedMul + ClosedAdd, + N: Scalar + Copy + Zero + One + ClosedMul + ClosedAdd, DefaultAllocator: Allocator, { fn product>>(iter: I) -> MatrixN { @@ -858,7 +858,7 @@ where impl<'a, N, D: DimName> iter::Product<&'a MatrixN> for MatrixN where - N: Scalar + Zero + One + ClosedMul + ClosedAdd, + N: Scalar + Copy + Zero + One + ClosedMul + ClosedAdd, DefaultAllocator: Allocator, { fn product>>(iter: I) -> MatrixN { @@ -866,7 +866,7 @@ where } } -impl> Matrix { +impl> Matrix { #[inline(always)] fn xcmp(&self, abs: impl Fn(N) -> N2, ordering: Ordering) -> N2 where N2: Scalar + PartialOrd + Zero { diff --git a/src/base/properties.rs b/src/base/properties.rs index 8ca49568..020e38d7 100644 --- a/src/base/properties.rs +++ b/src/base/properties.rs @@ -9,7 +9,7 @@ use crate::base::dimension::{Dim, DimMin}; use crate::base::storage::Storage; use crate::base::{DefaultAllocator, Matrix, Scalar, SquareMatrix}; -impl> Matrix { +impl> Matrix { /// Indicates if this is an empty matrix. #[inline] pub fn is_empty(&self) -> bool { diff --git a/src/base/scalar.rs b/src/base/scalar.rs index 47e3019c..a6c837ff 100644 --- a/src/base/scalar.rs +++ b/src/base/scalar.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; /// The basic scalar type for all structures of `nalgebra`. /// /// This does not make any assumption on the algebraic properties of `Self`. -pub trait Scalar: Copy + PartialEq + Debug + Any { +pub trait Scalar: PartialEq + Debug + Any { #[inline] /// Tests if `Self` the same as the type `T` /// diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 0fe18130..d71697d7 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -3,7 +3,7 @@ use alga::general::{Field, SupersetOf}; use crate::storage::Storage; use crate::allocator::Allocator; -impl> Matrix { +impl> Matrix { /// Returns a row vector where each element is the result of the application of `f` on the /// corresponding column of the original matrix. #[inline] @@ -54,7 +54,7 @@ impl> Matrix { } } -impl, R: Dim, C: Dim, S: Storage> Matrix { +impl, R: Dim, C: Dim, S: Storage> Matrix { /* * * Sum computation. diff --git a/src/base/storage.rs b/src/base/storage.rs index 02941e47..f4d8551e 100644 --- a/src/base/storage.rs +++ b/src/base/storage.rs @@ -36,7 +36,7 @@ pub type CStride = /// should **not** allow the user to modify the size of the underlying buffer with safe methods /// (for example the `VecStorage::data_mut` method is unsafe because the user could change the /// vector's size so that it no longer contains enough elements: this will lead to UB. -pub unsafe trait Storage: Debug + Sized { +pub unsafe trait Storage: Debug + Sized { /// The static stride of this storage's rows. type RStride: Dim; @@ -117,7 +117,7 @@ pub unsafe trait Storage: Debug + Sized { /// Note that a mutable access does not mean that the matrix owns its data. For example, a mutable /// matrix slice can provide mutable access to its elements even if it does not own its data (it /// contains only an internal reference to them). -pub unsafe trait StorageMut: Storage { +pub unsafe trait StorageMut: Storage { /// The matrix mutable data pointer. fn ptr_mut(&mut self) -> *mut N; @@ -175,7 +175,7 @@ pub unsafe trait StorageMut: Storage { /// The storage requirement means that for any value of `i` in `[0, nrows * ncols[`, the value /// `.get_unchecked_linear` returns one of the matrix component. This trait is unsafe because /// failing to comply to this may cause Undefined Behaviors. -pub unsafe trait ContiguousStorage: +pub unsafe trait ContiguousStorage: Storage { } @@ -185,7 +185,7 @@ pub unsafe trait ContiguousStorage: /// The storage requirement means that for any value of `i` in `[0, nrows * ncols[`, the value /// `.get_unchecked_linear` returns one of the matrix component. This trait is unsafe because /// failing to comply to this may cause Undefined Behaviors. -pub unsafe trait ContiguousStorageMut: +pub unsafe trait ContiguousStorageMut: ContiguousStorage + StorageMut { } diff --git a/src/base/swizzle.rs b/src/base/swizzle.rs index 4c9b0b63..4508c758 100644 --- a/src/base/swizzle.rs +++ b/src/base/swizzle.rs @@ -5,7 +5,7 @@ use typenum::{self, Cmp, Greater}; macro_rules! impl_swizzle { ($( where $BaseDim: ident: $( $name: ident() -> $Result: ident[$($i: expr),+] ),+ ;)* ) => { $( - impl> Vector + impl> Vector where D::Value: Cmp { $( diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index 2b4bf743..a0230488 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -102,7 +102,7 @@ impl Into> for VecStorage * Dynamic − Dynamic * */ -unsafe impl Storage for VecStorage +unsafe impl Storage for VecStorage where DefaultAllocator: Allocator { type RStride = U1; @@ -146,7 +146,7 @@ where DefaultAllocator: Allocator } } -unsafe impl Storage for VecStorage +unsafe impl Storage for VecStorage where DefaultAllocator: Allocator { type RStride = U1; @@ -195,7 +195,7 @@ where DefaultAllocator: Allocator * StorageMut, ContiguousStorage. * */ -unsafe impl StorageMut for VecStorage +unsafe impl StorageMut for VecStorage where DefaultAllocator: Allocator { #[inline] @@ -209,13 +209,13 @@ where DefaultAllocator: Allocator } } -unsafe impl ContiguousStorage for VecStorage where DefaultAllocator: Allocator +unsafe impl ContiguousStorage for VecStorage where DefaultAllocator: Allocator {} -unsafe impl ContiguousStorageMut for VecStorage where DefaultAllocator: Allocator +unsafe impl ContiguousStorageMut for VecStorage where DefaultAllocator: Allocator {} -unsafe impl StorageMut for VecStorage +unsafe impl StorageMut for VecStorage where DefaultAllocator: Allocator { #[inline] @@ -244,10 +244,10 @@ impl Abomonation for VecStorage { } } -unsafe impl ContiguousStorage for VecStorage where DefaultAllocator: Allocator +unsafe impl ContiguousStorage for VecStorage where DefaultAllocator: Allocator {} -unsafe impl ContiguousStorageMut for VecStorage where DefaultAllocator: Allocator +unsafe impl ContiguousStorageMut for VecStorage where DefaultAllocator: Allocator {} impl Extend for VecStorage @@ -270,7 +270,7 @@ impl Extend for VecStorage impl Extend> for VecStorage where - N: Scalar, + N: Scalar + Copy, R: Dim, RV: Dim, SV: Storage, diff --git a/src/debug/random_orthogonal.rs b/src/debug/random_orthogonal.rs index 421b041a..8a3e6486 100644 --- a/src/debug/random_orthogonal.rs +++ b/src/debug/random_orthogonal.rs @@ -12,7 +12,7 @@ use crate::linalg::givens::GivensRotation; /// A random orthogonal matrix. #[derive(Clone, Debug)] -pub struct RandomOrthogonal +pub struct RandomOrthogonal where DefaultAllocator: Allocator { m: MatrixN, diff --git a/src/debug/random_sdp.rs b/src/debug/random_sdp.rs index 47e3ca60..5875faf6 100644 --- a/src/debug/random_sdp.rs +++ b/src/debug/random_sdp.rs @@ -13,7 +13,7 @@ use crate::debug::RandomOrthogonal; /// A random, well-conditioned, symmetric definite-positive matrix. #[derive(Clone, Debug)] -pub struct RandomSDP +pub struct RandomSDP where DefaultAllocator: Allocator { m: MatrixN, diff --git a/src/geometry/op_macros.rs b/src/geometry/op_macros.rs index 873c6d7d..7ee81f07 100644 --- a/src/geometry/op_macros.rs +++ b/src/geometry/op_macros.rs @@ -18,7 +18,7 @@ macro_rules! md_impl( // Lifetime. $($lives: tt),*) => { impl<$($lives ,)* N $(, $Dims: $DimsBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs - where N: Scalar + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, + where N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, DefaultAllocator: Allocator + Allocator + Allocator, @@ -96,7 +96,7 @@ macro_rules! md_assign_impl( // Actual implementation and lifetimes. $action: expr; $($lives: tt),*) => { impl<$($lives ,)* N $(, $Dims: $DimsBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs - where N: Scalar + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, + where N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, DefaultAllocator: Allocator + Allocator, $( $ConstraintType: $ConstraintBound $(<$( $ConstraintBoundParams $( = $EqBound )*),*>)* ),* @@ -148,7 +148,7 @@ macro_rules! add_sub_impl( $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty, Output = $Result: ty; $action: expr; $($lives: tt),*) => { impl<$($lives ,)* N $(, $Dims: $DimsBound $(<$($BoundParam),*>)*)*> $Op<$Rhs> for $Lhs - where N: Scalar + $bound, + where N: Scalar + Copy + $bound, DefaultAllocator: Allocator + Allocator + SameShapeAllocator, @@ -172,7 +172,7 @@ macro_rules! add_sub_assign_impl( $lhs: ident: $Lhs: ty, $rhs: ident: $Rhs: ty; $action: expr; $($lives: tt),*) => { impl<$($lives ,)* N $(, $Dims: $DimsBound)*> $Op<$Rhs> for $Lhs - where N: Scalar + $bound, + where N: Scalar + Copy + $bound, DefaultAllocator: Allocator + Allocator, ShapeConstraint: SameNumberOfRows<$R1, $R2> + SameNumberOfColumns<$C1, $C2> { diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index 8020c0cf..923da505 100644 --- a/src/geometry/perspective.rs +++ b/src/geometry/perspective.rs @@ -18,7 +18,7 @@ use crate::base::{Matrix4, Scalar, Vector, Vector3}; use crate::geometry::{Point3, Projective3}; /// A 3D perspective projection stored as an homogeneous 4x4 matrix. -pub struct Perspective3 { +pub struct Perspective3 { matrix: Matrix4, } diff --git a/src/geometry/point.rs b/src/geometry/point.rs index 04338d2a..48031ba9 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -20,14 +20,14 @@ use crate::base::{DefaultAllocator, Scalar, VectorN}; /// A point in a n-dimensional euclidean space. #[repr(C)] #[derive(Debug, Clone)] -pub struct Point +pub struct Point where DefaultAllocator: Allocator { /// The coordinates of this point, i.e., the shift from the origin. pub coords: VectorN, } -impl hash::Hash for Point +impl hash::Hash for Point where DefaultAllocator: Allocator, >::Buffer: hash::Hash, @@ -37,7 +37,7 @@ where } } -impl Copy for Point +impl Copy for Point where DefaultAllocator: Allocator, >::Buffer: Copy, @@ -45,7 +45,7 @@ where } #[cfg(feature = "serde-serialize")] -impl Serialize for Point +impl Serialize for Point where DefaultAllocator: Allocator, >::Buffer: Serialize, @@ -57,7 +57,7 @@ where } #[cfg(feature = "serde-serialize")] -impl<'a, N: Scalar, D: DimName> Deserialize<'a> for Point +impl<'a, N: Scalar + Copy, D: DimName> Deserialize<'a> for Point where DefaultAllocator: Allocator, >::Buffer: Deserialize<'a>, @@ -73,7 +73,7 @@ where #[cfg(feature = "abomonation-serialize")] impl Abomonation for Point where - N: Scalar, + N: Scalar + Copy, D: DimName, VectorN: Abomonation, DefaultAllocator: Allocator, @@ -91,7 +91,7 @@ where } } -impl Point +impl Point where DefaultAllocator: Allocator { /// Converts this point into a vector in homogeneous coordinates, i.e., appends a `1` at the @@ -210,7 +210,7 @@ where DefaultAllocator: Allocator } } -impl AbsDiffEq for Point +impl AbsDiffEq for Point where DefaultAllocator: Allocator, N::Epsilon: Copy, @@ -228,7 +228,7 @@ where } } -impl RelativeEq for Point +impl RelativeEq for Point where DefaultAllocator: Allocator, N::Epsilon: Copy, @@ -251,7 +251,7 @@ where } } -impl UlpsEq for Point +impl UlpsEq for Point where DefaultAllocator: Allocator, N::Epsilon: Copy, @@ -267,9 +267,9 @@ where } } -impl Eq for Point where DefaultAllocator: Allocator {} +impl Eq for Point where DefaultAllocator: Allocator {} -impl PartialEq for Point +impl PartialEq for Point where DefaultAllocator: Allocator { #[inline] @@ -278,7 +278,7 @@ where DefaultAllocator: Allocator } } -impl PartialOrd for Point +impl PartialOrd for Point where DefaultAllocator: Allocator { #[inline] @@ -312,7 +312,7 @@ where DefaultAllocator: Allocator * Display * */ -impl fmt::Display for Point +impl fmt::Display for Point where DefaultAllocator: Allocator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/geometry/point_alga.rs b/src/geometry/point_alga.rs index 162e6c68..0deb52d3 100644 --- a/src/geometry/point_alga.rs +++ b/src/geometry/point_alga.rs @@ -7,9 +7,9 @@ use crate::base::{DefaultAllocator, Scalar, VectorN}; use crate::geometry::Point; -impl AffineSpace for Point +impl AffineSpace for Point where - N: Scalar + Field, + N: Scalar + Copy + Field, DefaultAllocator: Allocator, { type Translation = VectorN; @@ -49,7 +49,7 @@ where DefaultAllocator: Allocator */ impl MeetSemilattice for Point where - N: Scalar + MeetSemilattice, + N: Scalar + Copy + MeetSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -60,7 +60,7 @@ where impl JoinSemilattice for Point where - N: Scalar + JoinSemilattice, + N: Scalar + Copy + JoinSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -71,7 +71,7 @@ where impl Lattice for Point where - N: Scalar + Lattice, + N: Scalar + Copy + Lattice, DefaultAllocator: Allocator, { #[inline] diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 2fac11d4..47d0e7e8 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -12,7 +12,7 @@ use crate::base::{DefaultAllocator, Scalar, VectorN}; use crate::geometry::Point; -impl Point +impl Point where DefaultAllocator: Allocator { /// Creates a new point with uninitialized coordinates. @@ -94,7 +94,7 @@ where DefaultAllocator: Allocator #[inline] pub fn from_homogeneous(v: VectorN>) -> Option where - N: Scalar + Zero + One + ClosedDiv, + N: Scalar + Copy + Zero + One + ClosedDiv, D: DimNameAdd, DefaultAllocator: Allocator>, { @@ -112,7 +112,7 @@ where DefaultAllocator: Allocator * Traits that build points. * */ -impl Bounded for Point +impl Bounded for Point where DefaultAllocator: Allocator { #[inline] @@ -126,7 +126,7 @@ where DefaultAllocator: Allocator } } -impl Distribution> for Standard +impl Distribution> for Standard where DefaultAllocator: Allocator, Standard: Distribution, @@ -156,7 +156,7 @@ where */ macro_rules! componentwise_constructors_impl( ($($doc: expr; $D: ty, $($args: ident:$irow: expr),*);* $(;)*) => {$( - impl Point + impl Point where DefaultAllocator: Allocator { #[doc = "Initializes this point from its components."] #[doc = "# Example\n```"] @@ -192,7 +192,7 @@ componentwise_constructors_impl!( macro_rules! from_array_impl( ($($D: ty, $len: expr);*) => {$( - impl From<[N; $len]> for Point { + impl From<[N; $len]> for Point { fn from (coords: [N; $len]) -> Self { Self { coords: coords.into() diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index 10438165..b3131f52 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -27,8 +27,8 @@ use std::convert::{AsMut, AsRef, From, Into}; impl SubsetOf> for Point where D: DimName, - N1: Scalar, - N2: Scalar + SupersetOf, + N1: Scalar + Copy, + N2: Scalar + Copy + SupersetOf, DefaultAllocator: Allocator + Allocator, { #[inline] @@ -52,8 +52,8 @@ where impl SubsetOf>> for Point where D: DimNameAdd, - N1: Scalar, - N2: Scalar + Zero + One + ClosedDiv + SupersetOf, + N1: Scalar + Copy, + N2: Scalar + Copy + Zero + One + ClosedDiv + SupersetOf, DefaultAllocator: Allocator + Allocator> + Allocator> @@ -83,7 +83,7 @@ where macro_rules! impl_from_into_mint_1D( ($($NRows: ident => $PT:ident, $VT:ident [$SZ: expr]);* $(;)*) => {$( impl From> for Point - where N: Scalar { + where N: Scalar + Copy { #[inline] fn from(p: mint::$PT) -> Self { Self { @@ -93,7 +93,7 @@ macro_rules! impl_from_into_mint_1D( } impl Into> for Point - where N: Scalar { + where N: Scalar + Copy { #[inline] fn into(self) -> mint::$PT { let mint_vec: mint::$VT = self.coords.into(); @@ -102,7 +102,7 @@ macro_rules! impl_from_into_mint_1D( } impl AsRef> for Point - where N: Scalar { + where N: Scalar + Copy { #[inline] fn as_ref(&self) -> &mint::$PT { unsafe { @@ -112,7 +112,7 @@ macro_rules! impl_from_into_mint_1D( } impl AsMut> for Point - where N: Scalar { + where N: Scalar + Copy { #[inline] fn as_mut(&mut self) -> &mut mint::$PT { unsafe { @@ -130,7 +130,7 @@ impl_from_into_mint_1D!( U3 => Point3, Vector3[3]; ); -impl From> for VectorN> +impl From> for VectorN> where D: DimNameAdd, DefaultAllocator: Allocator + Allocator>, @@ -141,7 +141,7 @@ where } } -impl From> for Point +impl From> for Point where DefaultAllocator: Allocator, { diff --git a/src/geometry/point_coordinates.rs b/src/geometry/point_coordinates.rs index b56e120e..1b6edf67 100644 --- a/src/geometry/point_coordinates.rs +++ b/src/geometry/point_coordinates.rs @@ -16,7 +16,7 @@ use crate::geometry::Point; macro_rules! deref_impl( ($D: ty, $Target: ident $(, $comps: ident)*) => { - impl Deref for Point + impl Deref for Point where DefaultAllocator: Allocator { type Target = $Target; @@ -26,7 +26,7 @@ macro_rules! deref_impl( } } - impl DerefMut for Point + impl DerefMut for Point where DefaultAllocator: Allocator { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { diff --git a/src/geometry/point_ops.rs b/src/geometry/point_ops.rs index b49495f8..2a4fae03 100644 --- a/src/geometry/point_ops.rs +++ b/src/geometry/point_ops.rs @@ -18,7 +18,7 @@ use crate::geometry::Point; * Indexing. * */ -impl Index for Point +impl Index for Point where DefaultAllocator: Allocator { type Output = N; @@ -29,7 +29,7 @@ where DefaultAllocator: Allocator } } -impl IndexMut for Point +impl IndexMut for Point where DefaultAllocator: Allocator { #[inline] @@ -43,7 +43,7 @@ where DefaultAllocator: Allocator * Neg. * */ -impl Neg for Point +impl Neg for Point where DefaultAllocator: Allocator { type Output = Self; @@ -54,7 +54,7 @@ where DefaultAllocator: Allocator } } -impl<'a, N: Scalar + ClosedNeg, D: DimName> Neg for &'a Point +impl<'a, N: Scalar + Copy + ClosedNeg, D: DimName> Neg for &'a Point where DefaultAllocator: Allocator { type Output = Point; @@ -138,7 +138,7 @@ add_sub_impl!(Add, add, ClosedAdd; macro_rules! op_assign_impl( ($($TraitAssign: ident, $method_assign: ident, $bound: ident);* $(;)*) => {$( impl<'b, N, D1: DimName, D2: Dim, SB> $TraitAssign<&'b Vector> for Point - where N: Scalar + $bound, + where N: Scalar + Copy + $bound, SB: Storage, DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows { @@ -150,7 +150,7 @@ macro_rules! op_assign_impl( } impl $TraitAssign> for Point - where N: Scalar + $bound, + where N: Scalar + Copy + $bound, SB: Storage, DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows { @@ -192,7 +192,7 @@ md_impl_all!( macro_rules! componentwise_scalarop_impl( ($Trait: ident, $method: ident, $bound: ident; $TraitAssign: ident, $method_assign: ident) => { - impl $Trait for Point + impl $Trait for Point where DefaultAllocator: Allocator { type Output = Point; @@ -202,7 +202,7 @@ macro_rules! componentwise_scalarop_impl( } } - impl<'a, N: Scalar + $bound, D: DimName> $Trait for &'a Point + impl<'a, N: Scalar + Copy + $bound, D: DimName> $Trait for &'a Point where DefaultAllocator: Allocator { type Output = Point; @@ -212,7 +212,7 @@ macro_rules! componentwise_scalarop_impl( } } - impl $TraitAssign for Point + impl $TraitAssign for Point where DefaultAllocator: Allocator { #[inline] fn $method_assign(&mut self, right: N) { diff --git a/src/geometry/reflection.rs b/src/geometry/reflection.rs index b4658a11..9b4da872 100644 --- a/src/geometry/reflection.rs +++ b/src/geometry/reflection.rs @@ -8,7 +8,7 @@ use crate::storage::{Storage, StorageMut}; use crate::geometry::Point; /// A reflection wrt. a plane. -pub struct Reflection> { +pub struct Reflection> { axis: Vector, bias: N, } diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index ec9c8150..0081262b 100755 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -24,13 +24,13 @@ use crate::geometry::Point; /// A rotation matrix. #[repr(C)] #[derive(Debug)] -pub struct Rotation +pub struct Rotation where DefaultAllocator: Allocator { matrix: MatrixN, } -impl hash::Hash for Rotation +impl hash::Hash for Rotation where DefaultAllocator: Allocator, >::Buffer: hash::Hash, @@ -40,14 +40,14 @@ where } } -impl Copy for Rotation +impl Copy for Rotation where DefaultAllocator: Allocator, >::Buffer: Copy, { } -impl Clone for Rotation +impl Clone for Rotation where DefaultAllocator: Allocator, >::Buffer: Clone, @@ -61,7 +61,7 @@ where #[cfg(feature = "abomonation-serialize")] impl Abomonation for Rotation where - N: Scalar, + N: Scalar + Copy, D: DimName, MatrixN: Abomonation, DefaultAllocator: Allocator, @@ -80,7 +80,7 @@ where } #[cfg(feature = "serde-serialize")] -impl Serialize for Rotation +impl Serialize for Rotation where DefaultAllocator: Allocator, Owned: Serialize, @@ -92,7 +92,7 @@ where } #[cfg(feature = "serde-serialize")] -impl<'a, N: Scalar, D: DimName> Deserialize<'a> for Rotation +impl<'a, N: Scalar + Copy, D: DimName> Deserialize<'a> for Rotation where DefaultAllocator: Allocator, Owned: Deserialize<'a>, @@ -105,7 +105,7 @@ where } } -impl Rotation +impl Rotation where DefaultAllocator: Allocator { /// A reference to the underlying matrix representation of this rotation. @@ -432,9 +432,9 @@ where DefaultAllocator: Allocator + Allocator } } -impl Eq for Rotation where DefaultAllocator: Allocator {} +impl Eq for Rotation where DefaultAllocator: Allocator {} -impl PartialEq for Rotation +impl PartialEq for Rotation where DefaultAllocator: Allocator { #[inline] @@ -445,7 +445,7 @@ where DefaultAllocator: Allocator impl AbsDiffEq for Rotation where - N: Scalar + AbsDiffEq, + N: Scalar + Copy + AbsDiffEq, DefaultAllocator: Allocator, N::Epsilon: Copy, { @@ -464,7 +464,7 @@ where impl RelativeEq for Rotation where - N: Scalar + RelativeEq, + N: Scalar + Copy + RelativeEq, DefaultAllocator: Allocator, N::Epsilon: Copy, { @@ -488,7 +488,7 @@ where impl UlpsEq for Rotation where - N: Scalar + UlpsEq, + N: Scalar + Copy + UlpsEq, DefaultAllocator: Allocator, N::Epsilon: Copy, { diff --git a/src/geometry/rotation_construction.rs b/src/geometry/rotation_construction.rs index a7779cc6..3e9b2930 100644 --- a/src/geometry/rotation_construction.rs +++ b/src/geometry/rotation_construction.rs @@ -10,7 +10,7 @@ use crate::geometry::Rotation; impl Rotation where - N: Scalar + Zero + One, + N: Scalar + Copy + Zero + One, DefaultAllocator: Allocator, { /// Creates a new square identity rotation of the given `dimension`. @@ -32,7 +32,7 @@ where impl One for Rotation where - N: Scalar + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Copy + Zero + One + ClosedAdd + ClosedMul, DefaultAllocator: Allocator, { #[inline] diff --git a/src/geometry/rotation_ops.rs b/src/geometry/rotation_ops.rs index ed555b6b..8b0810a1 100644 --- a/src/geometry/rotation_ops.rs +++ b/src/geometry/rotation_ops.rs @@ -30,7 +30,7 @@ use crate::base::{DefaultAllocator, Matrix, MatrixMN, Scalar, Unit, Vector, Vect use crate::geometry::{Point, Rotation}; -impl Index<(usize, usize)> for Rotation +impl Index<(usize, usize)> for Rotation where DefaultAllocator: Allocator { type Output = N; diff --git a/src/geometry/swizzle.rs b/src/geometry/swizzle.rs index d5740016..fdcb4743 100644 --- a/src/geometry/swizzle.rs +++ b/src/geometry/swizzle.rs @@ -6,7 +6,7 @@ use typenum::{self, Cmp, Greater}; macro_rules! impl_swizzle { ($( where $BaseDim: ident: $( $name: ident() -> $Result: ident[$($i: expr),+] ),+ ;)* ) => { $( - impl Point + impl Point where DefaultAllocator: Allocator, D::Value: Cmp diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index e64b3d2e..0e9b37fc 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -23,7 +23,7 @@ use crate::geometry::Point; /// A translation. #[repr(C)] #[derive(Debug)] -pub struct Translation +pub struct Translation where DefaultAllocator: Allocator { /// The translation coordinates, i.e., how much is added to a point's coordinates when it is @@ -31,7 +31,7 @@ where DefaultAllocator: Allocator pub vector: VectorN, } -impl hash::Hash for Translation +impl hash::Hash for Translation where DefaultAllocator: Allocator, Owned: hash::Hash, @@ -41,13 +41,13 @@ where } } -impl Copy for Translation +impl Copy for Translation where DefaultAllocator: Allocator, Owned: Copy, {} -impl Clone for Translation +impl Clone for Translation where DefaultAllocator: Allocator, Owned: Clone, @@ -61,7 +61,7 @@ where #[cfg(feature = "abomonation-serialize")] impl Abomonation for Translation where - N: Scalar, + N: Scalar + Copy, D: DimName, VectorN: Abomonation, DefaultAllocator: Allocator, @@ -80,7 +80,7 @@ where } #[cfg(feature = "serde-serialize")] -impl Serialize for Translation +impl Serialize for Translation where DefaultAllocator: Allocator, Owned: Serialize, @@ -92,7 +92,7 @@ where } #[cfg(feature = "serde-serialize")] -impl<'a, N: Scalar, D: DimName> Deserialize<'a> for Translation +impl<'a, N: Scalar + Copy, D: DimName> Deserialize<'a> for Translation where DefaultAllocator: Allocator, Owned: Deserialize<'a>, @@ -105,7 +105,7 @@ where } } -impl Translation +impl Translation where DefaultAllocator: Allocator { /// Creates a new translation from the given vector. @@ -192,7 +192,7 @@ where DefaultAllocator: Allocator } } -impl Translation +impl Translation where DefaultAllocator: Allocator { /// Translate the given point. @@ -211,7 +211,7 @@ where DefaultAllocator: Allocator } } -impl Translation +impl Translation where DefaultAllocator: Allocator { /// Translate the given point by the inverse of this translation. @@ -228,9 +228,9 @@ where DefaultAllocator: Allocator } } -impl Eq for Translation where DefaultAllocator: Allocator {} +impl Eq for Translation where DefaultAllocator: Allocator {} -impl PartialEq for Translation +impl PartialEq for Translation where DefaultAllocator: Allocator { #[inline] @@ -239,7 +239,7 @@ where DefaultAllocator: Allocator } } -impl AbsDiffEq for Translation +impl AbsDiffEq for Translation where DefaultAllocator: Allocator, N::Epsilon: Copy, @@ -257,7 +257,7 @@ where } } -impl RelativeEq for Translation +impl RelativeEq for Translation where DefaultAllocator: Allocator, N::Epsilon: Copy, @@ -280,7 +280,7 @@ where } } -impl UlpsEq for Translation +impl UlpsEq for Translation where DefaultAllocator: Allocator, N::Epsilon: Copy, diff --git a/src/geometry/translation_construction.rs b/src/geometry/translation_construction.rs index 339bdd2a..266b4b3b 100644 --- a/src/geometry/translation_construction.rs +++ b/src/geometry/translation_construction.rs @@ -15,7 +15,7 @@ use crate::base::{DefaultAllocator, Scalar, VectorN}; use crate::geometry::Translation; -impl Translation +impl Translation where DefaultAllocator: Allocator { /// Creates a new identity translation. @@ -38,7 +38,7 @@ where DefaultAllocator: Allocator } } -impl One for Translation +impl One for Translation where DefaultAllocator: Allocator { #[inline] @@ -47,7 +47,7 @@ where DefaultAllocator: Allocator } } -impl Distribution> for Standard +impl Distribution> for Standard where DefaultAllocator: Allocator, Standard: Distribution, @@ -78,7 +78,7 @@ where */ macro_rules! componentwise_constructors_impl( ($($doc: expr; $D: ty, $($args: ident:$irow: expr),*);* $(;)*) => {$( - impl Translation + impl Translation where DefaultAllocator: Allocator { #[doc = "Initializes this translation from its components."] #[doc = "# Example\n```"] diff --git a/src/geometry/translation_conversion.rs b/src/geometry/translation_conversion.rs index b44412e6..2a6d9535 100644 --- a/src/geometry/translation_conversion.rs +++ b/src/geometry/translation_conversion.rs @@ -22,8 +22,8 @@ use crate::geometry::{Isometry, Point, Similarity, SuperTCategoryOf, TAffine, Tr impl SubsetOf> for Translation where - N1: Scalar, - N2: Scalar + SupersetOf, + N1: Scalar + Copy, + N2: Scalar + Copy + SupersetOf, DefaultAllocator: Allocator + Allocator, { #[inline] @@ -153,7 +153,7 @@ where } } -impl From> for MatrixN> +impl From> for MatrixN> where D: DimNameAdd, DefaultAllocator: Allocator + Allocator, DimNameSum>, @@ -164,7 +164,7 @@ where } } -impl From> for Translation +impl From> for Translation where DefaultAllocator: Allocator { #[inline] diff --git a/src/geometry/translation_coordinates.rs b/src/geometry/translation_coordinates.rs index c422415c..97eb5b32 100644 --- a/src/geometry/translation_coordinates.rs +++ b/src/geometry/translation_coordinates.rs @@ -16,7 +16,7 @@ use crate::geometry::Translation; macro_rules! deref_impl( ($D: ty, $Target: ident $(, $comps: ident)*) => { - impl Deref for Translation + impl Deref for Translation where DefaultAllocator: Allocator { type Target = $Target; @@ -26,7 +26,7 @@ macro_rules! deref_impl( } } - impl DerefMut for Translation + impl DerefMut for Translation where DefaultAllocator: Allocator { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { diff --git a/src/linalg/lu.rs b/src/linalg/lu.rs index 2c3beee3..9676cd83 100644 --- a/src/linalg/lu.rs +++ b/src/linalg/lu.rs @@ -318,7 +318,7 @@ where DefaultAllocator: Allocator + Allocator<(usize, usize), D> /// element `matrix[(i, i)]` is provided as argument. pub fn gauss_step(matrix: &mut Matrix, diag: N, i: usize) where - N: Scalar + Field, + N: Scalar + Copy + Field, S: StorageMut, { let mut submat = matrix.slice_range_mut(i.., i..); @@ -346,7 +346,7 @@ pub fn gauss_step_swap( i: usize, piv: usize, ) where - N: Scalar + Field, + N: Scalar + Copy + Field, S: StorageMut, { let piv = piv - i; diff --git a/src/linalg/permutation_sequence.rs b/src/linalg/permutation_sequence.rs index ce493905..c7fb9b2b 100644 --- a/src/linalg/permutation_sequence.rs +++ b/src/linalg/permutation_sequence.rs @@ -92,7 +92,7 @@ where DefaultAllocator: Allocator<(usize, usize), D> /// Applies this sequence of permutations to the rows of `rhs`. #[inline] - pub fn permute_rows(&self, rhs: &mut Matrix) + pub fn permute_rows(&self, rhs: &mut Matrix) where S2: StorageMut { for i in self.ipiv.rows_range(..self.len).iter() { rhs.swap_rows(i.0, i.1) @@ -101,7 +101,7 @@ where DefaultAllocator: Allocator<(usize, usize), D> /// Applies this sequence of permutations in reverse to the rows of `rhs`. #[inline] - pub fn inv_permute_rows( + pub fn inv_permute_rows( &self, rhs: &mut Matrix, ) where @@ -115,7 +115,7 @@ where DefaultAllocator: Allocator<(usize, usize), D> /// Applies this sequence of permutations to the columns of `rhs`. #[inline] - pub fn permute_columns( + pub fn permute_columns( &self, rhs: &mut Matrix, ) where @@ -128,7 +128,7 @@ where DefaultAllocator: Allocator<(usize, usize), D> /// Applies this sequence of permutations in reverse to the columns of `rhs`. #[inline] - pub fn inv_permute_columns( + pub fn inv_permute_columns( &self, rhs: &mut Matrix, ) where diff --git a/src/sparse/cs_matrix.rs b/src/sparse/cs_matrix.rs index 2fc571c7..e8c259a2 100644 --- a/src/sparse/cs_matrix.rs +++ b/src/sparse/cs_matrix.rs @@ -105,7 +105,7 @@ pub trait CsStorageMut: /// A storage of column-compressed sparse matrix based on a Vec. #[derive(Clone, Debug, PartialEq)] -pub struct CsVecStorage +pub struct CsVecStorage where DefaultAllocator: Allocator { pub(crate) shape: (R, C), @@ -114,7 +114,7 @@ where DefaultAllocator: Allocator pub(crate) vals: Vec, } -impl CsVecStorage +impl CsVecStorage where DefaultAllocator: Allocator { /// The value buffer of this storage. @@ -133,9 +133,9 @@ where DefaultAllocator: Allocator } } -impl CsVecStorage where DefaultAllocator: Allocator {} +impl CsVecStorage where DefaultAllocator: Allocator {} -impl<'a, N: Scalar, R: Dim, C: Dim> CsStorageIter<'a, N, R, C> for CsVecStorage +impl<'a, N: Scalar + Copy, R: Dim, C: Dim> CsStorageIter<'a, N, R, C> for CsVecStorage where DefaultAllocator: Allocator { type ColumnEntries = ColumnEntries<'a, N>; @@ -154,7 +154,7 @@ where DefaultAllocator: Allocator } } -impl CsStorage for CsVecStorage +impl CsStorage for CsVecStorage where DefaultAllocator: Allocator { #[inline] @@ -199,7 +199,7 @@ where DefaultAllocator: Allocator } } -impl<'a, N: Scalar, R: Dim, C: Dim> CsStorageIterMut<'a, N, R, C> for CsVecStorage +impl<'a, N: Scalar + Copy, R: Dim, C: Dim> CsStorageIterMut<'a, N, R, C> for CsVecStorage where DefaultAllocator: Allocator { type ValuesMut = slice::IterMut<'a, N>; @@ -220,11 +220,11 @@ where DefaultAllocator: Allocator } } -impl CsStorageMut for CsVecStorage where DefaultAllocator: Allocator +impl CsStorageMut for CsVecStorage where DefaultAllocator: Allocator {} /* -pub struct CsSliceStorage<'a, N: Scalar, R: Dim, C: DimAdd> { +pub struct CsSliceStorage<'a, N: Scalar + Copy, R: Dim, C: DimAdd> { shape: (R, C), p: VectorSlice>, i: VectorSlice, @@ -234,7 +234,7 @@ pub struct CsSliceStorage<'a, N: Scalar, R: Dim, C: DimAdd> { /// A compressed sparse column matrix. #[derive(Clone, Debug, PartialEq)] pub struct CsMatrix< - N: Scalar, + N: Scalar + Copy, R: Dim = Dynamic, C: Dim = Dynamic, S: CsStorage = CsVecStorage, @@ -246,7 +246,7 @@ pub struct CsMatrix< /// A column compressed sparse vector. pub type CsVector> = CsMatrix; -impl CsMatrix +impl CsMatrix where DefaultAllocator: Allocator { /// Creates a new compressed sparse column matrix with the specified dimension and @@ -323,7 +323,7 @@ where DefaultAllocator: Allocator } /* -impl CsMatrix { +impl CsMatrix { pub(crate) fn from_parts( nrows: usize, ncols: usize, @@ -340,7 +340,7 @@ impl CsMatrix { } */ -impl> CsMatrix { +impl> CsMatrix { pub(crate) fn from_data(data: S) -> Self { CsMatrix { data, @@ -433,7 +433,7 @@ impl> CsMatrix { } } -impl> CsMatrix { +impl> CsMatrix { /// Iterator through all the mutable values of this sparse matrix. #[inline] pub fn values_mut(&mut self) -> impl Iterator { @@ -441,7 +441,7 @@ impl> CsMatrix { } } -impl CsMatrix +impl CsMatrix where DefaultAllocator: Allocator { pub(crate) fn sort(&mut self) diff --git a/src/sparse/cs_matrix_conversion.rs b/src/sparse/cs_matrix_conversion.rs index 31e53796..251fa282 100644 --- a/src/sparse/cs_matrix_conversion.rs +++ b/src/sparse/cs_matrix_conversion.rs @@ -7,7 +7,7 @@ use crate::sparse::{CsMatrix, CsStorage}; use crate::storage::Storage; use crate::{DefaultAllocator, Dim, Dynamic, Matrix, MatrixMN, Scalar}; -impl<'a, N: Scalar + Zero + ClosedAdd> CsMatrix { +impl<'a, N: Scalar + Copy + Zero + ClosedAdd> CsMatrix { /// Creates a column-compressed sparse matrix from a sparse matrix in triplet form. pub fn from_triplet( nrows: usize, @@ -21,7 +21,7 @@ impl<'a, N: Scalar + Zero + ClosedAdd> CsMatrix { } } -impl<'a, N: Scalar + Zero + ClosedAdd, R: Dim, C: Dim> CsMatrix +impl<'a, N: Scalar + Copy + Zero + ClosedAdd, R: Dim, C: Dim> CsMatrix where DefaultAllocator: Allocator + Allocator { /// Creates a column-compressed sparse matrix from a sparse matrix in triplet form. @@ -66,7 +66,7 @@ where DefaultAllocator: Allocator + Allocator } } -impl<'a, N: Scalar + Zero, R: Dim, C: Dim, S> From> for MatrixMN +impl<'a, N: Scalar + Copy + Zero, R: Dim, C: Dim, S> From> for MatrixMN where S: CsStorage, DefaultAllocator: Allocator, @@ -85,7 +85,7 @@ where } } -impl<'a, N: Scalar + Zero, R: Dim, C: Dim, S> From> for CsMatrix +impl<'a, N: Scalar + Copy + Zero, R: Dim, C: Dim, S> From> for CsMatrix where S: Storage, DefaultAllocator: Allocator + Allocator, diff --git a/src/sparse/cs_matrix_ops.rs b/src/sparse/cs_matrix_ops.rs index 322ebb34..9e827e3c 100644 --- a/src/sparse/cs_matrix_ops.rs +++ b/src/sparse/cs_matrix_ops.rs @@ -8,7 +8,7 @@ use crate::sparse::{CsMatrix, CsStorage, CsStorageMut, CsVector}; use crate::storage::StorageMut; use crate::{DefaultAllocator, Dim, Scalar, Vector, VectorN, U1}; -impl> CsMatrix { +impl> CsMatrix { fn scatter( &self, j: usize, @@ -39,7 +39,7 @@ impl> CsMatrix { } /* -impl CsVector { +impl CsVector { pub fn axpy(&mut self, alpha: N, x: CsVector, beta: N) { // First, compute the number of non-zero entries. let mut nnzero = 0; @@ -76,7 +76,7 @@ impl CsVector { } */ -impl> Vector { +impl> Vector { /// Perform a sparse axpy operation: `self = alpha * x + beta * self` operation. pub fn axpy_cs(&mut self, alpha: N, x: &CsVector, beta: N) where @@ -126,7 +126,7 @@ impl> Vect impl<'a, 'b, N, R1, R2, C1, C2, S1, S2> Mul<&'b CsMatrix> for &'a CsMatrix where - N: Scalar + ClosedAdd + ClosedMul + Zero, + N: Scalar + Copy + ClosedAdd + ClosedMul + Zero, R1: Dim, C1: Dim, R2: Dim, @@ -219,7 +219,7 @@ where impl<'a, 'b, N, R1, R2, C1, C2, S1, S2> Add<&'b CsMatrix> for &'a CsMatrix where - N: Scalar + ClosedAdd + ClosedMul + One, + N: Scalar + Copy + ClosedAdd + ClosedMul + One, R1: Dim, C1: Dim, R2: Dim, @@ -287,7 +287,7 @@ where impl<'a, 'b, N, R, C, S> Mul for CsMatrix where - N: Scalar + ClosedAdd + ClosedMul + Zero, + N: Scalar + Copy + ClosedAdd + ClosedMul + Zero, R: Dim, C: Dim, S: CsStorageMut,