From 22b657f566e745e7bc31ad92e08647e6f5859043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Violeta=20Hern=C3=A1ndez?= Date: Mon, 19 Jul 2021 18:00:40 -0500 Subject: [PATCH] First draft of `Owned` overhaul --- src/base/alias.rs | 15 +- src/base/allocator.rs | 2 + src/base/array_storage.rs | 11 +- src/base/construction.rs | 4 +- src/base/default_allocator.rs | 199 +++++++++++++++++++++-- src/base/dimension.rs | 16 +- src/base/edition.rs | 6 +- src/base/matrix.rs | 12 +- src/base/matrix_slice.rs | 6 +- src/base/ops.rs | 4 +- src/base/storage.rs | 3 +- src/base/unit.rs | 10 +- src/base/vec_storage.rs | 28 ++-- src/debug/random_orthogonal.rs | 4 +- src/debug/random_sdp.rs | 3 +- src/geometry/isometry.rs | 6 +- src/geometry/isometry_construction.rs | 4 +- src/geometry/point.rs | 6 +- src/geometry/point_construction.rs | 2 +- src/geometry/quaternion.rs | 2 +- src/geometry/quaternion_construction.rs | 8 +- src/geometry/rotation.rs | 14 +- src/geometry/rotation_specialization.rs | 8 +- src/geometry/similarity.rs | 6 +- src/geometry/similarity_construction.rs | 4 +- src/geometry/transform.rs | 18 +- src/geometry/transform_ops.rs | 4 +- src/geometry/translation.rs | 10 +- src/geometry/translation_construction.rs | 4 +- src/linalg/bidiagonal.rs | 22 +-- src/linalg/cholesky.rs | 10 +- src/linalg/exp.rs | 4 +- src/linalg/hessenberg.rs | 18 +- src/linalg/lu.rs | 10 +- src/linalg/permutation_sequence.rs | 4 +- src/linalg/qr.rs | 16 +- src/linalg/schur.rs | 14 +- src/linalg/svd.rs | 24 +-- src/linalg/symmetric_eigen.rs | 20 +-- src/linalg/symmetric_tridiagonal.rs | 18 +- src/linalg/udu.rs | 18 +- 41 files changed, 392 insertions(+), 205 deletions(-) diff --git a/src/base/alias.rs b/src/base/alias.rs index a1e82ac0..f12fb383 100644 --- a/src/base/alias.rs +++ b/src/base/alias.rs @@ -1,11 +1,10 @@ - #[cfg(any(feature = "alloc", feature = "std"))] use crate::base::dimension::Dynamic; use crate::base::dimension::{U1, U2, U3, U4, U5, U6}; -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(any(feature = "std", feature = "alloc"))] use crate::base::vec_storage::VecStorage; -use crate::base::{ArrayStorage, Const, Matrix, Unit}; +use crate::base::{ArrayStorage, Const, Matrix, Owned, Unit}; /* * @@ -26,13 +25,13 @@ pub type OMatrix = Matrix>; #[deprecated( note = "use SMatrix for a statically-sized matrix using integer dimensions, or OMatrix for an owned matrix using types as dimensions." )] -pub type MatrixMN = Matrix>; +pub type MatrixMN = OMatrix; /// An owned matrix column-major matrix with `D` columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[deprecated(note = "use OMatrix or SMatrix instead.")] -pub type MatrixN = Matrix>; +pub type MatrixN = Matrix>; /// A statically sized column-major matrix with `R` rows and `C` columns. /// @@ -275,7 +274,7 @@ pub type Matrix6x5 = Matrix>; pub type DVector = Matrix>; /// An owned D-dimensional column vector. -pub type OVector = Matrix>; +pub type OVector = Matrix>; /// A statically sized D-dimensional column vector. pub type SVector = Matrix, U1, ArrayStorage>; // Owned, U1>>; @@ -285,7 +284,7 @@ pub type SVector = Matrix, U1, ArrayStorage = Matrix>; +pub type VectorN = Matrix>; /// A stack-allocated, 1-dimensional column vector. pub type Vector1 = Matrix>; @@ -312,7 +311,7 @@ pub type Vector6 = Matrix>; pub type RowDVector = Matrix>; /// An owned D-dimensional row vector. -pub type RowOVector = Matrix>; +pub type RowOVector = Matrix>; /// A statically sized D-dimensional row vector. pub type RowSVector = Matrix, ArrayStorage>; diff --git a/src/base/allocator.rs b/src/base/allocator.rs index 26ea11bc..1f639d3d 100644 --- a/src/base/allocator.rs +++ b/src/base/allocator.rs @@ -59,6 +59,7 @@ pub trait Allocator: ) -> , R, C>>::Buffer; } + /// 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: @@ -68,6 +69,7 @@ pub trait Reallocator: /// `buf`. Data stored by `buf` are linearly copied to the output: /// /// # Safety + /// **NO! THIS IS STILL UB!** /// * The copy is performed as if both were just arrays (without a matrix structure). /// * If `buf` is larger than the output size, then extra elements of `buf` are truncated. /// * If `buf` is smaller than the output size, then extra elements of the output are left diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index ccc676c2..bf8ef17b 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -21,8 +21,9 @@ use crate::allocator::InnerAllocator; use crate::base::default_allocator::DefaultAllocator; use crate::base::dimension::{Const, ToTypenum}; use crate::base::storage::{ - ContiguousStorage, ContiguousStorageMut, Owned, ReshapableStorage, Storage, StorageMut, + ContiguousStorage, ContiguousStorageMut, ReshapableStorage, Storage, StorageMut, }; +use crate::base::Owned; /* * @@ -85,7 +86,7 @@ where where DefaultAllocator: InnerAllocator, Const>, { - self + Owned(self) } #[inline] @@ -95,7 +96,11 @@ where DefaultAllocator: InnerAllocator, Const>, { let it = self.as_slice().iter().cloned(); - DefaultAllocator::allocate_from_iterator(self.shape().0, self.shape().1, it) + Owned(DefaultAllocator::allocate_from_iterator( + self.shape().0, + self.shape().1, + it, + )) } #[inline] diff --git a/src/base/construction.rs b/src/base/construction.rs index c45798c2..801c3b2d 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -2,7 +2,7 @@ use alloc::vec::Vec; #[cfg(feature = "arbitrary")] -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -898,7 +898,7 @@ impl Arbitrary for OMatrix where T: Arbitrary + Send, DefaultAllocator: Allocator, - Owned: Clone + Send, + InnerOwned: Clone + Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index 269ef447..cce4d848 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -4,22 +4,25 @@ //! heap-allocated buffers for matrices with at least one dimension unknown at compile-time. use std::cmp; -use std::mem::{ManuallyDrop, MaybeUninit}; +use std::fmt; +use std::mem::{self, ManuallyDrop, MaybeUninit}; use std::ptr; #[cfg(all(feature = "alloc", not(feature = "std")))] use alloc::vec::Vec; +#[cfg(any(feature = "alloc", feature = "std"))] +use crate::base::dimension::Dynamic; + use super::Const; use crate::base::allocator::{Allocator, InnerAllocator, Reallocator}; use crate::base::array_storage::ArrayStorage; -#[cfg(any(feature = "alloc", feature = "std"))] -use crate::base::dimension::Dynamic; use crate::base::dimension::{Dim, DimName}; -use crate::base::storage::{ContiguousStorageMut, Storage, StorageMut}; -#[cfg(any(feature = "std", feature = "alloc"))] +use crate::base::storage::{ + ContiguousStorage, ContiguousStorageMut, InnerOwned, Storage, StorageMut, +}; use crate::base::vec_storage::VecStorage; -use crate::storage::Owned; +use crate::U1; /* * @@ -66,7 +69,7 @@ impl Allocator, Const> for Def fn allocate_uninitialized( _: Const, _: Const, - ) -> Owned, Const, Const> { + ) -> InnerOwned, Const, Const> { // SAFETY: An uninitialized `[MaybeUninit<_>; _]` is valid. let array = unsafe { MaybeUninit::uninit().assume_init() }; ArrayStorage(array) @@ -75,7 +78,7 @@ impl Allocator, Const> for Def #[inline] unsafe fn assume_init( uninit: , Const, Const>>::Buffer, - ) -> Owned, Const> { + ) -> InnerOwned, Const> { // Safety: // * The caller guarantees that all elements of the array are initialized // * `MaybeUninit` and T are guaranteed to have the same layout @@ -120,7 +123,7 @@ impl InnerAllocator for DefaultAllocator { impl Allocator for DefaultAllocator { #[inline] - fn allocate_uninitialized(nrows: Dynamic, ncols: C) -> Owned, Dynamic, C> { + fn allocate_uninitialized(nrows: Dynamic, ncols: C) -> InnerOwned, Dynamic, C> { let mut data = Vec::new(); let length = nrows.value() * ncols.value(); data.reserve_exact(length); @@ -130,7 +133,9 @@ impl Allocator for DefaultAllocator { } #[inline] - unsafe fn assume_init(uninit: Owned, Dynamic, C>) -> Owned { + unsafe fn assume_init( + uninit: InnerOwned, Dynamic, C>, + ) -> InnerOwned { // Avoids a double-drop. let (nrows, ncols) = uninit.shape(); let vec: Vec<_> = uninit.into(); @@ -173,7 +178,7 @@ impl InnerAllocator for DefaultAllocator { nrows: R, ncols: Dynamic, iter: I, - ) -> Owned { + ) -> InnerOwned { let it = iter.into_iter(); let res: Vec = it.collect(); assert!(res.len() == nrows.value() * ncols.value(), @@ -185,7 +190,7 @@ impl InnerAllocator for DefaultAllocator { impl Allocator for DefaultAllocator { #[inline] - fn allocate_uninitialized(nrows: R, ncols: Dynamic) -> Owned, R, Dynamic> { + fn allocate_uninitialized(nrows: R, ncols: Dynamic) -> InnerOwned, R, Dynamic> { let mut data = Vec::new(); let length = nrows.value() * ncols.value(); data.reserve_exact(length); @@ -195,7 +200,9 @@ impl Allocator for DefaultAllocator { } #[inline] - unsafe fn assume_init(uninit: Owned, R, Dynamic>) -> Owned { + unsafe fn assume_init( + uninit: InnerOwned, R, Dynamic>, + ) -> InnerOwned { // Avoids a double-drop. let (nrows, ncols) = uninit.shape(); let vec: Vec<_> = uninit.into(); @@ -228,6 +235,170 @@ impl Allocator for DefaultAllocator { } } +/// The owned storage type for a matrix. +#[repr(transparent)] +pub struct Owned(pub InnerOwned) +where + DefaultAllocator: Allocator; + +impl Copy for Owned +where + DefaultAllocator: Allocator, + InnerOwned: Copy, +{ +} + +impl Clone for Owned +where + DefaultAllocator: Allocator, +{ + fn clone(&self) -> Self { + if Self::is_array() { + // We first clone the data. + let slice = unsafe { self.as_slice_unchecked() }; + let vec = ManuallyDrop::new(slice.to_owned()); + + // We then transmute it back into an array and then an Owned. + unsafe { mem::transmute_copy(&*vec.as_ptr()) } + + // TODO: check that the auxiliary copy is elided. + } else { + // We first clone the data. + let clone = ManuallyDrop::new(self.as_vec_storage().clone()); + + // We then transmute it back into an Owned. + unsafe { mem::transmute_copy(&clone) } + + // TODO: check that the auxiliary copy is elided. + } + } +} + +impl fmt::Debug for Owned +where + DefaultAllocator: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if Self::is_array() { + let slice = unsafe { self.as_slice_unchecked() }; + slice.fmt(f) + } else { + self.as_vec_storage().fmt(f) + } + } +} + +impl Owned +where + DefaultAllocator: Allocator, +{ + /// Returns whether `Self` stores an [`ArrayStorage`]. + fn is_array() -> bool { + R::is_static() && C::is_static() + } + + /// Returns whether `Self` stores a [`VecStorage`]. + fn is_vec() -> bool { + !Self::is_array() + } + + /// Returns the underlying [`VecStorage`]. Does not do any sort of static + /// type checking. + /// + /// # Panics + /// This method will panic if `Self` does not contain a [`VecStorage`]. + fn as_vec_storage(&self) -> &VecStorage { + assert!(Self::is_vec()); + + // Safety: `self` is transparent and must contain a `VecStorage`. + unsafe { &*(&self as *const _ as *const _) } + } +} + +unsafe impl Storage for Owned +where + DefaultAllocator: Allocator, +{ + type RStride = U1; + + type CStride = R; + + fn ptr(&self) -> *const T { + if Self::is_array() { + &self as *const _ as *const T + } else { + self.as_vec_storage().as_vec().as_ptr() + } + } + + fn shape(&self) -> (R, C) { + if Self::is_array() { + (R::default(), C::default()) + } else { + let vec = self.as_vec_storage(); + (vec.nrows, vec.ncols) + } + } + + fn strides(&self) -> (Self::RStride, Self::CStride) { + if Self::is_array() { + (U1::name(), R::default()) + } else { + let vec = self.as_vec_storage(); + (U1::name(), vec.nrows) + } + } + + fn is_contiguous(&self) -> bool { + true + } + + unsafe fn as_slice_unchecked(&self) -> &[T] { + if Self::is_array() { + std::slice::from_raw_parts( + self.ptr(), + R::try_to_usize().unwrap() * C::try_to_usize().unwrap(), + ) + } else { + self.as_vec_storage().as_vec().as_ref() + } + } + + fn into_owned(self) -> Owned { + self + } + + fn clone_owned(&self) -> Owned + where + T: Clone, + { + self.clone() + } +} + +unsafe impl StorageMut for Owned +where + DefaultAllocator: Allocator, +{ + fn ptr_mut(&mut self) -> *mut T { + todo!() + } + + unsafe fn as_mut_slice_unchecked(&mut self) -> &mut [T] { + todo!() + } +} + +unsafe impl ContiguousStorage for Owned where + DefaultAllocator: Allocator +{ +} + +unsafe impl ContiguousStorageMut for Owned where + DefaultAllocator: Allocator +{ +} + /* * * Reallocator. @@ -243,7 +414,7 @@ where unsafe fn reallocate_copy( rto: Const, cto: Const, - buf: Owned, + buf: InnerOwned, ) -> ArrayStorage { let mut res = , Const>>::allocate_uninitialized(rto, cto); diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 22b80b2a..cfe66c87 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -12,7 +12,7 @@ use typenum::{self, Diff, Max, Maximum, Min, Minimum, Prod, Quot, Sum, Unsigned} use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Stores the dimension of dynamically-sized algebraic entities. -#[derive(Clone, Copy, Eq, PartialEq, Debug)] +#[derive(Clone, Copy, Default, Eq, PartialEq, Debug)] pub struct Dynamic { value: usize, } @@ -55,7 +55,7 @@ impl IsNotStaticOne for Dynamic {} /// Trait implemented by any type that can be used as a dimension. This includes type-level /// integers and `Dynamic` (for dimensions not known at compile-time). -pub trait Dim: 'static + Debug + Copy + PartialEq + Send + Sync { +pub trait Dim: 'static + Debug + Copy + Default + PartialEq + Send + Sync { #[inline(always)] fn is() -> bool { TypeId::of::() == TypeId::of::() @@ -65,6 +65,16 @@ pub trait Dim: 'static + Debug + Copy + PartialEq + Send + Sync { /// Dynamic`. fn try_to_usize() -> Option; + /// Returns whether `Self` has a known compile-time value. + fn is_static() -> bool { + Self::try_to_usize().is_some() + } + + /// Returns whether `Self` does not have a known compile-time value. + fn is_dynamic() -> bool { + Self::try_to_usize().is_none() + } + /// Gets the run-time value of `self`. For type-level integers, this is the same as /// `Self::try_to_usize().unwrap()`. fn value(&self) -> usize; @@ -199,7 +209,7 @@ dim_ops!( /// A wrapper around const types, which provides the capability of performing /// type-level arithmetic. This might get removed if const-generics become /// more powerful in the future. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, Hash)] pub struct Const; /// Trait implemented exclusively by type-level integers. diff --git a/src/base/edition.rs b/src/base/edition.rs index 9919cda3..94c13b09 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -812,7 +812,7 @@ impl> Matrix { let mut data = self.data.into_owned(); if new_nrows.value() == nrows { - let res = unsafe { DefaultAllocator::reallocate_copy(new_nrows, new_ncols, data) }; + let res = unsafe { DefaultAllocator::reallocate_copy(new_nrows, new_ncols, data.0) }; let mut res = Matrix::from_data(res); if new_ncols.value() > ncols { res.columns_range_mut(ncols..).fill(val); @@ -832,11 +832,11 @@ impl> Matrix { nrows - new_nrows.value(), ); res = Matrix::from_data(DefaultAllocator::reallocate_copy( - new_nrows, new_ncols, data, + new_nrows, new_ncols, data.0, )); } else { res = Matrix::from_data(DefaultAllocator::reallocate_copy( - new_nrows, new_ncols, data, + new_nrows, new_ncols, data.0, )); extend_rows( &mut res.data.as_mut_slice(), diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 887d8e6c..9bbe7261 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -153,7 +153,7 @@ pub type MatrixCross = /// dynamically-sized column vector should be represented as a `Matrix` (given /// some concrete types for `T` and a compatible data storage type `S`). #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone,Copy,Debug)] pub struct Matrix { /// The data storage that contains all the matrix components. Disappointed? /// @@ -193,12 +193,6 @@ pub struct Matrix { _phantoms: PhantomData<(T, R, C)>, } -impl fmt::Debug for Matrix { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Matrix").field("data", &self.data).finish() - } -} - impl Default for Matrix where S: Storage + Default, @@ -640,7 +634,7 @@ impl> Matrix { T: Clone, DefaultAllocator: Allocator, { - Matrix::from_data(self.data.into_owned()) + Matrix::from_data(self.data.into_owned().0) } // TODO: this could probably benefit from specialization. @@ -680,7 +674,7 @@ impl> Matrix { T: Clone, DefaultAllocator: Allocator, { - Matrix::from_data(self.data.clone_owned()) + Matrix::from_data(self.data.clone_owned().0) } /// Clones this matrix into one that owns its data. The actual type of the result depends on diff --git a/src/base/matrix_slice.rs b/src/base/matrix_slice.rs index 69d55e3f..65072e5e 100644 --- a/src/base/matrix_slice.rs +++ b/src/base/matrix_slice.rs @@ -7,8 +7,8 @@ use crate::base::allocator::{Allocator, InnerAllocator}; use crate::base::default_allocator::DefaultAllocator; use crate::base::dimension::{Const, Dim, DimName, Dynamic, IsNotStaticOne, U1}; use crate::base::iter::MatrixIter; -use crate::base::storage::{ContiguousStorage, ContiguousStorageMut, Owned, Storage, StorageMut}; -use crate::base::Matrix; +use crate::base::storage::{ContiguousStorage, ContiguousStorageMut, Storage, StorageMut}; +use crate::base::{Matrix, Owned}; macro_rules! slice_storage_impl( ($doc: expr; $Storage: ident as $SRef: ty; $T: ident.$get_addr: ident ($Ptr: ty as $Ref: ty)) => { @@ -199,7 +199,7 @@ macro_rules! storage_impl( { let (nrows, ncols) = self.shape(); let it = MatrixIter::new(self).cloned(); - DefaultAllocator::allocate_from_iterator(nrows, ncols, it) + Owned( DefaultAllocator::allocate_from_iterator(nrows, ncols, it)) } #[inline] diff --git a/src/base/ops.rs b/src/base/ops.rs index dfedb69a..dee83c98 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -16,7 +16,7 @@ use crate::base::constraint::{ use crate::base::dimension::{Dim, DimMul, DimName, DimProd, Dynamic}; use crate::base::storage::{ContiguousStorageMut, Storage, StorageMut}; use crate::base::{DefaultAllocator, Matrix, MatrixSum, OMatrix, Scalar, VectorSlice}; -use crate::storage::Owned; +use crate::storage::InnerOwned; use crate::{MatrixSliceMut, SimdComplexField}; /* @@ -436,7 +436,7 @@ where // TODO: we should take out this trait bound, as T: Clone should suffice. // The brute way to do it would be how it was already done: by adding this // trait bound on the associated type itself. - Owned: Clone, + InnerOwned: Clone, { /// # Example /// ``` diff --git a/src/base/storage.rs b/src/base/storage.rs index 518fbf71..24fc14f5 100644 --- a/src/base/storage.rs +++ b/src/base/storage.rs @@ -5,6 +5,7 @@ use std::ptr; use crate::base::allocator::{Allocator, InnerAllocator, SameShapeC, SameShapeR}; use crate::base::default_allocator::DefaultAllocator; use crate::base::dimension::{Dim, U1}; +use crate::base::Owned; /* * Aliases for allocation results. @@ -15,7 +16,7 @@ pub type SameShapeStorage = // TODO: better name than Owned ? /// The owned data storage that can be allocated from `S`. -pub type Owned = >::Buffer; +pub type InnerOwned = >::Buffer; /// The row-stride of the owned data storage for a buffer of dimension `(R, C)`. pub type RStride = diff --git a/src/base/unit.rs b/src/base/unit.rs index ed9ffc14..851df833 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -10,7 +10,7 @@ use abomonation::Abomonation; use crate::allocator::Allocator; use crate::base::DefaultAllocator; -use crate::storage::{Owned, Storage}; +use crate::storage::{InnerOwned, Storage}; use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealField}; /// A wrapper that ensures the underlying algebraic entity has a unit norm. @@ -344,7 +344,7 @@ where T: From<[::Element; 2]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, - Owned: Clone, + InnerOwned: Clone, { #[inline] fn from(arr: [Unit>; 2]) -> Self { @@ -361,7 +361,7 @@ where T: From<[::Element; 4]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, - Owned: Clone, + InnerOwned: Clone, { #[inline] fn from(arr: [Unit>; 4]) -> Self { @@ -380,7 +380,7 @@ where T: From<[::Element; 8]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, - Owned: Clone, + InnerOwned: Clone, { #[inline] fn from(arr: [Unit>; 8]) -> Self { @@ -403,7 +403,7 @@ where T: From<[::Element; 16]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, - Owned: Clone, + InnerOwned: Clone, { #[inline] fn from(arr: [Unit>; 16]) -> Self { diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index a6d62faf..06b5d49b 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -9,9 +9,9 @@ use crate::base::constraint::{SameNumberOfRows, ShapeConstraint}; use crate::base::default_allocator::DefaultAllocator; use crate::base::dimension::{Dim, DimName, Dynamic, U1}; use crate::base::storage::{ - ContiguousStorage, ContiguousStorageMut, Owned, ReshapableStorage, Storage, StorageMut, + ContiguousStorage, ContiguousStorageMut, ReshapableStorage, Storage, StorageMut, }; -use crate::base::Vector; +use crate::base::{Owned, Vector}; #[cfg(feature = "serde-serialize-no-std")] use serde::{ @@ -31,8 +31,8 @@ use abomonation::Abomonation; #[derive(Eq, Debug, Clone, PartialEq)] pub struct VecStorage { data: Vec, - nrows: R, - ncols: C, + pub(crate) nrows: R, + pub(crate) ncols: C, } #[cfg(feature = "serde-serialize")] @@ -184,20 +184,16 @@ where } #[inline] - fn into_owned(self) -> Owned - where - DefaultAllocator: InnerAllocator, - { - self + fn into_owned(self) -> Owned { + Owned(self) } #[inline] fn clone_owned(&self) -> Owned where T: Clone, - DefaultAllocator: InnerAllocator, { - self.clone() + Owned(self.clone()) } #[inline] @@ -234,20 +230,16 @@ where } #[inline] - fn into_owned(self) -> Owned - where - DefaultAllocator: InnerAllocator, - { - self + fn into_owned(self) -> Owned { + Owned(self) } #[inline] fn clone_owned(&self) -> Owned where T: Clone, - DefaultAllocator: InnerAllocator, { - self.clone() + Owned(self.clone()) } #[inline] diff --git a/src/debug/random_orthogonal.rs b/src/debug/random_orthogonal.rs index 0f4a9a4c..2cfbec26 100644 --- a/src/debug/random_orthogonal.rs +++ b/src/debug/random_orthogonal.rs @@ -4,7 +4,7 @@ use std::fmt; use quickcheck::{Arbitrary, Gen}; use crate::base::allocator::Allocator; -use crate::base::dimension::{Dim, Dynamic}; +use crate::base::dimension::{Dim, DimName, Dynamic}; use crate::base::{DefaultAllocator, OMatrix}; use crate::linalg::givens::GivensRotation; use crate::storage::Owned; @@ -18,7 +18,7 @@ where m: OMatrix, } -impl Copy for RandomOrthogonal +impl Copy for RandomOrthogonal where DefaultAllocator: Allocator, Owned: Copy, diff --git a/src/debug/random_sdp.rs b/src/debug/random_sdp.rs index 08bee9e2..3e119946 100644 --- a/src/debug/random_sdp.rs +++ b/src/debug/random_sdp.rs @@ -5,8 +5,7 @@ use quickcheck::{Arbitrary, Gen}; use crate::base::allocator::Allocator; use crate::base::dimension::{Dim, Dynamic}; -use crate::base::{DefaultAllocator, OMatrix}; -use crate::storage::Owned; +use crate::base::{DefaultAllocator, OMatrix, Owned}; use simba::scalar::ComplexField; use crate::debug::RandomOrthogonal; diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index 389965be..de45ec52 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -15,7 +15,7 @@ use simba::simd::SimdRealField; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar, Unit}; use crate::geometry::{AbstractRotation, Point, Translation}; @@ -157,7 +157,7 @@ mod rkyv_impl { impl hash::Hash for Isometry where - Owned>: hash::Hash, + InnerOwned>: hash::Hash, { fn hash(&self, state: &mut H) { self.translation.hash(state); @@ -165,7 +165,7 @@ where } } -impl Copy for Isometry where Owned>: Copy {} +impl Copy for Isometry where InnerOwned>: Copy {} impl Clone for Isometry { #[inline] diff --git a/src/geometry/isometry_construction.rs b/src/geometry/isometry_construction.rs index 39a1d763..3deea9f7 100644 --- a/src/geometry/isometry_construction.rs +++ b/src/geometry/isometry_construction.rs @@ -1,5 +1,5 @@ #[cfg(feature = "arbitrary")] -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -97,7 +97,7 @@ where T: SimdRealField + Arbitrary + Send, T::Element: SimdRealField, R: AbstractRotation + Arbitrary + Send, - Owned>: Send, + InnerOwned>: Send, { #[inline] fn arbitrary(rng: &mut Gen) -> Self { diff --git a/src/geometry/point.rs b/src/geometry/point.rs index 24dcf260..09644605 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -20,7 +20,7 @@ use crate::base::allocator::Allocator; use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; use crate::base::iter::{MatrixIter, MatrixIterMut}; use crate::base::{Const, DefaultAllocator, OVector}; -use crate::storage::Owned; +use crate::storage::InnerOwned; use crate::Scalar; /// A point in an euclidean space. @@ -322,7 +322,7 @@ where /// assert_eq!(it.next(), Some(3.0)); /// assert_eq!(it.next(), None); #[inline] - pub fn iter(&self) -> MatrixIter, Owned> { + pub fn iter(&self) -> MatrixIter, InnerOwned> { self.coords.iter() } @@ -346,7 +346,7 @@ where /// /// assert_eq!(p, Point3::new(10.0, 20.0, 30.0)); #[inline] - pub fn iter_mut(&mut self) -> MatrixIterMut, Owned> { + pub fn iter_mut(&mut self) -> MatrixIterMut, InnerOwned> { self.coords.iter_mut() } diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 988cc3d6..94876c18 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -185,7 +185,7 @@ where impl Arbitrary for OPoint where DefaultAllocator: Allocator, - crate::base::storage::Owned: Clone + Send, + crate::base::storage::InnerOwned: Clone + Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index bdda6e64..59a0fa35 100755 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -6,7 +6,7 @@ use std::hash::{Hash, Hasher}; use std::io::{Result as IOResult, Write}; #[cfg(feature = "serde-serialize-no-std")] -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(feature = "serde-serialize-no-std")] use serde::{Deserialize, Deserializer, Serialize, Serializer}; diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index 7a681bb2..a3984a6d 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -1,7 +1,7 @@ #[cfg(feature = "arbitrary")] use crate::base::dimension::U4; #[cfg(feature = "arbitrary")] -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -179,7 +179,7 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for Quaternion where - Owned: Send, + InnerOwned: Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { @@ -881,8 +881,8 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for UnitQuaternion where - Owned: Send, - Owned: Send, + InnerOwned: Send, + InnerOwned: Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 4a74c5f2..24597efd 100755 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -9,8 +9,8 @@ use std::io::{Result as IOResult, Write}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg(feature = "serde-serialize-no-std")] -use crate::base::storage::Owned; -use crate::storage::Owned; +use crate::base::storage::InnerOwned; +use crate::storage::InnerOwned; #[cfg(feature = "abomonation-serialize")] use abomonation::Abomonation; @@ -62,18 +62,18 @@ pub struct Rotation { impl hash::Hash for Rotation where - Owned, Const>: hash::Hash, + InnerOwned, Const>: hash::Hash, { fn hash(&self, state: &mut H) { self.matrix.hash(state) } } -impl Copy for Rotation where Owned, Const>: Copy {} +impl Copy for Rotation where InnerOwned, Const>: Copy {} impl Clone for Rotation where - Owned, Const>: Clone, + InnerOwned, Const>: Clone, { #[inline] fn clone(&self) -> Self { @@ -102,7 +102,7 @@ where #[cfg(feature = "serde-serialize-no-std")] impl Serialize for Rotation where - Owned, Const>: Serialize, + InnerOwned, Const>: Serialize, { fn serialize(&self, serializer: S) -> Result where @@ -115,7 +115,7 @@ where #[cfg(feature = "serde-serialize-no-std")] impl<'a, T, const D: usize> Deserialize<'a> for Rotation where - Owned, Const>: Deserialize<'a>, + InnerOwned, Const>: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result where diff --git a/src/geometry/rotation_specialization.rs b/src/geometry/rotation_specialization.rs index 2ad73c69..f7eecf9d 100644 --- a/src/geometry/rotation_specialization.rs +++ b/src/geometry/rotation_specialization.rs @@ -1,5 +1,5 @@ #[cfg(feature = "arbitrary")] -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -284,7 +284,7 @@ where impl Arbitrary for Rotation2 where T::Element: SimdRealField, - Owned: Send, + InnerOwned: Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { @@ -976,8 +976,8 @@ where impl Arbitrary for Rotation3 where T::Element: SimdRealField, - Owned: Send, - Owned: Send, + InnerOwned: Send, + InnerOwned: Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index 3a750656..aa831b7e 100755 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -17,7 +17,7 @@ use simba::simd::SimdRealField; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar}; use crate::geometry::{AbstractRotation, Isometry, Point, Translation}; @@ -64,7 +64,7 @@ where impl hash::Hash for Similarity where - Owned>: hash::Hash, + InnerOwned>: hash::Hash, { fn hash(&self, state: &mut H) { self.isometry.hash(state); @@ -75,7 +75,7 @@ where impl + Copy, const D: usize> Copy for Similarity where - Owned>: Copy, + InnerOwned>: Copy, { } diff --git a/src/geometry/similarity_construction.rs b/src/geometry/similarity_construction.rs index 3c1b2b42..7d4e8bc7 100644 --- a/src/geometry/similarity_construction.rs +++ b/src/geometry/similarity_construction.rs @@ -1,5 +1,5 @@ #[cfg(feature = "arbitrary")] -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -109,7 +109,7 @@ where T: crate::RealField + Arbitrary + Send, T::Element: crate::RealField, R: AbstractRotation + Arbitrary + Send, - Owned>: Send, + InnerOwned>: Send, { #[inline] fn arbitrary(rng: &mut Gen) -> Self { diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index bf61337b..5cf92da7 100755 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -12,7 +12,7 @@ use simba::scalar::{ComplexField, RealField}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; use crate::base::{Const, DefaultAllocator, DimName, OMatrix, SVector}; use crate::geometry::Point; @@ -171,26 +171,28 @@ impl hash::Hash for Transform: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: hash::Hash, + InnerOwned, U1>, DimNameSum, U1>>: hash::Hash, { fn hash(&self, state: &mut H) { self.matrix.hash(state); } } +/* impl Copy for Transform where Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: Copy, + InnerOwned, U1>, DimNameSum, U1>>: Copy, { } +*/ impl Clone for Transform where Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: Clone, + InnerOwned, U1>, DimNameSum, U1>>: Clone, { #[inline] fn clone(&self) -> Self { @@ -202,7 +204,7 @@ impl Debug for Transform where Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: Debug, + InnerOwned, U1>, DimNameSum, U1>>: Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Transform") @@ -216,7 +218,7 @@ impl Serialize for Transform where Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: Serialize, + InnerOwned, U1>, DimNameSum, U1>>: Serialize, { fn serialize(&self, serializer: S) -> Result where @@ -231,7 +233,7 @@ impl<'a, T, C: TCategory, const D: usize> Deserialize<'a> for Transform where Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: Deserialize<'a>, + InnerOwned, U1>, DimNameSum, U1>>: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result where @@ -551,7 +553,7 @@ where C: SubTCategoryOf, DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + Allocator, U1>>, - Owned, U1>, DimNameSum, U1>>: Clone, + InnerOwned, U1>, DimNameSum, U1>>: Clone, { /// Transform the given point by the inverse of this transformation. /// This may be cheaper than inverting the transformation and transforming diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 2fa098fe..c8a71926 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -9,7 +9,7 @@ use simba::scalar::{ClosedAdd, ClosedMul, RealField, SubsetOf}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar}; -use crate::storage::Owned; +use crate::storage::InnerOwned; use crate::geometry::{ Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory, @@ -589,7 +589,7 @@ md_assign_impl_all!( for CA, CB; where Const: DimNameAdd, CA: SuperTCategoryOf, CB: SubTCategoryOf, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: Clone; + InnerOwned, U1>, DimNameSum, U1>>: Clone; self: Transform, rhs: Transform; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.clone().inverse() }; diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index ff2cf32e..edd38fee 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -15,7 +15,7 @@ use simba::scalar::{ClosedAdd, ClosedNeg, ClosedSub}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar}; use crate::geometry::Point; @@ -31,7 +31,7 @@ pub struct Translation { impl hash::Hash for Translation where - Owned>: hash::Hash, + InnerOwned>: hash::Hash, { fn hash(&self, state: &mut H) { self.vector.hash(state) @@ -42,7 +42,7 @@ impl Copy for Translation {} impl Clone for Translation where - Owned>: Clone, + InnerOwned>: Clone, { #[inline] fn clone(&self) -> Self { @@ -71,7 +71,7 @@ where #[cfg(feature = "serde-serialize-no-std")] impl Serialize for Translation where - Owned>: Serialize, + InnerOwned>: Serialize, { fn serialize(&self, serializer: S) -> Result where @@ -84,7 +84,7 @@ where #[cfg(feature = "serde-serialize-no-std")] impl<'a, T, const D: usize> Deserialize<'a> for Translation where - Owned>: Deserialize<'a>, + InnerOwned>: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result where diff --git a/src/geometry/translation_construction.rs b/src/geometry/translation_construction.rs index 5371b648..a9f501be 100644 --- a/src/geometry/translation_construction.rs +++ b/src/geometry/translation_construction.rs @@ -1,5 +1,5 @@ #[cfg(feature = "arbitrary")] -use crate::base::storage::Owned; +use crate::base::storage::InnerOwned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -77,7 +77,7 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for Translation where - Owned>: Send, + InnerOwned>: Send, { #[inline] fn arbitrary(rng: &mut Gen) -> Self { diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index 141034a2..d4b6a1e3 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, Matrix, OMatrix, OVector, Unit}; use crate::dimension::{Const, Dim, DimDiff, DimMin, DimMinimum, DimSub, U1}; -use crate::storage::{Owned, Storage}; +use crate::storage::{InnerOwned, Storage}; use crate::Dynamic; use simba::scalar::ComplexField; @@ -58,9 +58,9 @@ where DefaultAllocator: Allocator + Allocator> + Allocator, U1>>, - Owned: Clone, - Owned>: Clone, - Owned, U1>>: Clone, + InnerOwned: Clone, + InnerOwned>: Clone, + InnerOwned, U1>>: Clone, { fn clone(&self) -> Self { Self { @@ -72,17 +72,19 @@ where } } +/* impl, C: Dim> Copy for Bidiagonal where DimMinimum: DimSub, DefaultAllocator: Allocator + Allocator> + Allocator, U1>>, - Owned: Copy, - Owned>: Copy, - Owned, U1>>: Copy, + InnerOwned: Copy, + InnerOwned>: Copy, + InnerOwned, U1>>: Copy, { } +*/ impl, C: Dim> fmt::Debug for Bidiagonal where @@ -90,9 +92,9 @@ where DefaultAllocator: Allocator + Allocator> + Allocator, U1>>, - Owned: fmt::Debug, - Owned>: fmt::Debug, - Owned, U1>>: fmt::Debug, + InnerOwned: fmt::Debug, + InnerOwned>: fmt::Debug, + InnerOwned, U1>>: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Bidiagonal") diff --git a/src/linalg/cholesky.rs b/src/linalg/cholesky.rs index afd90c0a..2abd8242 100644 --- a/src/linalg/cholesky.rs +++ b/src/linalg/cholesky.rs @@ -12,7 +12,7 @@ use crate::allocator::Allocator; use crate::base::{Const, DefaultAllocator, Matrix, OMatrix, Vector}; use crate::constraint::{SameNumberOfRows, ShapeConstraint}; use crate::dimension::{Dim, DimAdd, DimDiff, DimSub, DimSum, U1}; -use crate::storage::{Owned, Storage, StorageMut}; +use crate::storage::{InnerOwned, Storage, StorageMut}; /// The Cholesky decomposition of a symmetric-definite-positive matrix. #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] @@ -33,17 +33,19 @@ where chol: OMatrix, } +/* impl Copy for Cholesky where DefaultAllocator: Allocator, - Owned: Copy, + InnerOwned: Copy, { } +*/ impl Clone for Cholesky where DefaultAllocator: Allocator, - Owned: Clone, + InnerOwned: Clone, { fn clone(&self) -> Self { Self { @@ -55,7 +57,7 @@ where impl fmt::Debug for Cholesky where DefaultAllocator: Allocator, - Owned: fmt::Debug, + InnerOwned: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Cholesky") diff --git a/src/linalg/exp.rs b/src/linalg/exp.rs index c402e743..76e2ddf5 100644 --- a/src/linalg/exp.rs +++ b/src/linalg/exp.rs @@ -8,7 +8,7 @@ use crate::{ DefaultAllocator, }, convert, - storage::Owned, + storage::InnerOwned, try_convert, ComplexField, OMatrix, RealField, }; @@ -435,7 +435,7 @@ where + Allocator + Allocator + Allocator, - Owned: Clone, + InnerOwned: Clone, { /// Computes exponential of this matrix #[must_use] diff --git a/src/linalg/hessenberg.rs b/src/linalg/hessenberg.rs index fc0351bf..3874bf77 100644 --- a/src/linalg/hessenberg.rs +++ b/src/linalg/hessenberg.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, OMatrix, OVector}; use crate::dimension::{Const, DimDiff, DimSub, U1}; -use crate::storage::{Owned, Storage}; +use crate::storage::{InnerOwned, Storage}; use crate::Matrix; use simba::scalar::ComplexField; @@ -37,19 +37,21 @@ where subdiag: OVector>, } +/* impl> Copy for Hessenberg where DefaultAllocator: Allocator + Allocator>, - Owned: Copy, - Owned>: Copy, + InnerOwned: Copy, + InnerOwned>: Copy, { } +*/ impl> Clone for Hessenberg where DefaultAllocator: Allocator + Allocator>, - Owned: Clone, - Owned>: Clone, + InnerOwned: Clone, + InnerOwned>: Clone, { fn clone(&self) -> Self { Self { @@ -62,8 +64,8 @@ where impl> fmt::Debug for Hessenberg where DefaultAllocator: Allocator + Allocator>, - Owned: fmt::Debug, - Owned>: fmt::Debug, + InnerOwned: fmt::Debug, + InnerOwned>: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Hessenberg") @@ -170,7 +172,7 @@ where #[must_use] pub fn h(&self) -> OMatrix where - Owned: Clone, + InnerOwned: Clone, { let dim = self.hess.nrows(); let mut res = self.hess.clone(); diff --git a/src/linalg/lu.rs b/src/linalg/lu.rs index 8b4fb7c3..6fc0d9fa 100644 --- a/src/linalg/lu.rs +++ b/src/linalg/lu.rs @@ -8,7 +8,7 @@ use crate::allocator::{Allocator, Reallocator}; use crate::base::{DefaultAllocator, Matrix, OMatrix, Scalar}; use crate::constraint::{SameNumberOfRows, ShapeConstraint}; use crate::dimension::{Dim, DimMin, DimMinimum}; -use crate::storage::{Owned, Storage, StorageMut}; +use crate::storage::{InnerOwned, Storage, StorageMut}; use simba::scalar::{ComplexField, Field}; use crate::linalg::PermutationSequence; @@ -37,19 +37,21 @@ where p: PermutationSequence>, } +/* impl, C: Dim> Copy for LU where DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, PermutationSequence>: Copy, - Owned: Copy, + InnerOwned: Copy, { } +*/ impl, C: Dim> Clone for LU where DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, PermutationSequence>: Clone, - Owned: Clone, + InnerOwned: Clone, { fn clone(&self) -> Self { Self { @@ -63,7 +65,7 @@ impl, C: Dim> fmt::Debug for LU where DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, PermutationSequence>: fmt::Debug, - Owned: fmt::Debug, + InnerOwned: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("LU") diff --git a/src/linalg/permutation_sequence.rs b/src/linalg/permutation_sequence.rs index 9f4bbdc3..14ff718d 100644 --- a/src/linalg/permutation_sequence.rs +++ b/src/linalg/permutation_sequence.rs @@ -13,7 +13,7 @@ use crate::base::{DefaultAllocator, Matrix, OVector, Scalar}; use crate::dimension::Dynamic; use crate::dimension::{Dim, DimName}; use crate::iter::MatrixIter; -use crate::storage::{Owned, StorageMut}; +use crate::storage::{InnerOwned, StorageMut}; use crate::{Const, U1}; /// A sequence of row or column permutations. @@ -200,7 +200,7 @@ where MaybeUninit<(usize, usize)>, D, U1, - Owned, D, U1>, + InnerOwned, D, U1>, >, >, >, diff --git a/src/linalg/qr.rs b/src/linalg/qr.rs index 64e14a97..e4a4911b 100644 --- a/src/linalg/qr.rs +++ b/src/linalg/qr.rs @@ -8,7 +8,7 @@ use crate::allocator::{Allocator, Reallocator}; use crate::base::{DefaultAllocator, Matrix, OMatrix, OVector, Unit}; use crate::constraint::{SameNumberOfRows, ShapeConstraint}; use crate::dimension::{Const, Dim, DimMin, DimMinimum}; -use crate::storage::{Owned, Storage, StorageMut}; +use crate::storage::{InnerOwned, Storage, StorageMut}; use simba::scalar::ComplexField; use crate::geometry::Reflection; @@ -39,19 +39,21 @@ where diag: OVector>, } +/* impl, C: Dim> Copy for QR where DefaultAllocator: Allocator + Allocator>, - Owned: Copy, - Owned>: Copy, + InnerOwned: Copy, + InnerOwned>: Copy, { } +*/ impl, C: Dim> Clone for QR where DefaultAllocator: Allocator + Allocator>, - Owned: Clone, - Owned>: Clone, + InnerOwned: Clone, + InnerOwned>: Clone, { fn clone(&self) -> Self { Self { @@ -64,8 +66,8 @@ where impl, C: Dim> fmt::Debug for QR where DefaultAllocator: Allocator + Allocator>, - Owned: fmt::Debug, - Owned>: fmt::Debug, + InnerOwned: fmt::Debug, + InnerOwned>: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("QR") diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index f93aec1e..583c0397 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -11,9 +11,11 @@ use num_complex::Complex as NumComplex; use simba::scalar::{ComplexField, RealField}; use crate::allocator::Allocator; -use crate::base::dimension::{Const, Dim, DimDiff, DimSub, Dynamic, U1, U2}; -use crate::base::storage::{Owned, Storage}; -use crate::base::{DefaultAllocator, OMatrix, OVector, SquareMatrix, Unit, Vector2, Vector3}; +use crate::base::dimension::{Const, Dim, DimDiff, DimName, DimSub, Dynamic, U1, U2}; +use crate::base::storage::{InnerOwned, Storage}; +use crate::base::{ + DefaultAllocator, OMatrix, OVector, Owned, SquareMatrix, Unit, Vector2, Vector3, +}; use crate::geometry::Reflection; use crate::linalg::givens::GivensRotation; @@ -42,7 +44,7 @@ where t: OMatrix, } -impl Copy for Schur +impl Copy for Schur where DefaultAllocator: Allocator, Owned: Copy, @@ -52,7 +54,7 @@ where impl Clone for Schur where DefaultAllocator: Allocator, - Owned: Clone, + InnerOwned: Clone, { fn clone(&self) -> Self { Self { @@ -65,7 +67,7 @@ where impl fmt::Debug for Schur where DefaultAllocator: Allocator, - Owned: fmt::Debug, + InnerOwned: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Schur") diff --git a/src/linalg/svd.rs b/src/linalg/svd.rs index c8cf5501..c2f58221 100644 --- a/src/linalg/svd.rs +++ b/src/linalg/svd.rs @@ -9,8 +9,8 @@ use num::{One, Zero}; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, Matrix, Matrix2x3, OMatrix, OVector, Vector2}; use crate::constraint::{SameNumberOfRows, ShapeConstraint}; -use crate::dimension::{Dim, DimDiff, DimMin, DimMinimum, DimSub, U1}; -use crate::storage::{Owned, Storage}; +use crate::dimension::{Dim, DimDiff, DimMin, DimMinimum, DimName, DimSub, U1}; +use crate::storage::{InnerOwned, Storage}; use simba::scalar::{ComplexField, RealField}; use crate::linalg::givens::GivensRotation; @@ -55,14 +55,14 @@ where pub singular_values: OVector>, } -impl, C: Dim> Copy for SVD +impl, C: DimName> Copy for SVD where DefaultAllocator: Allocator, C> + Allocator> + Allocator>, - Owned>: Copy, - Owned, C>: Copy, - Owned>: Copy, + InnerOwned>: Copy, + InnerOwned, C>: Copy, + InnerOwned>: Copy, { } @@ -71,9 +71,9 @@ where DefaultAllocator: Allocator, C> + Allocator> + Allocator>, - Owned>: Clone, - Owned, C>: Clone, - Owned>: Clone, + InnerOwned>: Clone, + InnerOwned, C>: Clone, + InnerOwned>: Clone, { fn clone(&self) -> Self { Self { @@ -89,9 +89,9 @@ where DefaultAllocator: Allocator, C> + Allocator> + Allocator>, - Owned>: fmt::Debug, - Owned, C>: fmt::Debug, - Owned>: fmt::Debug, + InnerOwned>: fmt::Debug, + InnerOwned, C>: fmt::Debug, + InnerOwned>: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SVD") diff --git a/src/linalg/symmetric_eigen.rs b/src/linalg/symmetric_eigen.rs index ad4d6be4..df32cdac 100644 --- a/src/linalg/symmetric_eigen.rs +++ b/src/linalg/symmetric_eigen.rs @@ -8,8 +8,8 @@ use num::Zero; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, Matrix2, OMatrix, OVector, SquareMatrix, Vector2}; -use crate::dimension::{Dim, DimDiff, DimSub, U1}; -use crate::storage::{Owned, Storage}; +use crate::dimension::{Dim, DimDiff, DimName, DimSub, U1}; +use crate::storage::{InnerOwned, Storage}; use simba::scalar::ComplexField; use crate::linalg::givens::GivensRotation; @@ -42,19 +42,19 @@ where pub eigenvalues: OVector, } -impl Copy for SymmetricEigen +impl Copy for SymmetricEigen where DefaultAllocator: Allocator + Allocator, - Owned: Copy, - Owned: Copy, + InnerOwned: Copy, + InnerOwned: Copy, { } impl Clone for SymmetricEigen where DefaultAllocator: Allocator + Allocator, - Owned: Clone, - Owned: Clone, + InnerOwned: Clone, + InnerOwned: Clone, { fn clone(&self) -> Self { Self { @@ -67,8 +67,8 @@ where impl fmt::Debug for SymmetricEigen where DefaultAllocator: Allocator + Allocator, - Owned: fmt::Debug, - Owned: fmt::Debug, + InnerOwned: fmt::Debug, + InnerOwned: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SymmetricEigen") @@ -301,7 +301,7 @@ where #[must_use] pub fn recompose(&self) -> OMatrix where - Owned: Clone, + InnerOwned: Clone, { let mut u_t = self.eigenvectors.clone(); for i in 0..self.eigenvalues.len() { diff --git a/src/linalg/symmetric_tridiagonal.rs b/src/linalg/symmetric_tridiagonal.rs index de45717f..f074b0eb 100644 --- a/src/linalg/symmetric_tridiagonal.rs +++ b/src/linalg/symmetric_tridiagonal.rs @@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize}; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, OMatrix, OVector}; -use crate::dimension::{Const, DimDiff, DimSub, U1}; -use crate::storage::{Owned, Storage}; +use crate::dimension::{Const, DimDiff, DimName, DimSub, U1}; +use crate::storage::{InnerOwned, Storage}; use simba::scalar::ComplexField; use crate::linalg::householder; @@ -36,19 +36,19 @@ where off_diagonal: OVector>, } -impl> Copy for SymmetricTridiagonal +impl + DimName> Copy for SymmetricTridiagonal where DefaultAllocator: Allocator + Allocator>, - Owned: Copy, - Owned>: Copy, + InnerOwned: Copy, + InnerOwned>: Copy, { } impl> Clone for SymmetricTridiagonal where DefaultAllocator: Allocator + Allocator>, - Owned: Clone, - Owned>: Clone, + InnerOwned: Clone, + InnerOwned>: Clone, { fn clone(&self) -> Self { Self { @@ -61,8 +61,8 @@ where impl> fmt::Debug for SymmetricTridiagonal where DefaultAllocator: Allocator + Allocator>, - Owned: fmt::Debug, - Owned>: fmt::Debug, + InnerOwned: fmt::Debug, + InnerOwned>: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SymmetricTridiagonal") diff --git a/src/linalg/udu.rs b/src/linalg/udu.rs index 8e1b068f..5d78951b 100644 --- a/src/linalg/udu.rs +++ b/src/linalg/udu.rs @@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize}; use crate::allocator::Allocator; use crate::base::{Const, DefaultAllocator, OMatrix, OVector}; -use crate::dimension::Dim; -use crate::storage::{Owned, Storage}; +use crate::dimension::{Dim, DimName}; +use crate::storage::{InnerOwned, Storage}; use simba::scalar::RealField; /// UDU factorization. @@ -31,19 +31,19 @@ where pub d: OVector, } -impl Copy for UDU +impl Copy for UDU where DefaultAllocator: Allocator + Allocator, - Owned: Copy, - Owned: Copy, + InnerOwned: Copy, + InnerOwned: Copy, { } impl Clone for UDU where DefaultAllocator: Allocator + Allocator, - Owned: Clone, - Owned: Clone, + InnerOwned: Clone, + InnerOwned: Clone, { fn clone(&self) -> Self { Self { @@ -56,8 +56,8 @@ where impl fmt::Debug for UDU where DefaultAllocator: Allocator + Allocator, - Owned: fmt::Debug, - Owned: fmt::Debug, + InnerOwned: fmt::Debug, + InnerOwned: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("UDU")