From 774f4da3e2b2556eaf1cf9fabd7ce59748a22d47 Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Mon, 16 Dec 2019 18:09:14 -0500 Subject: [PATCH] Add `Clone` to `Scalar`, providing a default implementation of `inlined_clone`. Change `Scalar + Clone` bounds to just `Scalar`. --- examples/scalar_genericity.rs | 4 +- nalgebra-glm/src/common.rs | 6 +- nalgebra-glm/src/constructors.rs | 32 ++++----- nalgebra-glm/src/gtc/bitfield.rs | 10 +-- nalgebra-glm/src/gtc/integer.rs | 4 +- nalgebra-glm/src/gtc/matrix_access.rs | 8 +-- nalgebra-glm/src/gtc/packing.rs | 6 +- nalgebra-glm/src/gtc/round.rs | 18 ++--- nalgebra-glm/src/gtc/type_ptr.rs | 60 ++++++++-------- nalgebra-glm/src/gtc/ulp.rs | 2 +- nalgebra-glm/src/integer.rs | 20 +++--- nalgebra-glm/src/matrix.rs | 2 +- nalgebra-glm/src/packing.rs | 24 +++---- nalgebra-glm/src/traits.rs | 4 +- nalgebra-lapack/src/cholesky.rs | 2 +- nalgebra-lapack/src/eigen.rs | 4 +- nalgebra-lapack/src/hessenberg.rs | 2 +- nalgebra-lapack/src/lu.rs | 2 +- nalgebra-lapack/src/qr.rs | 2 +- nalgebra-lapack/src/schur.rs | 4 +- nalgebra-lapack/src/svd.rs | 4 +- nalgebra-lapack/src/symmetric_eigen.rs | 4 +- src/base/allocator.rs | 12 ++-- src/base/array_storage.rs | 16 ++--- src/base/blas.rs | 18 ++--- src/base/cg.rs | 6 +- src/base/componentwise.rs | 6 +- src/base/construction.rs | 24 +++---- src/base/construction_slice.rs | 16 ++--- src/base/conversion.rs | 54 +++++++------- src/base/coordinates.rs | 6 +- src/base/default_allocator.rs | 20 +++--- src/base/edition.rs | 24 +++---- src/base/indexing.rs | 18 ++--- src/base/iter.rs | 40 +++++------ src/base/matrix.rs | 90 ++++++++++++------------ src/base/matrix_alga.rs | 28 ++++---- src/base/matrix_slice.rs | 40 +++++------ src/base/ops.rs | 64 ++++++++--------- src/base/properties.rs | 2 +- src/base/scalar.rs | 8 +-- src/base/statistics.rs | 4 +- src/base/storage.rs | 8 +-- src/base/swizzle.rs | 2 +- src/base/vec_storage.rs | 18 ++--- src/debug/random_orthogonal.rs | 2 +- src/debug/random_sdp.rs | 2 +- src/geometry/op_macros.rs | 8 +-- src/geometry/perspective.rs | 2 +- src/geometry/point.rs | 26 +++---- src/geometry/point_alga.rs | 10 +-- src/geometry/point_construction.rs | 14 ++-- src/geometry/point_conversion.rs | 20 +++--- src/geometry/point_coordinates.rs | 4 +- src/geometry/point_ops.rs | 18 ++--- src/geometry/reflection.rs | 2 +- src/geometry/rotation.rs | 24 +++---- src/geometry/rotation_construction.rs | 4 +- src/geometry/rotation_ops.rs | 2 +- src/geometry/swizzle.rs | 2 +- src/geometry/translation.rs | 28 ++++---- src/geometry/translation_construction.rs | 10 +-- src/geometry/translation_conversion.rs | 8 +-- src/geometry/translation_coordinates.rs | 4 +- src/linalg/lu.rs | 4 +- src/linalg/permutation_sequence.rs | 8 +-- src/sparse/cs_matrix.rs | 28 ++++---- src/sparse/cs_matrix_conversion.rs | 8 +-- src/sparse/cs_matrix_ops.rs | 12 ++-- 69 files changed, 499 insertions(+), 499 deletions(-) diff --git a/examples/scalar_genericity.rs b/examples/scalar_genericity.rs index c1d363f7..75f6f9d4 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/nalgebra-glm/src/common.rs b/nalgebra-glm/src/common.rs index 42f26d30..eda9f295 100644 --- a/nalgebra-glm/src/common.rs +++ b/nalgebra-glm/src/common.rs @@ -297,13 +297,13 @@ where DefaultAllocator: Alloc { v.map(int_bits_to_float) } -//pub fn isinf(x: &TVec) -> TVec +//pub fn isinf(x: &TVec) -> TVec // where DefaultAllocator: Alloc { // unimplemented!() // //} // -//pub fn isnan(x: &TVec) -> TVec +//pub fn isnan(x: &TVec) -> TVec // where DefaultAllocator: Alloc { // unimplemented!() // @@ -504,7 +504,7 @@ where DefaultAllocator: Alloc { x.map(|x| x.round()) } -//pub fn roundEven(x: &TVec) -> TVec +//pub fn roundEven(x: &TVec) -> TVec // where DefaultAllocator: Alloc { // unimplemented!() //} diff --git a/nalgebra-glm/src/constructors.rs b/nalgebra-glm/src/constructors.rs index 020bbcb4..949ea9e4 100644 --- a/nalgebra-glm/src/constructors.rs +++ b/nalgebra-glm/src/constructors.rs @@ -15,28 +15,28 @@ use crate::aliases::{TMat, Qua, TVec1, TVec2, TVec3, TVec4, TMat2, TMat2x3, TMat /// # use nalgebra_glm as glm; /// let v = glm::vec1(true); /// ``` -pub fn vec1(x: N) -> TVec1 { +pub fn vec1(x: N) -> TVec1 { TVec1::new(x) } /// Creates a new 2D vector. -pub fn vec2(x: N, y: N) -> TVec2 { +pub fn vec2(x: N, y: N) -> TVec2 { TVec2::new(x, y) } /// Creates a new 3D vector. -pub fn vec3(x: N, y: N, z: N) -> TVec3 { +pub fn vec3(x: N, y: N, z: N) -> TVec3 { TVec3::new(x, y, z) } /// Creates a new 4D vector. -pub fn vec4(x: N, y: N, z: N, w: N) -> TVec4 { +pub fn vec4(x: N, y: N, z: N, w: N) -> TVec4 { TVec4::new(x, y, z, w) } /// Create a new 2x2 matrix. -pub fn mat2(m11: N, m12: N, +pub fn mat2(m11: N, m12: N, m21: N, m22: N) -> TMat2 { TMat::::new( m11, m12, @@ -45,7 +45,7 @@ pub fn mat2(m11: N, m12: N, } /// Create a new 2x2 matrix. -pub fn mat2x2(m11: N, m12: N, +pub fn mat2x2(m11: N, m12: N, m21: N, m22: N) -> TMat2 { TMat::::new( m11, m12, @@ -54,7 +54,7 @@ pub fn mat2x2(m11: N, m12: N, } /// Create a new 2x3 matrix. -pub fn mat2x3(m11: N, m12: N, m13: N, +pub fn mat2x3(m11: N, m12: N, m13: N, m21: N, m22: N, m23: N) -> TMat2x3 { TMat::::new( m11, m12, m13, @@ -63,7 +63,7 @@ pub fn mat2x3(m11: N, m12: N, m13: N, } /// Create a new 2x4 matrix. -pub fn mat2x4(m11: N, m12: N, m13: N, m14: N, +pub fn mat2x4(m11: N, m12: N, m13: N, m14: N, m21: N, m22: N, m23: N, m24: N) -> TMat2x4 { TMat::::new( m11, m12, m13, m14, @@ -72,7 +72,7 @@ pub fn mat2x4(m11: N, m12: N, m13: N, m14: N, } /// Create a new 3x3 matrix. -pub fn mat3(m11: N, m12: N, m13: N, +pub fn mat3(m11: N, m12: N, m13: N, m21: N, m22: N, m23: N, m31: N, m32: N, m33: N) -> TMat3 { TMat::::new( @@ -83,7 +83,7 @@ pub fn mat3(m11: N, m12: N, m13: N, } /// Create a new 3x2 matrix. -pub fn mat3x2(m11: N, m12: N, +pub fn mat3x2(m11: N, m12: N, m21: N, m22: N, m31: N, m32: N) -> TMat3x2 { TMat::::new( @@ -94,7 +94,7 @@ pub fn mat3x2(m11: N, m12: N, } /// Create a new 3x3 matrix. -pub fn mat3x3(m11: N, m12: N, m13: N, +pub fn mat3x3(m11: N, m12: N, m13: N, m21: N, m22: N, m23: N, m31: N, m32: N, m33: N) -> TMat3 { TMat::::new( @@ -105,7 +105,7 @@ pub fn mat3x3(m11: N, m12: N, m13: N, } /// Create a new 3x4 matrix. -pub fn mat3x4(m11: N, m12: N, m13: N, m14: N, +pub fn mat3x4(m11: N, m12: N, m13: N, m14: N, m21: N, m22: N, m23: N, m24: N, m31: N, m32: N, m33: N, m34: N) -> TMat3x4 { TMat::::new( @@ -116,7 +116,7 @@ pub fn mat3x4(m11: N, m12: N, m13: N, m14: N, } /// Create a new 4x2 matrix. -pub fn mat4x2(m11: N, m12: N, +pub fn mat4x2(m11: N, m12: N, m21: N, m22: N, m31: N, m32: N, m41: N, m42: N) -> TMat4x2 { @@ -129,7 +129,7 @@ pub fn mat4x2(m11: N, m12: N, } /// Create a new 4x3 matrix. -pub fn mat4x3(m11: N, m12: N, m13: N, +pub fn mat4x3(m11: N, m12: N, m13: N, m21: N, m22: N, m23: N, m31: N, m32: N, m33: N, m41: N, m42: N, m43: N) -> TMat4x3 { @@ -142,7 +142,7 @@ pub fn mat4x3(m11: N, m12: N, m13: N, } /// Create a new 4x4 matrix. -pub fn mat4x4(m11: N, m12: N, m13: N, m14: N, +pub fn mat4x4(m11: N, m12: N, m13: N, m14: N, m21: N, m22: N, m23: N, m24: N, m31: N, m32: N, m33: N, m34: N, m41: N, m42: N, m43: N, m44: N) -> TMat4 { @@ -155,7 +155,7 @@ pub fn mat4x4(m11: N, m12: N, m13: N, m14: N, } /// Create a new 4x4 matrix. -pub fn mat4(m11: N, m12: N, m13: N, m14: N, +pub fn mat4(m11: N, m12: N, m13: N, m14: N, m21: N, m22: N, m23: N, m24: N, m31: N, m32: N, m33: N, m34: N, m41: N, m42: N, m43: N, m44: N) -> TMat4 { diff --git a/nalgebra-glm/src/gtc/bitfield.rs b/nalgebra-glm/src/gtc/bitfield.rs index 81a1646f..bdf18552 100644 --- a/nalgebra-glm/src/gtc/bitfield.rs +++ b/nalgebra-glm/src/gtc/bitfield.rs @@ -19,7 +19,7 @@ pub fn bitfieldFillOne(Value: IU, FirstBit: i32, BitCount: i32) -> IU { unimplemented!() } -pub fn bitfieldFillOne2(Value: &TVec, FirstBit: i32, BitCount: i32) -> TVec +pub fn bitfieldFillOne2(Value: &TVec, FirstBit: i32, BitCount: i32) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -28,7 +28,7 @@ pub fn bitfieldFillZero(Value: IU, FirstBit: i32, BitCount: i32) -> IU { unimplemented!() } -pub fn bitfieldFillZero2(Value: &TVec, FirstBit: i32, BitCount: i32) -> TVec +pub fn bitfieldFillZero2(Value: &TVec, FirstBit: i32, BitCount: i32) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -113,7 +113,7 @@ pub fn bitfieldRotateLeft(In: IU, Shift: i32) -> IU { unimplemented!() } -pub fn bitfieldRotateLeft2(In: &TVec, Shift: i32) -> TVec +pub fn bitfieldRotateLeft2(In: &TVec, Shift: i32) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -122,7 +122,7 @@ pub fn bitfieldRotateRight(In: IU, Shift: i32) -> IU { unimplemented!() } -pub fn bitfieldRotateRight2(In: &TVec, Shift: i32) -> TVec +pub fn bitfieldRotateRight2(In: &TVec, Shift: i32) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -131,7 +131,7 @@ pub fn mask(Bits: IU) -> IU { unimplemented!() } -pub fn mask2(v: &TVec) -> TVec +pub fn mask2(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } diff --git a/nalgebra-glm/src/gtc/integer.rs b/nalgebra-glm/src/gtc/integer.rs index d5965f38..a972a4ab 100644 --- a/nalgebra-glm/src/gtc/integer.rs +++ b/nalgebra-glm/src/gtc/integer.rs @@ -3,7 +3,7 @@ //use crate::traits::{Alloc, Dimension}; //use crate::aliases::TVec; -//pub fn iround(x: &TVec) -> TVec +//pub fn iround(x: &TVec) -> TVec // where DefaultAllocator: Alloc { // x.map(|x| x.round()) //} @@ -12,7 +12,7 @@ // unimplemented!() //} // -//pub fn uround(x: &TVec) -> TVec +//pub fn uround(x: &TVec) -> TVec // where DefaultAllocator: Alloc { // unimplemented!() //} diff --git a/nalgebra-glm/src/gtc/matrix_access.rs b/nalgebra-glm/src/gtc/matrix_access.rs index bfc0199b..f61d9782 100644 --- a/nalgebra-glm/src/gtc/matrix_access.rs +++ b/nalgebra-glm/src/gtc/matrix_access.rs @@ -10,7 +10,7 @@ use crate::traits::{Alloc, Dimension}; /// * [`row`](fn.row.html) /// * [`set_column`](fn.set_column.html) /// * [`set_row`](fn.set_row.html) -pub fn column( +pub fn column( m: &TMat, index: usize, ) -> TVec @@ -27,7 +27,7 @@ where /// * [`column`](fn.column.html) /// * [`row`](fn.row.html) /// * [`set_row`](fn.set_row.html) -pub fn set_column( +pub fn set_column( m: &TMat, index: usize, x: &TVec, @@ -47,7 +47,7 @@ where /// * [`column`](fn.column.html) /// * [`set_column`](fn.set_column.html) /// * [`set_row`](fn.set_row.html) -pub fn row(m: &TMat, index: usize) -> TVec +pub fn row(m: &TMat, index: usize) -> TVec where DefaultAllocator: Alloc { m.row(index).into_owned().transpose() } @@ -59,7 +59,7 @@ where DefaultAllocator: Alloc { /// * [`column`](fn.column.html) /// * [`row`](fn.row.html) /// * [`set_column`](fn.set_column.html) -pub fn set_row( +pub fn set_row( m: &TMat, index: usize, x: &TVec, diff --git a/nalgebra-glm/src/gtc/packing.rs b/nalgebra-glm/src/gtc/packing.rs index 5d649538..ea5acac4 100644 --- a/nalgebra-glm/src/gtc/packing.rs +++ b/nalgebra-glm/src/gtc/packing.rs @@ -49,7 +49,7 @@ pub fn packInt4x8(v: &I8Vec4) -> i32 { unimplemented!() } -pub fn packRGBM(rgb: &TVec3) -> TVec4 { +pub fn packRGBM(rgb: &TVec3) -> TVec4 { unimplemented!() } @@ -155,7 +155,7 @@ pub fn unpackF3x9_E1x5(p: i32) -> Vec3 { unimplemented!() } -pub fn unpackHalf(p: TVec) -> TVec +pub fn unpackHalf(p: TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -192,7 +192,7 @@ pub fn unpackInt4x8(p: i32) -> I8Vec4 { unimplemented!() } -pub fn unpackRGBM(rgbm: &TVec4) -> TVec3 { +pub fn unpackRGBM(rgbm: &TVec4) -> TVec3 { unimplemented!() } diff --git a/nalgebra-glm/src/gtc/round.rs b/nalgebra-glm/src/gtc/round.rs index 21d3a21e..5ad95780 100644 --- a/nalgebra-glm/src/gtc/round.rs +++ b/nalgebra-glm/src/gtc/round.rs @@ -8,7 +8,7 @@ pub fn ceilMultiple(v: T, Multiple: T) -> T { unimplemented!() } -pub fn ceilMultiple2(v: &TVec, Multiple: &TVec) -> TVec +pub fn ceilMultiple2(v: &TVec, Multiple: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -17,7 +17,7 @@ pub fn ceilPowerOfTwo(v: IU) -> IU { unimplemented!() } -pub fn ceilPowerOfTwo2(v: &TVec) -> TVec +pub fn ceilPowerOfTwo2(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -26,7 +26,7 @@ pub fn floorMultiple(v: T, Multiple: T) -> T { unimplemented!() } -pub fn floorMultiple2(v: &TVec, Multiple: &TVec) -> TVec +pub fn floorMultiple2(v: &TVec, Multiple: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -35,7 +35,7 @@ pub fn floorPowerOfTwo(v: IU) -> IU { unimplemented!() } -pub fn floorPowerOfTwo2(v: &TVec) -> TVec +pub fn floorPowerOfTwo2(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -44,12 +44,12 @@ pub fn isMultiple(v: IU, Multiple: IU) -> bool { unimplemented!() } -pub fn isMultiple2(v: &TVec,Multiple: N) -> TVec +pub fn isMultiple2(v: &TVec,Multiple: N) -> TVec where DefaultAllocator: Alloc { unimplemented!() } -pub fn isMultiple3(v: &TVec, Multiple: &TVec) -> TVec +pub fn isMultiple3(v: &TVec, Multiple: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -58,7 +58,7 @@ pub fn isPowerOfTwo2(v: IU) -> bool { unimplemented!() } -pub fn isPowerOfTwo(v: &TVec) -> TVec +pub fn isPowerOfTwo(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -67,7 +67,7 @@ pub fn roundMultiple(v: T, Multiple: T) -> T { unimplemented!() } -pub fn roundMultiple2(v: &TVec, Multiple: &TVec) -> TVec +pub fn roundMultiple2(v: &TVec, Multiple: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -76,7 +76,7 @@ pub fn roundPowerOfTwo(v: IU) -> IU { unimplemented!() } -pub fn roundPowerOfTwo2(v: &TVec) -> TVec +pub fn roundPowerOfTwo2(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } diff --git a/nalgebra-glm/src/gtc/type_ptr.rs b/nalgebra-glm/src/gtc/type_ptr.rs index ad9e6f8f..6de096ca 100644 --- a/nalgebra-glm/src/gtc/type_ptr.rs +++ b/nalgebra-glm/src/gtc/type_ptr.rs @@ -7,62 +7,62 @@ use crate::aliases::{ use crate::traits::{Alloc, Dimension, Number}; /// Creates a 2x2 matrix from a slice arranged in column-major order. -pub fn make_mat2(ptr: &[N]) -> TMat2 { +pub fn make_mat2(ptr: &[N]) -> TMat2 { TMat2::from_column_slice(ptr) } /// Creates a 2x2 matrix from a slice arranged in column-major order. -pub fn make_mat2x2(ptr: &[N]) -> TMat2 { +pub fn make_mat2x2(ptr: &[N]) -> TMat2 { TMat2::from_column_slice(ptr) } /// Creates a 2x3 matrix from a slice arranged in column-major order. -pub fn make_mat2x3(ptr: &[N]) -> TMat2x3 { +pub fn make_mat2x3(ptr: &[N]) -> TMat2x3 { TMat2x3::from_column_slice(ptr) } /// Creates a 2x4 matrix from a slice arranged in column-major order. -pub fn make_mat2x4(ptr: &[N]) -> TMat2x4 { +pub fn make_mat2x4(ptr: &[N]) -> TMat2x4 { TMat2x4::from_column_slice(ptr) } /// Creates a 3 matrix from a slice arranged in column-major order. -pub fn make_mat3(ptr: &[N]) -> TMat3 { +pub fn make_mat3(ptr: &[N]) -> TMat3 { TMat3::from_column_slice(ptr) } /// Creates a 3x2 matrix from a slice arranged in column-major order. -pub fn make_mat3x2(ptr: &[N]) -> TMat3x2 { +pub fn make_mat3x2(ptr: &[N]) -> TMat3x2 { TMat3x2::from_column_slice(ptr) } /// Creates a 3x3 matrix from a slice arranged in column-major order. -pub fn make_mat3x3(ptr: &[N]) -> TMat3 { +pub fn make_mat3x3(ptr: &[N]) -> TMat3 { TMat3::from_column_slice(ptr) } /// Creates a 3x4 matrix from a slice arranged in column-major order. -pub fn make_mat3x4(ptr: &[N]) -> TMat3x4 { +pub fn make_mat3x4(ptr: &[N]) -> TMat3x4 { TMat3x4::from_column_slice(ptr) } /// Creates a 4x4 matrix from a slice arranged in column-major order. -pub fn make_mat4(ptr: &[N]) -> TMat4 { +pub fn make_mat4(ptr: &[N]) -> TMat4 { TMat4::from_column_slice(ptr) } /// Creates a 4x2 matrix from a slice arranged in column-major order. -pub fn make_mat4x2(ptr: &[N]) -> TMat4x2 { +pub fn make_mat4x2(ptr: &[N]) -> TMat4x2 { TMat4x2::from_column_slice(ptr) } /// Creates a 4x3 matrix from a slice arranged in column-major order. -pub fn make_mat4x3(ptr: &[N]) -> TMat4x3 { +pub fn make_mat4x3(ptr: &[N]) -> TMat4x3 { TMat4x3::from_column_slice(ptr) } /// Creates a 4x4 matrix from a slice arranged in column-major order. -pub fn make_mat4x4(ptr: &[N]) -> TMat4 { +pub fn make_mat4x4(ptr: &[N]) -> TMat4 { TMat4::from_column_slice(ptr) } @@ -75,7 +75,7 @@ pub fn mat2_to_mat3(m: &TMat2) -> TMat3 { } /// Converts a 3x3 matrix to a 2x2 matrix. -pub fn mat3_to_mat2(m: &TMat3) -> TMat2 { +pub fn mat3_to_mat2(m: &TMat3) -> TMat2 { TMat2::new(m.m11.inlined_clone(), m.m12.inlined_clone(), m.m21.inlined_clone(), m.m22.inlined_clone()) } @@ -90,7 +90,7 @@ pub fn mat3_to_mat4(m: &TMat3) -> TMat4 { } /// Converts a 4x4 matrix to a 3x3 matrix. -pub fn mat4_to_mat3(m: &TMat4) -> TMat3 { +pub fn mat4_to_mat3(m: &TMat4) -> TMat3 { TMat3::new( m.m11.inlined_clone(), m.m12.inlined_clone(), m.m13.inlined_clone(), m.m21.inlined_clone(), m.m22.inlined_clone(), m.m23.inlined_clone(), @@ -109,7 +109,7 @@ pub fn mat2_to_mat4(m: &TMat2) -> TMat4 { } /// Converts a 4x4 matrix to a 2x2 matrix. -pub fn mat4_to_mat2(m: &TMat4) -> TMat2 { +pub fn mat4_to_mat2(m: &TMat4) -> TMat2 { TMat2::new(m.m11.inlined_clone(), m.m12.inlined_clone(), m.m21.inlined_clone(), m.m22.inlined_clone()) } @@ -125,7 +125,7 @@ pub fn make_quat(ptr: &[N]) -> Qua { /// * [`make_vec2`](fn.make_vec2.html) /// * [`make_vec3`](fn.make_vec3.html) /// * [`make_vec4`](fn.make_vec4.html) -pub fn make_vec1(v: &TVec1) -> TVec1 { +pub fn make_vec1(v: &TVec1) -> TVec1 { v.clone() } @@ -139,7 +139,7 @@ pub fn make_vec1(v: &TVec1) -> TVec1 { /// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) /// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) /// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) -pub fn vec2_to_vec1(v: &TVec2) -> TVec1 { +pub fn vec2_to_vec1(v: &TVec2) -> TVec1 { TVec1::new(v.x.inlined_clone()) } @@ -153,7 +153,7 @@ pub fn vec2_to_vec1(v: &TVec2) -> TVec1 { /// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) /// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) /// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) -pub fn vec3_to_vec1(v: &TVec3) -> TVec1 { +pub fn vec3_to_vec1(v: &TVec3) -> TVec1 { TVec1::new(v.x.inlined_clone()) } @@ -167,7 +167,7 @@ pub fn vec3_to_vec1(v: &TVec3) -> TVec1 { /// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) /// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) /// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) -pub fn vec4_to_vec1(v: &TVec4) -> TVec1 { +pub fn vec4_to_vec1(v: &TVec4) -> TVec1 { TVec1::new(v.x.inlined_clone()) } @@ -198,7 +198,7 @@ pub fn vec1_to_vec2(v: &TVec1) -> TVec2 { /// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) /// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) /// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) -pub fn vec2_to_vec2(v: &TVec2) -> TVec2 { +pub fn vec2_to_vec2(v: &TVec2) -> TVec2 { v.clone() } @@ -212,7 +212,7 @@ pub fn vec2_to_vec2(v: &TVec2) -> TVec2 { /// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) /// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) /// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) -pub fn vec3_to_vec2(v: &TVec3) -> TVec2 { +pub fn vec3_to_vec2(v: &TVec3) -> TVec2 { TVec2::new(v.x.inlined_clone(), v.y.inlined_clone()) } @@ -226,7 +226,7 @@ pub fn vec3_to_vec2(v: &TVec3) -> TVec2 { /// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) /// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) /// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) -pub fn vec4_to_vec2(v: &TVec4) -> TVec2 { +pub fn vec4_to_vec2(v: &TVec4) -> TVec2 { TVec2::new(v.x.inlined_clone(), v.y.inlined_clone()) } @@ -237,7 +237,7 @@ pub fn vec4_to_vec2(v: &TVec4) -> TVec2 { /// * [`make_vec1`](fn.make_vec1.html) /// * [`make_vec3`](fn.make_vec3.html) /// * [`make_vec4`](fn.make_vec4.html) -pub fn make_vec2(ptr: &[N]) -> TVec2 { +pub fn make_vec2(ptr: &[N]) -> TVec2 { TVec2::from_column_slice(ptr) } @@ -282,7 +282,7 @@ pub fn vec2_to_vec3(v: &TVec2) -> TVec3 { /// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) /// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) /// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) -pub fn vec3_to_vec3(v: &TVec3) -> TVec3 { +pub fn vec3_to_vec3(v: &TVec3) -> TVec3 { v.clone() } @@ -296,7 +296,7 @@ pub fn vec3_to_vec3(v: &TVec3) -> TVec3 { /// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) /// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) /// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) -pub fn vec4_to_vec3(v: &TVec4) -> TVec3 { +pub fn vec4_to_vec3(v: &TVec4) -> TVec3 { TVec3::new(v.x.inlined_clone(), v.y.inlined_clone(), v.z.inlined_clone()) } @@ -307,7 +307,7 @@ pub fn vec4_to_vec3(v: &TVec4) -> TVec3 { /// * [`make_vec1`](fn.make_vec1.html) /// * [`make_vec2`](fn.make_vec2.html) /// * [`make_vec4`](fn.make_vec4.html) -pub fn make_vec3(ptr: &[N]) -> TVec3 { +pub fn make_vec3(ptr: &[N]) -> TVec3 { TVec3::from_column_slice(ptr) } @@ -369,7 +369,7 @@ pub fn vec3_to_vec4(v: &TVec3) -> TVec4 { /// * [`vec4_to_vec1`](fn.vec4_to_vec1.html) /// * [`vec4_to_vec2`](fn.vec4_to_vec2.html) /// * [`vec4_to_vec3`](fn.vec4_to_vec3.html) -pub fn vec4_to_vec4(v: &TVec4) -> TVec4 { +pub fn vec4_to_vec4(v: &TVec4) -> TVec4 { v.clone() } @@ -380,18 +380,18 @@ pub fn vec4_to_vec4(v: &TVec4) -> TVec4 { /// * [`make_vec1`](fn.make_vec1.html) /// * [`make_vec2`](fn.make_vec2.html) /// * [`make_vec3`](fn.make_vec3.html) -pub fn make_vec4(ptr: &[N]) -> TVec4 { +pub fn make_vec4(ptr: &[N]) -> TVec4 { TVec4::from_column_slice(ptr) } /// Converts a matrix or vector to a slice arranged in column-major order. -pub fn value_ptr(x: &TMat) -> &[N] +pub fn value_ptr(x: &TMat) -> &[N] where DefaultAllocator: Alloc { x.as_slice() } /// Converts a matrix or vector to a mutable slice arranged in column-major order. -pub fn value_ptr_mut(x: &mut TMat) -> &mut [N] +pub fn value_ptr_mut(x: &mut TMat) -> &mut [N] where DefaultAllocator: Alloc { x.as_mut_slice() } diff --git a/nalgebra-glm/src/gtc/ulp.rs b/nalgebra-glm/src/gtc/ulp.rs index 07116b15..8258d0df 100644 --- a/nalgebra-glm/src/gtc/ulp.rs +++ b/nalgebra-glm/src/gtc/ulp.rs @@ -7,7 +7,7 @@ pub fn float_distance(x: T, y: T) -> u64 { unimplemented!() } -pub fn float_distance2(x: &TVec2, y: &TVec2) -> TVec { +pub fn float_distance2(x: &TVec2, y: &TVec2) -> TVec { unimplemented!() } diff --git a/nalgebra-glm/src/integer.rs b/nalgebra-glm/src/integer.rs index 73cae447..198d737a 100644 --- a/nalgebra-glm/src/integer.rs +++ b/nalgebra-glm/src/integer.rs @@ -7,22 +7,22 @@ pub fn bitCount(v: T) -> i32 { unimplemented!() } -pub fn bitCount2(v: &TVec) -> TVec +pub fn bitCount2(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } -pub fn bitfieldExtract(Value: &TVec, Offset: i32, Bits: i32) -> TVec +pub fn bitfieldExtract(Value: &TVec, Offset: i32, Bits: i32) -> TVec where DefaultAllocator: Alloc { unimplemented!() } -pub fn bitfieldInsert(Base: &TVec, Insert: &TVec, Offset: i32, Bits: i32) -> TVec +pub fn bitfieldInsert(Base: &TVec, Insert: &TVec, Offset: i32, Bits: i32) -> TVec where DefaultAllocator: Alloc { unimplemented!() } -pub fn bitfieldReverse(v: &TVec) -> TVec +pub fn bitfieldReverse(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -31,7 +31,7 @@ pub fn findLSB(x: IU) -> u32 { unimplemented!() } -pub fn findLSB2(v: &TVec) -> TVec +pub fn findLSB2(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } @@ -40,27 +40,27 @@ pub fn findMSB(x: IU) -> i32 { unimplemented!() } -pub fn findMSB2(v: &TVec) -> TVec +pub fn findMSB2(v: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } -pub fn imulExtended(x: &TVec, y: &TVec, msb: &TVec, lsb: &TVec) +pub fn imulExtended(x: &TVec, y: &TVec, msb: &TVec, lsb: &TVec) where DefaultAllocator: Alloc { unimplemented!() } -pub fn uaddCarry(x: &TVec, y: &TVec, carry: &TVec) -> TVec +pub fn uaddCarry(x: &TVec, y: &TVec, carry: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } -pub fn umulExtended(x: &TVec, y: &TVec, msb: &TVec, lsb: &TVec) +pub fn umulExtended(x: &TVec, y: &TVec, msb: &TVec, lsb: &TVec) where DefaultAllocator: Alloc { unimplemented!() } -pub fn usubBorrow(x: &TVec, y: &TVec, borrow: &TVec) -> TVec +pub fn usubBorrow(x: &TVec, y: &TVec, borrow: &TVec) -> TVec where DefaultAllocator: Alloc { unimplemented!() } diff --git a/nalgebra-glm/src/matrix.rs b/nalgebra-glm/src/matrix.rs index c9c177b4..a4c4efe9 100644 --- a/nalgebra-glm/src/matrix.rs +++ b/nalgebra-glm/src/matrix.rs @@ -40,7 +40,7 @@ where } /// The transpose of the matrix `m`. -pub fn transpose(x: &TMat) -> TMat +pub fn transpose(x: &TMat) -> TMat where DefaultAllocator: Alloc { x.transpose() } diff --git a/nalgebra-glm/src/packing.rs b/nalgebra-glm/src/packing.rs index e0169cbe..3273fb26 100644 --- a/nalgebra-glm/src/packing.rs +++ b/nalgebra-glm/src/packing.rs @@ -3,50 +3,50 @@ use na::Scalar; use crate::aliases::{Vec2, Vec4, UVec2}; -pub fn packDouble2x32(v: &UVec2) -> f64 { +pub fn packDouble2x32(v: &UVec2) -> f64 { unimplemented!() } -pub fn packHalf2x16(v: &Vec2) -> u32 { +pub fn packHalf2x16(v: &Vec2) -> u32 { unimplemented!() } -pub fn packSnorm2x16(v: &Vec2) -> u32 { +pub fn packSnorm2x16(v: &Vec2) -> u32 { unimplemented!() } -pub fn packSnorm4x8(v: &Vec4) -> u32 { +pub fn packSnorm4x8(v: &Vec4) -> u32 { unimplemented!() } -pub fn packUnorm2x16(v: &Vec2) -> u32 { +pub fn packUnorm2x16(v: &Vec2) -> u32 { unimplemented!() } -pub fn packUnorm4x8(v: &Vec4) -> u32 { +pub fn packUnorm4x8(v: &Vec4) -> u32 { unimplemented!() } -pub fn unpackDouble2x32(v: f64) -> UVec2 { +pub fn unpackDouble2x32(v: f64) -> UVec2 { unimplemented!() } -pub fn unpackHalf2x16(v: u32) -> Vec2 { +pub fn unpackHalf2x16(v: u32) -> Vec2 { unimplemented!() } -pub fn unpackSnorm2x16(p: u32) -> Vec2 { +pub fn unpackSnorm2x16(p: u32) -> Vec2 { unimplemented!() } -pub fn unpackSnorm4x8(p: u32) -> Vec4 { +pub fn unpackSnorm4x8(p: u32) -> Vec4 { unimplemented!() } -pub fn unpackUnorm2x16(p: u32) -> Vec2 { +pub fn unpackUnorm2x16(p: u32) -> Vec2 { unimplemented!() } -pub fn unpackUnorm4x8(p: u32) -> Vec4 { +pub fn unpackUnorm4x8(p: u32) -> Vec4 { unimplemented!() } diff --git a/nalgebra-glm/src/traits.rs b/nalgebra-glm/src/traits.rs index 15efb72b..22fd5581 100644 --- a/nalgebra-glm/src/traits.rs +++ b/nalgebra-glm/src/traits.rs @@ -20,7 +20,7 @@ impl + Signed + Fr {} #[doc(hidden)] -pub trait Alloc: +pub trait Alloc: Allocator + Allocator + Allocator @@ -50,7 +50,7 @@ pub trait Alloc: { } -impl Alloc for T where T: Allocator +impl Alloc for T where T: Allocator + Allocator + Allocator + Allocator diff --git a/nalgebra-lapack/src/cholesky.rs b/nalgebra-lapack/src/cholesky.rs index 7dce3a13..e25223fa 100644 --- a/nalgebra-lapack/src/cholesky.rs +++ b/nalgebra-lapack/src/cholesky.rs @@ -28,7 +28,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct Cholesky +pub struct Cholesky where DefaultAllocator: Allocator { l: MatrixN, diff --git a/nalgebra-lapack/src/eigen.rs b/nalgebra-lapack/src/eigen.rs index c645e228..91bc01ac 100644 --- a/nalgebra-lapack/src/eigen.rs +++ b/nalgebra-lapack/src/eigen.rs @@ -33,7 +33,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct Eigen +pub struct Eigen where DefaultAllocator: Allocator + Allocator { /// The eigenvalues of the decomposed matrix. @@ -311,7 +311,7 @@ where DefaultAllocator: Allocator + Allocator */ /// Trait implemented by scalar type for which Lapack function exist to compute the /// eigendecomposition. -pub trait EigenScalar: Scalar + Clone { +pub trait EigenScalar: Scalar { #[allow(missing_docs)] fn xgeev( jobvl: u8, diff --git a/nalgebra-lapack/src/hessenberg.rs b/nalgebra-lapack/src/hessenberg.rs index 92ec6cda..81e72966 100644 --- a/nalgebra-lapack/src/hessenberg.rs +++ b/nalgebra-lapack/src/hessenberg.rs @@ -30,7 +30,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct Hessenberg> +pub struct Hessenberg> where DefaultAllocator: Allocator + Allocator> { h: MatrixN, diff --git a/nalgebra-lapack/src/lu.rs b/nalgebra-lapack/src/lu.rs index a636a722..fb4296da 100644 --- a/nalgebra-lapack/src/lu.rs +++ b/nalgebra-lapack/src/lu.rs @@ -37,7 +37,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct LU, C: Dim> +pub struct LU, C: Dim> where DefaultAllocator: Allocator> + Allocator { lu: MatrixMN, diff --git a/nalgebra-lapack/src/qr.rs b/nalgebra-lapack/src/qr.rs index 7aa10cb5..d9d28910 100644 --- a/nalgebra-lapack/src/qr.rs +++ b/nalgebra-lapack/src/qr.rs @@ -33,7 +33,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct QR, C: Dim> +pub struct QR, C: Dim> where DefaultAllocator: Allocator + Allocator> { qr: MatrixMN, diff --git a/nalgebra-lapack/src/schur.rs b/nalgebra-lapack/src/schur.rs index 69d0a29a..0592acdf 100644 --- a/nalgebra-lapack/src/schur.rs +++ b/nalgebra-lapack/src/schur.rs @@ -33,7 +33,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct Schur +pub struct Schur where DefaultAllocator: Allocator + Allocator { re: VectorN, @@ -162,7 +162,7 @@ where DefaultAllocator: Allocator + Allocator * */ /// Trait implemented by scalars for which Lapack implements the RealField Schur decomposition. -pub trait SchurScalar: Scalar + Clone { +pub trait SchurScalar: Scalar { #[allow(missing_docs)] fn xgees( jobvs: u8, diff --git a/nalgebra-lapack/src/svd.rs b/nalgebra-lapack/src/svd.rs index ac77fba1..43bb1c20 100644 --- a/nalgebra-lapack/src/svd.rs +++ b/nalgebra-lapack/src/svd.rs @@ -36,7 +36,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct SVD, C: Dim> +pub struct SVD, C: Dim> where DefaultAllocator: Allocator + Allocator> + Allocator { /// The left-singular vectors `U` of this SVD. @@ -57,7 +57,7 @@ where /// Trait implemented by floats (`f32`, `f64`) and complex floats (`Complex`, `Complex`) /// supported by the Singular Value Decompotition. -pub trait SVDScalar, C: Dim>: Scalar + Clone +pub trait SVDScalar, C: Dim>: Scalar where DefaultAllocator: Allocator + Allocator + Allocator> diff --git a/nalgebra-lapack/src/symmetric_eigen.rs b/nalgebra-lapack/src/symmetric_eigen.rs index eccdf0f7..e575fdc1 100644 --- a/nalgebra-lapack/src/symmetric_eigen.rs +++ b/nalgebra-lapack/src/symmetric_eigen.rs @@ -35,7 +35,7 @@ use lapack; )) )] #[derive(Clone, Debug)] -pub struct SymmetricEigen +pub struct SymmetricEigen where DefaultAllocator: Allocator + Allocator { /// The eigenvectors of the decomposed matrix. @@ -169,7 +169,7 @@ where DefaultAllocator: Allocator + Allocator */ /// Trait implemented by scalars for which Lapack implements the eigendecomposition of symmetric /// real matrices. -pub trait SymmetricEigenScalar: Scalar + Clone { +pub trait SymmetricEigenScalar: Scalar { #[allow(missing_docs)] fn xsyev( jobz: u8, diff --git a/src/base/allocator.rs b/src/base/allocator.rs index 3625b059..0ad30981 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 + Clone, + N: Scalar, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { } @@ -76,7 +76,7 @@ where R2: Dim, C1: Dim, C2: Dim, - N: Scalar + Clone, + N: Scalar, DefaultAllocator: Allocator + Allocator, SameShapeC>, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, {} @@ -88,7 +88,7 @@ pub trait SameShapeVectorAllocator: where R1: Dim, R2: Dim, - N: Scalar + Clone, + N: Scalar, ShapeConstraint: SameNumberOfRows, { } @@ -97,7 +97,7 @@ impl SameShapeVectorAllocator for DefaultAllocator where R1: Dim, R2: Dim, - N: Scalar + Clone, + N: Scalar, DefaultAllocator: Allocator + Allocator>, ShapeConstraint: SameNumberOfRows, {} diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index ccddcce6..bebb8740 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 + Clone, + N: Scalar, R: DimName, C: DimName, R::Value: Mul, @@ -206,7 +206,7 @@ where unsafe impl StorageMut for ArrayStorage where - N: Scalar + Clone, + N: Scalar, R: DimName, C: DimName, R::Value: Mul, @@ -226,7 +226,7 @@ where unsafe impl ContiguousStorage for ArrayStorage where - N: Scalar + Clone, + N: Scalar, R: DimName, C: DimName, R::Value: Mul, @@ -236,7 +236,7 @@ where unsafe impl ContiguousStorageMut for ArrayStorage where - N: Scalar + Clone, + N: Scalar, R: DimName, C: DimName, R::Value: Mul, @@ -253,7 +253,7 @@ where #[cfg(feature = "serde-serialize")] impl Serialize for ArrayStorage where - N: Scalar + Clone + Serialize, + N: Scalar + Serialize, R: DimName, C: DimName, R::Value: Mul, @@ -274,7 +274,7 @@ where #[cfg(feature = "serde-serialize")] impl<'a, N, R, C> Deserialize<'a> for ArrayStorage where - N: Scalar + Clone + Deserialize<'a>, + N: Scalar + Deserialize<'a>, R: DimName, C: DimName, R::Value: Mul, @@ -295,7 +295,7 @@ struct ArrayStorageVisitor { #[cfg(feature = "serde-serialize")] impl ArrayStorageVisitor where - N: Scalar + Clone, + N: Scalar, R: DimName, C: DimName, R::Value: Mul, @@ -312,7 +312,7 @@ where #[cfg(feature = "serde-serialize")] impl<'a, N, R, C> Visitor<'a> for ArrayStorageVisitor where - N: Scalar + Clone + Deserialize<'a>, + N: Scalar + Deserialize<'a>, R: DimName, C: DimName, R::Value: Mul, diff --git a/src/base/blas.rs b/src/base/blas.rs index 5cdc52dc..d147bbcb 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> Matrix -where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul +where N: Scalar + Zero + ClosedAdd + ClosedMul { #[inline(always)] fn dotx(&self, rhs: &Matrix, conjugate: impl Fn(N) -> N) -> N @@ -469,7 +469,7 @@ where N: Scalar + Clone + 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 + Clone + Zero + ClosedAdd + ClosedMul { +where N: Scalar + Zero + ClosedAdd + ClosedMul { for i in 0..len { unsafe { let y = y.get_unchecked_mut(i * stride1); @@ -479,7 +479,7 @@ where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul { } fn array_axc(y: &mut [N], a: N, x: &[N], c: N, stride1: usize, stride2: usize, len: usize) -where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul { +where N: Scalar + Zero + ClosedAdd + ClosedMul { for i in 0..len { unsafe { *y.get_unchecked_mut(i * stride1) = a.inlined_clone() * x.get_unchecked(i * stride2).inlined_clone() * c.inlined_clone(); @@ -489,7 +489,7 @@ where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul { impl Vector where - N: Scalar + Clone + Zero + ClosedAdd + ClosedMul, + N: Scalar + Zero + ClosedAdd + ClosedMul, S: StorageMut, { /// Computes `self = a * x * c + b * self`. @@ -886,7 +886,7 @@ where } impl> Matrix -where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul +where N: Scalar + Zero + ClosedAdd + ClosedMul { #[inline(always)] fn gerx( @@ -1249,7 +1249,7 @@ where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul } impl> Matrix -where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul +where N: Scalar + Zero + ClosedAdd + ClosedMul { #[inline(always)] fn xxgerx( @@ -1396,7 +1396,7 @@ where N: Scalar + Clone + Zero + ClosedAdd + ClosedMul } impl> SquareMatrix -where N: Scalar + Clone + Zero + One + ClosedAdd + ClosedMul +where N: Scalar + 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 262ffecf..df3906ae 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -23,7 +23,7 @@ use alga::linear::Transformation; impl MatrixN where - N: Scalar + Clone + Ring, + N: Scalar + 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> 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 96f5d12a..c4ce1293 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 6925351d..f6056576 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 + Clone, + N: Scalar, 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 + Clone + Zero + ClosedAdd, + N: Scalar + Zero + ClosedAdd, DefaultAllocator: Allocator, { #[inline] @@ -737,7 +737,7 @@ where impl One for MatrixN where - N: Scalar + Clone + Zero + One + ClosedMul + ClosedAdd, + N: Scalar + Zero + One + ClosedMul + ClosedAdd, DefaultAllocator: Allocator, { #[inline] @@ -748,7 +748,7 @@ where impl Bounded for MatrixMN where - N: Scalar + Clone + Bounded, + N: Scalar + Bounded, DefaultAllocator: Allocator, { #[inline] @@ -762,7 +762,7 @@ where } } -impl Distribution> for Standard +impl Distribution> for Standard where DefaultAllocator: Allocator, Standard: Distribution, @@ -781,7 +781,7 @@ impl Arbitrary for MatrixMN where R: Dim, C: Dim, - N: Scalar + Clone + Arbitrary + Send, + N: Scalar + Arbitrary + Send, DefaultAllocator: Allocator, Owned: Clone + Send, { @@ -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 + Clone, + where N: Scalar, DefaultAllocator: Allocator { /// Initializes this matrix from its components. #[inline] @@ -990,7 +990,7 @@ componentwise_constructors_impl!( */ impl VectorN where - N: Scalar + Clone + Zero + One, + N: Scalar + 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 0e1d28f8..4f745a65 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> +impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> +impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> { +impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> { } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim> MatrixSliceMutMN<'a, N, R, C> { +impl<'a, N: Scalar, 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 + Clone, 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 + Clone, $($DimIdent: $DimBound),*> MatrixSliceMN<'a, N, $($Dims),*> { + impl<'a, N: Scalar, $($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 + Clone, $($DimIdent: $DimBound, )*> MatrixSliceMN<'a, N, $($Dims,)* Dynamic, Dynamic> { + impl<'a, N: Scalar, $($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 + Clone, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, N, $($Dims),*> { + impl<'a, N: Scalar, $($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 + Clone, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, N, $($Dims,)* Dynamic, Dynamic> { + impl<'a, N: Scalar, $($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 4b937556..7763a086 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -31,8 +31,8 @@ where C1: Dim, R2: Dim, C2: Dim, - N1: Scalar + Clone, - N2: Scalar + Clone + SupersetOf, + N1: Scalar, + N2: Scalar + SupersetOf, DefaultAllocator: Allocator + Allocator + SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, @@ -75,7 +75,7 @@ where } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: Storage> IntoIterator for &'a Matrix { +impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, S: Storage> IntoIterator fo } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: StorageMut> IntoIterator +impl<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> IntoIterator for &'a mut Matrix { type Item = &'a mut N; @@ -100,7 +100,7 @@ impl<'a, N: Scalar + Clone, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + where N: Scalar, 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 + Clone, + N: Scalar, R: DimName, C: DimName, RStride: Dim, @@ -359,7 +359,7 @@ where impl<'a, N, C, RStride, CStride> From> for Matrix> where - N: Scalar + Clone, + N: Scalar, C: Dim, RStride: Dim, CStride: Dim, @@ -373,7 +373,7 @@ where impl<'a, N, R, RStride, CStride> From> for Matrix> where - N: Scalar + Clone, + N: Scalar, R: DimName, RStride: Dim, CStride: Dim, @@ -386,7 +386,7 @@ where impl<'a, N, R, C, RStride, CStride> From> for Matrix> where - N: Scalar + Clone, + N: Scalar, R: DimName, C: DimName, RStride: Dim, @@ -403,7 +403,7 @@ where impl<'a, N, C, RStride, CStride> From> for Matrix> where - N: Scalar + Clone, + N: Scalar, C: Dim, RStride: Dim, CStride: Dim, @@ -417,7 +417,7 @@ where impl<'a, N, R, RStride, CStride> From> for Matrix> where - N: Scalar + Clone, + N: Scalar, 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 + Clone, + N: Scalar, 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 + Clone, + N: Scalar, 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 + Clone, + N: Scalar, R: Dim, C: Dim, RSlice: Dim, diff --git a/src/base/coordinates.rs b/src/base/coordinates.rs index ee6ccf91..832723e3 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 4413de27..c07c8708 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 + Clone, + N: Scalar, 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 DefaultAllocato * */ // 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 19937e3f..b84a6110 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> 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> 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 + Clone, + N: Scalar, R: Dim, S: Extend, { @@ -986,7 +986,7 @@ where #[cfg(any(feature = "std", feature = "alloc"))] impl Extend for Matrix where - N: Scalar + Clone, + N: Scalar, 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 + Clone, + N: Scalar, R: Dim, S: Extend>, RV: Dim, diff --git a/src/base/indexing.rs b/src/base/indexing.rs index 35b4a9ff..ca786530 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 + Clone, R: Dim, C: Dim, S: Storage>: Sized { +pub trait MatrixIndex<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, S: Storage } /// A helper trait used for indexing operations. -pub trait MatrixIndexMut<'a, N: Scalar + Clone, R: Dim, C: Dim, S: StorageMut>: MatrixIndex<'a, N, R, C, S> { +pub trait MatrixIndexMut<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, S: StorageMut> 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 + Clone, + N: Scalar, 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 + Clone, + N: Scalar, 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 + Clone, + N: Scalar, 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 + Clone, + N: Scalar, 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 + Clone, + N: Scalar, $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 + Clone, + N: Scalar, $R: Dim, $C: Dim, S: StorageMut, diff --git a/src/base/iter.rs b/src/base/iter.rs index 1032cd2a..65cdb20a 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 + Clone, R: Dim, C: Dim, S: 'a + $Storage> { + pub struct $Name<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, S: 'a + $Storage> $Name<'a, N, R, C, S> { + impl<'a, N: Scalar, 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(); @@ -58,7 +58,7 @@ macro_rules! iterator { } } - impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + $Storage> Iterator + impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + $Storage> Iterator for $Name<'a, N, R, C, S> { type Item = $Ref; @@ -111,7 +111,7 @@ macro_rules! iterator { } } - impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + $Storage> ExactSizeIterator + impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + $Storage> ExactSizeIterator for $Name<'a, N, R, C, S> { #[inline] @@ -133,12 +133,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 + Clone, R: Dim, C: Dim, S: Storage> { +pub struct RowIter<'a, N: Scalar, R: Dim, C: Dim, S: Storage> { mat: &'a Matrix, curr: usize } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> RowIter<'a, N, R, C, S> { +impl<'a, N: Scalar, 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 @@ -147,7 +147,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> RowIter<'a } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> Iterator for RowIter<'a, N, R, C, S> { +impl<'a, N: Scalar, 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] @@ -172,7 +172,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> Iterator f } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator for RowIter<'a, N, R, C, S> { +impl<'a, N: Scalar, 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 @@ -181,13 +181,13 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> ExactSizeI /// An iterator through the mutable rows of a matrix. -pub struct RowIterMut<'a, N: Scalar + Clone, R: Dim, C: Dim, S: StorageMut> { +pub struct RowIterMut<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> { mat: *mut Matrix, curr: usize, phantom: PhantomData<&'a mut Matrix> } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> RowIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> RowIterMut<'a, N, R, C, S> { pub(crate) fn new(mat: &'a mut Matrix) -> Self { RowIterMut { mat, @@ -204,7 +204,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> RowIter } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for RowIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar, 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] @@ -229,7 +229,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> Iterato } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterator for RowIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterator for RowIterMut<'a, N, R, C, S> { #[inline] fn len(&self) -> usize { self.nrows() - self.curr @@ -244,12 +244,12 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> ExactSi */ #[derive(Clone)] /// An iterator through the columns of a matrix. -pub struct ColumnIter<'a, N: Scalar + Clone, R: Dim, C: Dim, S: Storage> { +pub struct ColumnIter<'a, N: Scalar, R: Dim, C: Dim, S: Storage> { mat: &'a Matrix, curr: usize } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> ColumnIter<'a, N, R, C, S> { +impl<'a, N: Scalar, 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 @@ -258,7 +258,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> ColumnIter } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> Iterator for ColumnIter<'a, N, R, C, S> { +impl<'a, N: Scalar, 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] @@ -283,7 +283,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> Iterator f } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> ExactSizeIterator for ColumnIter<'a, N, R, C, S> { +impl<'a, N: Scalar, 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 @@ -292,13 +292,13 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + Storage> ExactSizeI /// An iterator through the mutable columns of a matrix. -pub struct ColumnIterMut<'a, N: Scalar + Clone, R: Dim, C: Dim, S: StorageMut> { +pub struct ColumnIterMut<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> { mat: *mut Matrix, curr: usize, phantom: PhantomData<&'a mut Matrix> } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> ColumnIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar, R: Dim, C: Dim, S: 'a + StorageMut> ColumnIterMut<'a, N, R, C, S> { pub(crate) fn new(mat: &'a mut Matrix) -> Self { ColumnIterMut { mat, @@ -315,7 +315,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> ColumnI } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> Iterator for ColumnIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar, 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] @@ -340,7 +340,7 @@ impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> Iterato } } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, S: 'a + StorageMut> ExactSizeIterator for ColumnIterMut<'a, N, R, C, S> { +impl<'a, N: Scalar, 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 7682f955..f3b9c044 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 Serialize for Matrix where - N: Scalar + Clone, + N: Scalar, 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 + Clone, + N: Scalar, 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 + Clone, - N3: Scalar + Clone, + N2: Scalar, + N3: Scalar, S2: Storage, F: FnMut(N, N2) -> N3, DefaultAllocator: Allocator, @@ -500,9 +500,9 @@ impl> Matrix mut f: F, ) -> MatrixMN where - N2: Scalar + Clone, - N3: Scalar + Clone, - N4: Scalar + Clone, + N2: Scalar, + N3: Scalar, + N4: Scalar, 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 + Clone, + N2: Scalar, 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(&mut self, rhs: &Matrix, mut f: impl FnMut(N, N2) -> N) - where N2: Scalar + Clone, + where N2: Scalar, R2: Dim, C2: Dim, S2: Storage, @@ -825,11 +825,11 @@ impl> Matrix(&mut self, b: &Matrix, c: &Matrix, mut f: impl FnMut(N, N2, N3) -> N) - where N2: Scalar + Clone, + where N2: Scalar, R2: Dim, C2: Dim, S2: Storage, - N3: Scalar + Clone, + N3: Scalar, R3: Dim, C3: Dim, S3: Storage, @@ -859,7 +859,7 @@ impl> Matrix> 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 } } -impl> 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 + Clone + AbsDiffEq, + N: Scalar + AbsDiffEq, S: Storage, N::Epsilon: Copy, { @@ -1209,7 +1209,7 @@ where impl RelativeEq for Matrix where - N: Scalar + Clone + RelativeEq, + N: Scalar + RelativeEq, S: Storage, N::Epsilon: Copy, { @@ -1232,7 +1232,7 @@ where impl UlpsEq for Matrix where - N: Scalar + Clone + UlpsEq, + N: Scalar + UlpsEq, S: Storage, N::Epsilon: Copy, { @@ -1252,7 +1252,7 @@ where impl PartialOrd for Matrix where - N: Scalar + Clone + PartialOrd, + N: Scalar + PartialOrd, S: Storage, { #[inline] @@ -1340,13 +1340,13 @@ where impl Eq for Matrix where - N: Scalar + Clone + Eq, + N: Scalar + Eq, S: Storage, {} impl PartialEq for Matrix where - N: Scalar + Clone, + N: Scalar, 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 + Clone + $trait, + N: Scalar + $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> 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 + Clone + AbsDiffEq, + N: Scalar + AbsDiffEq, S: Storage, N::Epsilon: Copy, { @@ -1702,7 +1702,7 @@ where impl RelativeEq for Unit> where - N: Scalar + Clone + RelativeEq, + N: Scalar + RelativeEq, S: Storage, N::Epsilon: Copy, { @@ -1726,7 +1726,7 @@ where impl UlpsEq for Unit> where - N: Scalar + Clone + UlpsEq, + N: Scalar + UlpsEq, S: Storage, N::Epsilon: Copy, { @@ -1743,7 +1743,7 @@ where impl Hash for Matrix where - N: Scalar + Clone + Hash, + N: Scalar + Hash, R: Dim, C: Dim, S: Storage, diff --git a/src/base/matrix_alga.rs b/src/base/matrix_alga.rs index b275ce2e..ac6aced7 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 + Clone + Zero, + N: Scalar + Zero, DefaultAllocator: Allocator, { #[inline] @@ -36,7 +36,7 @@ where impl AbstractMagma for MatrixMN where - N: Scalar + Clone + ClosedAdd, + N: Scalar + ClosedAdd, DefaultAllocator: Allocator, { #[inline] @@ -47,7 +47,7 @@ where impl TwoSidedInverse for MatrixMN where - N: Scalar + Clone + ClosedNeg, + N: Scalar + 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 + Clone + $marker<$operator> $(+ $bounds)*, + where N: Scalar + $marker<$operator> $(+ $bounds)*, DefaultAllocator: Allocator { } )*} ); @@ -80,7 +80,7 @@ inherit_additive_structure!( impl AbstractModule for MatrixMN where - N: Scalar + Clone + RingCommutative, + N: Scalar + RingCommutative, DefaultAllocator: Allocator, { type AbstractRing = N; @@ -93,7 +93,7 @@ where impl Module for MatrixMN where - N: Scalar + Clone + RingCommutative, + N: Scalar + RingCommutative, DefaultAllocator: Allocator, { type Ring = N; @@ -101,7 +101,7 @@ where impl VectorSpace for MatrixMN where - N: Scalar + Clone + Field, + N: Scalar + Field, DefaultAllocator: Allocator, { type Field = N; @@ -109,7 +109,7 @@ where impl FiniteDimVectorSpace for MatrixMN where - N: Scalar + Clone + Field, + N: Scalar + Field, DefaultAllocator: Allocator, { #[inline] @@ -329,7 +329,7 @@ where DefaultAllocator: Allocator */ impl Identity for MatrixN where - N: Scalar + Clone + Zero + One, + N: Scalar + Zero + One, DefaultAllocator: Allocator, { #[inline] @@ -340,7 +340,7 @@ where impl AbstractMagma for MatrixN where - N: Scalar + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + 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 + Clone + Zero + One + ClosedAdd + ClosedMul + $marker<$operator> $(+ $bounds)*, + where N: Scalar + Zero + One + ClosedAdd + ClosedMul + $marker<$operator> $(+ $bounds)*, DefaultAllocator: Allocator { } )*} ); @@ -369,7 +369,7 @@ impl_multiplicative_structure!( */ impl MeetSemilattice for MatrixMN where - N: Scalar + Clone + MeetSemilattice, + N: Scalar + MeetSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -380,7 +380,7 @@ where impl JoinSemilattice for MatrixMN where - N: Scalar + Clone + JoinSemilattice, + N: Scalar + JoinSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -391,7 +391,7 @@ where impl Lattice for MatrixMN where - N: Scalar + Clone + Lattice, + N: Scalar + Lattice, DefaultAllocator: Allocator, { #[inline] diff --git a/src/base/matrix_slice.rs b/src/base/matrix_slice.rs index 1ab3d487..be53034a 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> { + pub struct $T<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> { ptr: $Ptr, shape: (R, C), strides: (RStride, CStride), _phantoms: PhantomData<$Ref>, } - unsafe impl<'a, N: Scalar + Clone + Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send + unsafe impl<'a, N: Scalar + Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send for $T<'a, N, R, C, RStride, CStride> {} - unsafe impl<'a, N: Scalar + Clone + Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync + unsafe impl<'a, N: Scalar + Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync for $T<'a, N, R, C, RStride, CStride> {} - impl<'a, N: Scalar + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> $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> { /// 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 + Clone, R: Dim, C: Dim> $T<'a, N, R, C, Dynamic, Dynamic> { + impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy +impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy for SliceStorage<'a, N, R, C, RStride, CStride> { } -impl<'a, N: Scalar + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone +impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone macro_rules! storage_impl( ($($T: ident),* $(,)*) => {$( - unsafe impl<'a, N: Scalar + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage + unsafe impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> StorageMut +unsafe impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim, RStride: Dim, CStride: Dim> S } } -unsafe impl<'a, N: Scalar + Clone, R: Dim, CStride: Dim> ContiguousStorage for SliceStorage<'a, N, R, U1, U1, CStride> { } -unsafe impl<'a, N: Scalar + Clone, R: Dim, CStride: Dim> ContiguousStorage for SliceStorageMut<'a, N, R, U1, U1, CStride> { } -unsafe impl<'a, N: Scalar + Clone, R: Dim, CStride: Dim> ContiguousStorageMut for SliceStorageMut<'a, N, R, U1, U1, CStride> { } +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 + Clone, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorage for SliceStorage<'a, N, R, C, U1, R> { } -unsafe impl<'a, N: Scalar + Clone, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorage for SliceStorageMut<'a, N, R, C, U1, R> { } -unsafe impl<'a, N: Scalar + Clone, R: DimName, C: Dim + IsNotStaticOne> ContiguousStorageMut for SliceStorageMut<'a, N, R, C, U1, R> { } +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> { } -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 From> for MatrixSlice<'a, N, R, C, RStride, CStride> where - N: Scalar + Clone, + N: Scalar, R: Dim, C: Dim, RStride: Dim, diff --git a/src/base/ops.rs b/src/base/ops.rs index 9f785daa..b20cc74f 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 Ma impl Index<(usize, usize)> for Matrix where - N: Scalar + Clone, + N: Scalar, 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 impl IndexMut<(usize, usize)> for Matrix where - N: Scalar + Clone, + N: Scalar, S: StorageMut, { #[inline] @@ -82,7 +82,7 @@ where */ impl Neg for Matrix where - N: Scalar + Clone + ClosedNeg, + N: Scalar + 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 + Clone + ClosedNeg, + N: Scalar + ClosedNeg, S: Storage, DefaultAllocator: Allocator, { @@ -112,7 +112,7 @@ where impl Matrix where - N: Scalar + Clone + ClosedNeg, + N: Scalar + 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 + Clone + $bound { + where N: Scalar + $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 + Clone + $bound, + N: Scalar + $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 + Clone + $bound, + N: Scalar + $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 + Clone + $bound, + N: Scalar + $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 + Clone + $bound, + N: Scalar + $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 + Clone + $bound, + N: Scalar + $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 + Clone + $bound, + N: Scalar + $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 + Clone + ClosedAdd + Zero, + N: Scalar + ClosedAdd + Zero, DefaultAllocator: Allocator, { fn sum>>(iter: I) -> MatrixMN { @@ -386,7 +386,7 @@ where impl iter::Sum for MatrixMN where - N: Scalar + Clone + ClosedAdd + Zero, + N: Scalar + 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 + Clone + ClosedAdd + Zero, + N: Scalar + 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 + Clone + ClosedAdd + Zero, + N: Scalar + 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 + Clone + $bound, + where N: Scalar + $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 + Clone + $bound, + where N: Scalar + $bound, S: Storage, DefaultAllocator: Allocator { type Output = MatrixMN; @@ -502,7 +502,7 @@ macro_rules! componentwise_scalarop_impl( } impl $TraitAssign for Matrix - where N: Scalar + Clone + $bound, + where N: Scalar + $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 + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + 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 + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + 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 + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -616,7 +616,7 @@ where impl Mul> for Matrix where - N: Scalar + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -638,7 +638,7 @@ where R1: Dim, C1: Dim, R2: Dim, - N: Scalar + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: ContiguousStorageMut + Clone, ShapeConstraint: AreMultipliable, @@ -655,7 +655,7 @@ where R1: Dim, C1: Dim, R2: Dim, - N: Scalar + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: ContiguousStorageMut + Clone, ShapeConstraint: AreMultipliable, @@ -671,7 +671,7 @@ where // Transpose-multiplication. impl Matrix where - N: Scalar + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + 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< impl iter::Product for MatrixN where - N: Scalar + Clone + Zero + One + ClosedMul + ClosedAdd, + N: Scalar + 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 + Clone + Zero + One + ClosedMul + ClosedAdd, + N: Scalar + 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 74ddf8cf..8ca49568 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 070dc0a7..a8008ddf 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: PartialEq + Debug + Any { +pub trait Scalar: Clone + PartialEq + Debug + Any { #[inline] /// Tests if `Self` the same as the type `T` /// @@ -16,9 +16,9 @@ pub trait Scalar: PartialEq + Debug + Any { #[inline(always)] /// Performance hack: Clone doesn't get inlined for Copy types in debug mode, so make it inline anyway. - /// - /// Downstream crates need to implement this on any Clone Scalars, as a blanket impl would conflict with with the blanket Copy impl. - fn inlined_clone(&self) -> Self; + fn inlined_clone(&self) -> Self { + self.clone() + } } impl Scalar for T { diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 8a355c87..cb597f31 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 f1b0177b..e7439552 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: +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 ec33f8da..02e48834 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 ffb1ac0c..e0c092fb 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 + Clone, + N: Scalar, R: Dim, RV: Dim, SV: Storage, diff --git a/src/debug/random_orthogonal.rs b/src/debug/random_orthogonal.rs index 8b9321f2..421b041a 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 503d8689..47e3ca60 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 2b12a8c9..382afe06 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 + Clone + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, + where N: Scalar + 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 + Clone + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, + where N: Scalar + 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 + Clone + $bound, + where N: Scalar + $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 + Clone + $bound, + where N: Scalar + $bound, DefaultAllocator: Allocator + Allocator, ShapeConstraint: SameNumberOfRows<$R1, $R2> + SameNumberOfColumns<$C1, $C2> { diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index ec4575fa..8020c0cf 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 6911db78..bc1b138a 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, @@ -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 + Clone, D: DimName> Deserialize<'a> for Point +impl<'a, N: Scalar, 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 + Clone, + N: Scalar, 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 b5ae46b8..162e6c68 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 + Clone + Field, + N: Scalar + Field, DefaultAllocator: Allocator, { type Translation = VectorN; @@ -49,7 +49,7 @@ where DefaultAllocator: Allocator */ impl MeetSemilattice for Point where - N: Scalar + Clone + MeetSemilattice, + N: Scalar + MeetSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -60,7 +60,7 @@ where impl JoinSemilattice for Point where - N: Scalar + Clone + JoinSemilattice, + N: Scalar + JoinSemilattice, DefaultAllocator: Allocator, { #[inline] @@ -71,7 +71,7 @@ where impl Lattice for Point where - N: Scalar + Clone + Lattice, + N: Scalar + Lattice, DefaultAllocator: Allocator, { #[inline] diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 5ba9bc2e..e5d2ee44 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 + Clone + Zero + One + ClosedDiv, + N: Scalar + 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, @@ -138,7 +138,7 @@ where } #[cfg(feature = "arbitrary")] -impl Arbitrary for Point +impl Arbitrary for Point where DefaultAllocator: Allocator, >::Buffer: Send, @@ -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 d2c5a8c0..4f32d840 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 + Clone, - N2: Scalar + Clone + SupersetOf, + N1: Scalar, + N2: Scalar + SupersetOf, DefaultAllocator: Allocator + Allocator, { #[inline] @@ -52,8 +52,8 @@ where impl SubsetOf>> for Point where D: DimNameAdd, - N1: Scalar + Clone, - N2: Scalar + Clone + Zero + One + ClosedDiv + SupersetOf, + N1: Scalar, + N2: Scalar + 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 + Clone { + where N: Scalar { #[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 + Clone { + where N: Scalar { #[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 + Clone { + where N: Scalar { #[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 + Clone { + where N: Scalar { #[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 0ccc9441..b56e120e 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 4f08f526..648a71a6 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 + Clone + ClosedNeg, D: DimName> Neg for &'a Point +impl<'a, N: Scalar + 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 + Clone + $bound, + where N: Scalar + $bound, SB: Storage, DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows { @@ -150,7 +150,7 @@ macro_rules! op_assign_impl( } impl $TraitAssign> for Point - where N: Scalar + Clone + $bound, + where N: Scalar + $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 + Clone + $bound, D: DimName> $Trait for &'a Point + impl<'a, N: Scalar + $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 585fe57b..b4658a11 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 9ee8511a..afbeeb3f 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, @@ -47,7 +47,7 @@ where { } -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 + Clone, + N: Scalar, 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 + Clone, D: DimName> Deserialize<'a> for Rotation +impl<'a, N: Scalar, 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 + Clone + AbsDiffEq, + N: Scalar + AbsDiffEq, DefaultAllocator: Allocator, N::Epsilon: Copy, { @@ -464,7 +464,7 @@ where impl RelativeEq for Rotation where - N: Scalar + Clone + RelativeEq, + N: Scalar + RelativeEq, DefaultAllocator: Allocator, N::Epsilon: Copy, { @@ -488,7 +488,7 @@ where impl UlpsEq for Rotation where - N: Scalar + Clone + UlpsEq, + N: Scalar + UlpsEq, DefaultAllocator: Allocator, N::Epsilon: Copy, { diff --git a/src/geometry/rotation_construction.rs b/src/geometry/rotation_construction.rs index 514ed439..a7779cc6 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 + Clone + Zero + One, + N: Scalar + 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 + Clone + Zero + One + ClosedAdd + ClosedMul, + N: Scalar + Zero + One + ClosedAdd + ClosedMul, DefaultAllocator: Allocator, { #[inline] diff --git a/src/geometry/rotation_ops.rs b/src/geometry/rotation_ops.rs index 553d8c62..ed555b6b 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 149bcf02..9ec6b2e5 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 1540da09..79c1ad8b 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, @@ -47,7 +47,7 @@ where 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 + Clone, + N: Scalar, 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 + Clone, D: DimName> Deserialize<'a> for Translation +impl<'a, N: Scalar, 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 7ac3c5fc..339bdd2a 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, @@ -59,7 +59,7 @@ where } #[cfg(feature = "arbitrary")] -impl Arbitrary for Translation +impl Arbitrary for Translation where DefaultAllocator: Allocator, Owned: Send, @@ -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 ee2f0e6d..b44412e6 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 + Clone, - N2: Scalar + Clone + SupersetOf, + N1: Scalar, + N2: Scalar + 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 10e5926f..c422415c 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 42cea3ad..521df894 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 + Clone + Field, + N: Scalar + 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 + Clone + Field, + N: Scalar + Field, S: StorageMut, { let piv = piv - i; diff --git a/src/linalg/permutation_sequence.rs b/src/linalg/permutation_sequence.rs index a7d2e8aa..ce493905 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 9cc6b51b..9fc91af0 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 + Clone, R: Dim, C: Dim> CsStorageIter<'a, N, R, C> for CsVecStorage +impl<'a, N: Scalar, 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 + Clone, R: Dim, C: Dim> CsStorageIterMut<'a, N, R, C> for CsVecStorage +impl<'a, N: Scalar, 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 + Clone, R: Dim, C: DimAdd> { +pub struct CsSliceStorage<'a, N: Scalar, R: Dim, C: DimAdd> { shape: (R, C), p: VectorSlice>, i: VectorSlice, @@ -234,7 +234,7 @@ pub struct CsSliceStorage<'a, N: Scalar + Clone, R: Dim, C: DimAdd> { /// A compressed sparse column matrix. #[derive(Clone, Debug, PartialEq)] pub struct CsMatrix< - N: Scalar + Clone, + N: Scalar, 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> 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 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 0844f22c..abf195e2 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 + Clone + Zero + ClosedAdd> CsMatrix { +impl<'a, N: Scalar + 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 + Clone + Zero + ClosedAdd> CsMatrix { } } -impl<'a, N: Scalar + Clone + Zero + ClosedAdd, R: Dim, C: Dim> CsMatrix +impl<'a, N: Scalar + 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 + Clone + Zero, R: Dim, C: Dim, S> From> for MatrixMN +impl<'a, N: Scalar + Zero, R: Dim, C: Dim, S> From> for MatrixMN where S: CsStorage, DefaultAllocator: Allocator, @@ -85,7 +85,7 @@ where } } -impl<'a, N: Scalar + Clone + Zero, R: Dim, C: Dim, S> From> for CsMatrix +impl<'a, N: Scalar + 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 e602fec6..8a4c063a 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 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 Mul<&'b CsMatrix> for &'a CsMatrix where - N: Scalar + Clone + ClosedAdd + ClosedMul + Zero, + N: Scalar + 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 + Clone + ClosedAdd + ClosedMul + One, + N: Scalar + 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 + Clone + ClosedAdd + ClosedMul + Zero, + N: Scalar + ClosedAdd + ClosedMul + Zero, R: Dim, C: Dim, S: CsStorageMut,