forked from M-Labs/nalgebra
First draft of Owned
overhaul
This commit is contained in:
parent
a753d84aae
commit
22b657f566
@ -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<T, R, C> = Matrix<T, R, C, Owned<T, R, C>>;
|
||||
#[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<T, R, C> = Matrix<T, R, C, Owned<T, R, C>>;
|
||||
pub type MatrixMN<T, R, C> = OMatrix<T, R, C>;
|
||||
|
||||
/// 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<T, D, D> or SMatrix<T, D, D> instead.")]
|
||||
pub type MatrixN<T, D> = Matrix<T, D, D, Owned<T, D, D>>;
|
||||
pub type MatrixN<T, D> = Matrix<T, D, D, InnerOwned<T, D, D>>;
|
||||
|
||||
/// A statically sized column-major matrix with `R` rows and `C` columns.
|
||||
///
|
||||
@ -275,7 +274,7 @@ pub type Matrix6x5<T> = Matrix<T, U6, U5, ArrayStorage<T, 6, 5>>;
|
||||
pub type DVector<T> = Matrix<T, Dynamic, U1, VecStorage<T, Dynamic, U1>>;
|
||||
|
||||
/// An owned D-dimensional column vector.
|
||||
pub type OVector<T, D> = Matrix<T, D, U1, Owned<T, D, U1>>;
|
||||
pub type OVector<T, D> = Matrix<T, D, U1, InnerOwned<T, D, U1>>;
|
||||
/// A statically sized D-dimensional column vector.
|
||||
pub type SVector<T, const D: usize> = Matrix<T, Const<D>, U1, ArrayStorage<T, D, 1>>; // Owned<T, Const<D>, U1>>;
|
||||
|
||||
@ -285,7 +284,7 @@ pub type SVector<T, const D: usize> = Matrix<T, Const<D>, U1, ArrayStorage<T, D,
|
||||
#[deprecated(
|
||||
note = "use SVector for a statically-sized matrix using integer dimensions, or OVector for an owned matrix using types as dimensions."
|
||||
)]
|
||||
pub type VectorN<T, D> = Matrix<T, D, U1, Owned<T, D, U1>>;
|
||||
pub type VectorN<T, D> = Matrix<T, D, U1, InnerOwned<T, D, U1>>;
|
||||
|
||||
/// A stack-allocated, 1-dimensional column vector.
|
||||
pub type Vector1<T> = Matrix<T, U1, U1, ArrayStorage<T, 1, 1>>;
|
||||
@ -312,7 +311,7 @@ pub type Vector6<T> = Matrix<T, U6, U1, ArrayStorage<T, 6, 1>>;
|
||||
pub type RowDVector<T> = Matrix<T, U1, Dynamic, VecStorage<T, U1, Dynamic>>;
|
||||
|
||||
/// An owned D-dimensional row vector.
|
||||
pub type RowOVector<T, D> = Matrix<T, U1, D, Owned<T, U1, D>>;
|
||||
pub type RowOVector<T, D> = Matrix<T, U1, D, InnerOwned<T, U1, D>>;
|
||||
|
||||
/// A statically sized D-dimensional row vector.
|
||||
pub type RowSVector<T, const D: usize> = Matrix<T, U1, Const<D>, ArrayStorage<T, 1, D>>;
|
||||
|
@ -59,6 +59,7 @@ pub trait Allocator<T, R: Dim, C: Dim = U1>:
|
||||
) -> <Self as InnerAllocator<ManuallyDrop<T>, 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<T, RFrom: Dim, CFrom: Dim, RTo: Dim, CTo: Dim>:
|
||||
@ -68,6 +69,7 @@ pub trait Reallocator<T, RFrom: Dim, CFrom: Dim, RTo: Dim, CTo: Dim>:
|
||||
/// `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
|
||||
|
@ -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<T, Const<R>, Const<C>>,
|
||||
{
|
||||
self
|
||||
Owned(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -95,7 +96,11 @@ where
|
||||
DefaultAllocator: InnerAllocator<T, Const<R>, Const<C>>,
|
||||
{
|
||||
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]
|
||||
|
@ -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<T, R: Dim, C: Dim> Arbitrary for OMatrix<T, R, C>
|
||||
where
|
||||
T: Arbitrary + Send,
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
Owned<T, R, C>: Clone + Send,
|
||||
InnerOwned<T, R, C>: Clone + Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
|
@ -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<T, const R: usize, const C: usize> Allocator<T, Const<R>, Const<C>> for Def
|
||||
fn allocate_uninitialized(
|
||||
_: Const<R>,
|
||||
_: Const<C>,
|
||||
) -> Owned<MaybeUninit<T>, Const<R>, Const<C>> {
|
||||
) -> InnerOwned<MaybeUninit<T>, Const<R>, Const<C>> {
|
||||
// SAFETY: An uninitialized `[MaybeUninit<_>; _]` is valid.
|
||||
let array = unsafe { MaybeUninit::uninit().assume_init() };
|
||||
ArrayStorage(array)
|
||||
@ -75,7 +78,7 @@ impl<T, const R: usize, const C: usize> Allocator<T, Const<R>, Const<C>> for Def
|
||||
#[inline]
|
||||
unsafe fn assume_init(
|
||||
uninit: <Self as InnerAllocator<MaybeUninit<T>, Const<R>, Const<C>>>::Buffer,
|
||||
) -> Owned<T, Const<R>, Const<C>> {
|
||||
) -> InnerOwned<T, Const<R>, Const<C>> {
|
||||
// Safety:
|
||||
// * The caller guarantees that all elements of the array are initialized
|
||||
// * `MaybeUninit<T>` and T are guaranteed to have the same layout
|
||||
@ -120,7 +123,7 @@ impl<T, C: Dim> InnerAllocator<T, Dynamic, C> for DefaultAllocator {
|
||||
|
||||
impl<T, C: Dim> Allocator<T, Dynamic, C> for DefaultAllocator {
|
||||
#[inline]
|
||||
fn allocate_uninitialized(nrows: Dynamic, ncols: C) -> Owned<MaybeUninit<T>, Dynamic, C> {
|
||||
fn allocate_uninitialized(nrows: Dynamic, ncols: C) -> InnerOwned<MaybeUninit<T>, Dynamic, C> {
|
||||
let mut data = Vec::new();
|
||||
let length = nrows.value() * ncols.value();
|
||||
data.reserve_exact(length);
|
||||
@ -130,7 +133,9 @@ impl<T, C: Dim> Allocator<T, Dynamic, C> for DefaultAllocator {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn assume_init(uninit: Owned<MaybeUninit<T>, Dynamic, C>) -> Owned<T, Dynamic, C> {
|
||||
unsafe fn assume_init(
|
||||
uninit: InnerOwned<MaybeUninit<T>, Dynamic, C>,
|
||||
) -> InnerOwned<T, Dynamic, C> {
|
||||
// Avoids a double-drop.
|
||||
let (nrows, ncols) = uninit.shape();
|
||||
let vec: Vec<_> = uninit.into();
|
||||
@ -173,7 +178,7 @@ impl<T, R: DimName> InnerAllocator<T, R, Dynamic> for DefaultAllocator {
|
||||
nrows: R,
|
||||
ncols: Dynamic,
|
||||
iter: I,
|
||||
) -> Owned<T, R, Dynamic> {
|
||||
) -> InnerOwned<T, R, Dynamic> {
|
||||
let it = iter.into_iter();
|
||||
let res: Vec<T> = it.collect();
|
||||
assert!(res.len() == nrows.value() * ncols.value(),
|
||||
@ -185,7 +190,7 @@ impl<T, R: DimName> InnerAllocator<T, R, Dynamic> for DefaultAllocator {
|
||||
|
||||
impl<T, R: DimName> Allocator<T, R, Dynamic> for DefaultAllocator {
|
||||
#[inline]
|
||||
fn allocate_uninitialized(nrows: R, ncols: Dynamic) -> Owned<MaybeUninit<T>, R, Dynamic> {
|
||||
fn allocate_uninitialized(nrows: R, ncols: Dynamic) -> InnerOwned<MaybeUninit<T>, R, Dynamic> {
|
||||
let mut data = Vec::new();
|
||||
let length = nrows.value() * ncols.value();
|
||||
data.reserve_exact(length);
|
||||
@ -195,7 +200,9 @@ impl<T, R: DimName> Allocator<T, R, Dynamic> for DefaultAllocator {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn assume_init(uninit: Owned<MaybeUninit<T>, R, Dynamic>) -> Owned<T, R, Dynamic> {
|
||||
unsafe fn assume_init(
|
||||
uninit: InnerOwned<MaybeUninit<T>, R, Dynamic>,
|
||||
) -> InnerOwned<T, R, Dynamic> {
|
||||
// Avoids a double-drop.
|
||||
let (nrows, ncols) = uninit.shape();
|
||||
let vec: Vec<_> = uninit.into();
|
||||
@ -228,6 +235,170 @@ impl<T, R: DimName> Allocator<T, R, Dynamic> for DefaultAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
/// The owned storage type for a matrix.
|
||||
#[repr(transparent)]
|
||||
pub struct Owned<T, R: Dim, C: Dim>(pub InnerOwned<T, R, C>)
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>;
|
||||
|
||||
impl<T: Copy, R: DimName, C: DimName> Copy for Owned<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
InnerOwned<T, R, C>: Copy,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T: Clone, R: Dim, C: Dim> Clone for Owned<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
{
|
||||
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<T: fmt::Debug, R: Dim, C: Dim> fmt::Debug for Owned<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
{
|
||||
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<T, R: Dim, C: Dim> Owned<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
{
|
||||
/// 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<T, R, C> {
|
||||
assert!(Self::is_vec());
|
||||
|
||||
// Safety: `self` is transparent and must contain a `VecStorage`.
|
||||
unsafe { &*(&self as *const _ as *const _) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T, R: Dim, C: Dim> Storage<T, R, C> for Owned<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
{
|
||||
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<T, R, C> {
|
||||
self
|
||||
}
|
||||
|
||||
fn clone_owned(&self) -> Owned<T, R, C>
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T, R: Dim, C: Dim> StorageMut<T, R, C> for Owned<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
{
|
||||
fn ptr_mut(&mut self) -> *mut T {
|
||||
todo!()
|
||||
}
|
||||
|
||||
unsafe fn as_mut_slice_unchecked(&mut self) -> &mut [T] {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T, R: Dim, C: Dim> ContiguousStorage<T, R, C> for Owned<T, R, C> where
|
||||
DefaultAllocator: Allocator<T, R, C>
|
||||
{
|
||||
}
|
||||
|
||||
unsafe impl<T, R: Dim, C: Dim> ContiguousStorageMut<T, R, C> for Owned<T, R, C> where
|
||||
DefaultAllocator: Allocator<T, R, C>
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Reallocator.
|
||||
@ -243,7 +414,7 @@ where
|
||||
unsafe fn reallocate_copy(
|
||||
rto: Const<RTO>,
|
||||
cto: Const<CTO>,
|
||||
buf: Owned<T, RFrom, CFrom>,
|
||||
buf: InnerOwned<T, RFrom, CFrom>,
|
||||
) -> ArrayStorage<T, RTO, CTO> {
|
||||
let mut res =
|
||||
<Self as Allocator<_, Const<RTO>, Const<CTO>>>::allocate_uninitialized(rto, cto);
|
||||
|
@ -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<D: Dim>() -> bool {
|
||||
TypeId::of::<Self>() == TypeId::of::<D>()
|
||||
@ -65,6 +65,16 @@ pub trait Dim: 'static + Debug + Copy + PartialEq + Send + Sync {
|
||||
/// Dynamic`.
|
||||
fn try_to_usize() -> Option<usize>;
|
||||
|
||||
/// 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<const R: usize>;
|
||||
|
||||
/// Trait implemented exclusively by type-level integers.
|
||||
|
@ -812,7 +812,7 @@ impl<T: Clone, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||
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<T: Clone, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||
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(),
|
||||
|
@ -153,7 +153,7 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
||||
/// dynamically-sized column vector should be represented as a `Matrix<T, Dynamic, U1, S>` (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<T, R, C, S> {
|
||||
/// The data storage that contains all the matrix components. Disappointed?
|
||||
///
|
||||
@ -193,12 +193,6 @@ pub struct Matrix<T, R, C, S> {
|
||||
_phantoms: PhantomData<(T, R, C)>,
|
||||
}
|
||||
|
||||
impl<T, R: Dim, C: Dim, S: fmt::Debug> fmt::Debug for Matrix<T, R, C, S> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Matrix").field("data", &self.data).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, R: Dim, C: Dim, S> Default for Matrix<T, R, C, S>
|
||||
where
|
||||
S: Storage<T, R, C> + Default,
|
||||
@ -640,7 +634,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||
T: Clone,
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
{
|
||||
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<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||
T: Clone,
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
{
|
||||
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
|
||||
|
@ -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]
|
||||
|
@ -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<T, Dynamic, C>: Clone,
|
||||
InnerOwned<T, Dynamic, C>: Clone,
|
||||
{
|
||||
/// # Example
|
||||
/// ```
|
||||
|
@ -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<T, R1, C1, R2, C2> =
|
||||
|
||||
// TODO: better name than Owned ?
|
||||
/// The owned data storage that can be allocated from `S`.
|
||||
pub type Owned<T, R, C = U1> = <DefaultAllocator as InnerAllocator<T, R, C>>::Buffer;
|
||||
pub type InnerOwned<T, R, C = U1> = <DefaultAllocator as InnerAllocator<T, R, C>>::Buffer;
|
||||
|
||||
/// The row-stride of the owned data storage for a buffer of dimension `(R, C)`.
|
||||
pub type RStride<T, R, C = U1> =
|
||||
|
@ -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<[<T as simba::simd::SimdValue>::Element; 2]>,
|
||||
T::Element: Scalar,
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<T::Element, R, C>,
|
||||
Owned<T::Element, R, C>: Clone,
|
||||
InnerOwned<T::Element, R, C>: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn from(arr: [Unit<OMatrix<T::Element, R, C>>; 2]) -> Self {
|
||||
@ -361,7 +361,7 @@ where
|
||||
T: From<[<T as simba::simd::SimdValue>::Element; 4]>,
|
||||
T::Element: Scalar,
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<T::Element, R, C>,
|
||||
Owned<T::Element, R, C>: Clone,
|
||||
InnerOwned<T::Element, R, C>: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn from(arr: [Unit<OMatrix<T::Element, R, C>>; 4]) -> Self {
|
||||
@ -380,7 +380,7 @@ where
|
||||
T: From<[<T as simba::simd::SimdValue>::Element; 8]>,
|
||||
T::Element: Scalar,
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<T::Element, R, C>,
|
||||
Owned<T::Element, R, C>: Clone,
|
||||
InnerOwned<T::Element, R, C>: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn from(arr: [Unit<OMatrix<T::Element, R, C>>; 8]) -> Self {
|
||||
@ -403,7 +403,7 @@ where
|
||||
T: From<[<T as simba::simd::SimdValue>::Element; 16]>,
|
||||
T::Element: Scalar,
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<T::Element, R, C>,
|
||||
Owned<T::Element, R, C>: Clone,
|
||||
InnerOwned<T::Element, R, C>: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn from(arr: [Unit<OMatrix<T::Element, R, C>>; 16]) -> Self {
|
||||
|
@ -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<T, R: Dim, C: Dim> {
|
||||
data: Vec<T>,
|
||||
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<T, Dynamic, C>
|
||||
where
|
||||
DefaultAllocator: InnerAllocator<T, Dynamic, C>,
|
||||
{
|
||||
self
|
||||
fn into_owned(self) -> Owned<T, Dynamic, C> {
|
||||
Owned(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn clone_owned(&self) -> Owned<T, Dynamic, C>
|
||||
where
|
||||
T: Clone,
|
||||
DefaultAllocator: InnerAllocator<T, Dynamic, C>,
|
||||
{
|
||||
self.clone()
|
||||
Owned(self.clone())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -234,20 +230,16 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn into_owned(self) -> Owned<T, R, Dynamic>
|
||||
where
|
||||
DefaultAllocator: InnerAllocator<T, R, Dynamic>,
|
||||
{
|
||||
self
|
||||
fn into_owned(self) -> Owned<T, R, Dynamic> {
|
||||
Owned(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn clone_owned(&self) -> Owned<T, R, Dynamic>
|
||||
where
|
||||
T: Clone,
|
||||
DefaultAllocator: InnerAllocator<T, R, Dynamic>,
|
||||
{
|
||||
self.clone()
|
||||
Owned(self.clone())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -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<T, D, D>,
|
||||
}
|
||||
|
||||
impl<T: Copy, D: Dim> Copy for RandomOrthogonal<T, D>
|
||||
impl<T: Copy, D: DimName> Copy for RandomOrthogonal<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D>,
|
||||
Owned<T, D, D>: Copy,
|
||||
|
@ -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;
|
||||
|
@ -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<T: hash::Hash, R: hash::Hash, const D: usize> hash::Hash for Isometry<T, R, D>
|
||||
where
|
||||
Owned<T, Const<D>>: hash::Hash,
|
||||
InnerOwned<T, Const<D>>: hash::Hash,
|
||||
{
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.translation.hash(state);
|
||||
@ -165,7 +165,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy, R: Copy, const D: usize> Copy for Isometry<T, R, D> where Owned<T, Const<D>>: Copy {}
|
||||
impl<T: Copy, R: Copy, const D: usize> Copy for Isometry<T, R, D> where InnerOwned<T, Const<D>>: Copy {}
|
||||
|
||||
impl<T: Clone, R: Clone, const D: usize> Clone for Isometry<T, R, D> {
|
||||
#[inline]
|
||||
|
@ -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<T, D> + Arbitrary + Send,
|
||||
Owned<T, crate::Const<D>>: Send,
|
||||
InnerOwned<T, crate::Const<D>>: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(rng: &mut Gen) -> Self {
|
||||
|
@ -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<T, D, Const<1>, Owned<T, D>> {
|
||||
pub fn iter(&self) -> MatrixIter<T, D, Const<1>, InnerOwned<T, D>> {
|
||||
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<T, D, Const<1>, Owned<T, D>> {
|
||||
pub fn iter_mut(&mut self) -> MatrixIterMut<T, D, Const<1>, InnerOwned<T, D>> {
|
||||
self.coords.iter_mut()
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ where
|
||||
impl<T: Arbitrary + Send, D: DimName> Arbitrary for OPoint<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D>,
|
||||
crate::base::storage::Owned<T, D>: Clone + Send,
|
||||
crate::base::storage::InnerOwned<T, D>: Clone + Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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<T: SimdRealField + Arbitrary> Arbitrary for Quaternion<T>
|
||||
where
|
||||
Owned<T, U4>: Send,
|
||||
InnerOwned<T, U4>: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
@ -881,8 +881,8 @@ where
|
||||
#[cfg(feature = "arbitrary")]
|
||||
impl<T: RealField + Arbitrary> Arbitrary for UnitQuaternion<T>
|
||||
where
|
||||
Owned<T, U4>: Send,
|
||||
Owned<T, U3>: Send,
|
||||
InnerOwned<T, U4>: Send,
|
||||
InnerOwned<T, U3>: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
|
@ -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<T, const D: usize> {
|
||||
|
||||
impl<T: hash::Hash, const D: usize> hash::Hash for Rotation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>, Const<D>>: hash::Hash,
|
||||
InnerOwned<T, Const<D>, Const<D>>: hash::Hash,
|
||||
{
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.matrix.hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy, const D: usize> Copy for Rotation<T, D> where Owned<T, Const<D>, Const<D>>: Copy {}
|
||||
impl<T: Copy, const D: usize> Copy for Rotation<T, D> where InnerOwned<T, Const<D>, Const<D>>: Copy {}
|
||||
|
||||
impl<T: Clone, const D: usize> Clone for Rotation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>, Const<D>>: Clone,
|
||||
InnerOwned<T, Const<D>, Const<D>>: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
@ -102,7 +102,7 @@ where
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<T: Scalar, const D: usize> Serialize for Rotation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>, Const<D>>: Serialize,
|
||||
InnerOwned<T, Const<D>, Const<D>>: Serialize,
|
||||
{
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
@ -115,7 +115,7 @@ where
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<'a, T, const D: usize> Deserialize<'a> for Rotation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>, Const<D>>: Deserialize<'a>,
|
||||
InnerOwned<T, Const<D>, Const<D>>: Deserialize<'a>,
|
||||
{
|
||||
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
|
||||
where
|
||||
|
@ -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<T: SimdRealField + Arbitrary> Arbitrary for Rotation2<T>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
Owned<T, U2, U2>: Send,
|
||||
InnerOwned<T, U2, U2>: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
@ -976,8 +976,8 @@ where
|
||||
impl<T: SimdRealField + Arbitrary> Arbitrary for Rotation3<T>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
Owned<T, U3, U3>: Send,
|
||||
Owned<T, U3>: Send,
|
||||
InnerOwned<T, U3, U3>: Send,
|
||||
InnerOwned<T, U3>: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
|
@ -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<T: Scalar + hash::Hash, R: hash::Hash, const D: usize> hash::Hash for Similarity<T, R, D>
|
||||
where
|
||||
Owned<T, Const<D>>: hash::Hash,
|
||||
InnerOwned<T, Const<D>>: hash::Hash,
|
||||
{
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.isometry.hash(state);
|
||||
@ -75,7 +75,7 @@ where
|
||||
impl<T: Scalar + Copy + Zero, R: AbstractRotation<T, D> + Copy, const D: usize> Copy
|
||||
for Similarity<T, R, D>
|
||||
where
|
||||
Owned<T, Const<D>>: Copy,
|
||||
InnerOwned<T, Const<D>>: Copy,
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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<T, D> + Arbitrary + Send,
|
||||
Owned<T, crate::Const<D>>: Send,
|
||||
InnerOwned<T, crate::Const<D>>: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(rng: &mut Gen) -> Self {
|
||||
|
@ -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<T: hash::Hash, C: TCategory, const D: usize> hash::Hash for Transform<T, C,
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: hash::Hash,
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: hash::Hash,
|
||||
{
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.matrix.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T: Copy, C: TCategory, const D: usize> Copy for Transform<T, C, D>
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Copy,
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Copy,
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
impl<T: Clone, C: TCategory, const D: usize> Clone for Transform<T, C, D>
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Clone,
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
@ -202,7 +204,7 @@ impl<T: Debug, C: TCategory, const D: usize> Debug for Transform<T, C, D>
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Debug,
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Transform")
|
||||
@ -216,7 +218,7 @@ impl<T, C: TCategory, const D: usize> Serialize for Transform<T, C, D>
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Serialize,
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Serialize,
|
||||
{
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
@ -231,7 +233,7 @@ impl<'a, T, C: TCategory, const D: usize> Deserialize<'a> for Transform<T, C, D>
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Deserialize<'a>,
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Deserialize<'a>,
|
||||
{
|
||||
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
|
||||
where
|
||||
@ -551,7 +553,7 @@ where
|
||||
C: SubTCategoryOf<TProjective>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
|
||||
+ Allocator<T, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Clone,
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Clone,
|
||||
{
|
||||
/// Transform the given point by the inverse of this transformation.
|
||||
/// This may be cheaper than inverting the transformation and transforming
|
||||
|
@ -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<D>: DimNameAdd<U1>, CA: SuperTCategoryOf<CB>, CB: SubTCategoryOf<TProjective>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Clone;
|
||||
InnerOwned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Clone;
|
||||
self: Transform<T, CA, D>, rhs: Transform<T, CB, D>;
|
||||
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
||||
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.clone().inverse() };
|
||||
|
@ -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<T, const D: usize> {
|
||||
|
||||
impl<T: hash::Hash, const D: usize> hash::Hash for Translation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>>: hash::Hash,
|
||||
InnerOwned<T, Const<D>>: hash::Hash,
|
||||
{
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.vector.hash(state)
|
||||
@ -42,7 +42,7 @@ impl<T: Copy, const D: usize> Copy for Translation<T, D> {}
|
||||
|
||||
impl<T: Clone, const D: usize> Clone for Translation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>>: Clone,
|
||||
InnerOwned<T, Const<D>>: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
@ -71,7 +71,7 @@ where
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<T, const D: usize> Serialize for Translation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>>: Serialize,
|
||||
InnerOwned<T, Const<D>>: Serialize,
|
||||
{
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
@ -84,7 +84,7 @@ where
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<'a, T, const D: usize> Deserialize<'a> for Translation<T, D>
|
||||
where
|
||||
Owned<T, Const<D>>: Deserialize<'a>,
|
||||
InnerOwned<T, Const<D>>: Deserialize<'a>,
|
||||
{
|
||||
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
|
||||
where
|
||||
|
@ -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<T: Scalar + Arbitrary + Send, const D: usize> Arbitrary for Translation<T, D>
|
||||
where
|
||||
Owned<T, crate::Const<D>>: Send,
|
||||
InnerOwned<T, crate::Const<D>>: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn arbitrary(rng: &mut Gen) -> Self {
|
||||
|
@ -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<T, R, C>
|
||||
+ Allocator<T, DimMinimum<R, C>>
|
||||
+ Allocator<T, DimDiff<DimMinimum<R, C>, U1>>,
|
||||
Owned<T, R, C>: Clone,
|
||||
Owned<T, DimMinimum<R, C>>: Clone,
|
||||
Owned<T, DimDiff<DimMinimum<R, C>, U1>>: Clone,
|
||||
InnerOwned<T, R, C>: Clone,
|
||||
InnerOwned<T, DimMinimum<R, C>>: Clone,
|
||||
InnerOwned<T, DimDiff<DimMinimum<R, C>, U1>>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -72,17 +72,19 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T: ComplexField, R: DimMin<C>, C: Dim> Copy for Bidiagonal<T, R, C>
|
||||
where
|
||||
DimMinimum<R, C>: DimSub<U1>,
|
||||
DefaultAllocator: Allocator<T, R, C>
|
||||
+ Allocator<T, DimMinimum<R, C>>
|
||||
+ Allocator<T, DimDiff<DimMinimum<R, C>, U1>>,
|
||||
Owned<T, R, C>: Copy,
|
||||
Owned<T, DimMinimum<R, C>>: Copy,
|
||||
Owned<T, DimDiff<DimMinimum<R, C>, U1>>: Copy,
|
||||
InnerOwned<T, R, C>: Copy,
|
||||
InnerOwned<T, DimMinimum<R, C>>: Copy,
|
||||
InnerOwned<T, DimDiff<DimMinimum<R, C>, U1>>: Copy,
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
impl<T: ComplexField, R: DimMin<C>, C: Dim> fmt::Debug for Bidiagonal<T, R, C>
|
||||
where
|
||||
@ -90,9 +92,9 @@ where
|
||||
DefaultAllocator: Allocator<T, R, C>
|
||||
+ Allocator<T, DimMinimum<R, C>>
|
||||
+ Allocator<T, DimDiff<DimMinimum<R, C>, U1>>,
|
||||
Owned<T, R, C>: fmt::Debug,
|
||||
Owned<T, DimMinimum<R, C>>: fmt::Debug,
|
||||
Owned<T, DimDiff<DimMinimum<R, C>, U1>>: fmt::Debug,
|
||||
InnerOwned<T, R, C>: fmt::Debug,
|
||||
InnerOwned<T, DimMinimum<R, C>>: fmt::Debug,
|
||||
InnerOwned<T, DimDiff<DimMinimum<R, C>, U1>>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Bidiagonal")
|
||||
|
@ -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<T, D, D>,
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T: SimdComplexField, D: Dim> Copy for Cholesky<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D>,
|
||||
Owned<T, D, D>: Copy,
|
||||
InnerOwned<T, D, D>: Copy,
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
impl<T: SimdComplexField, D: Dim> Clone for Cholesky<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D>,
|
||||
Owned<T, D, D>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -55,7 +57,7 @@ where
|
||||
impl<T: SimdComplexField, D: Dim> fmt::Debug for Cholesky<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D>,
|
||||
Owned<T, D, D>: fmt::Debug,
|
||||
InnerOwned<T, D, D>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Cholesky")
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
DefaultAllocator,
|
||||
},
|
||||
convert,
|
||||
storage::Owned,
|
||||
storage::InnerOwned,
|
||||
try_convert, ComplexField, OMatrix, RealField,
|
||||
};
|
||||
|
||||
@ -435,7 +435,7 @@ where
|
||||
+ Allocator<T, D>
|
||||
+ Allocator<T::RealField, D>
|
||||
+ Allocator<T::RealField, D, D>,
|
||||
Owned<T, D, D>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
{
|
||||
/// Computes exponential of this matrix
|
||||
#[must_use]
|
||||
|
@ -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<T, DimDiff<D, U1>>,
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T: ComplexField, D: DimSub<U1>> Copy for Hessenberg<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
|
||||
Owned<T, D, D>: Copy,
|
||||
Owned<T, DimDiff<D, U1>>: Copy,
|
||||
InnerOwned<T, D, D>: Copy,
|
||||
InnerOwned<T, DimDiff<D, U1>>: Copy,
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
impl<T: ComplexField, D: DimSub<U1>> Clone for Hessenberg<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
|
||||
Owned<T, D, D>: Clone,
|
||||
Owned<T, DimDiff<D, U1>>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
InnerOwned<T, DimDiff<D, U1>>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -62,8 +64,8 @@ where
|
||||
impl<T: ComplexField, D: DimSub<U1>> fmt::Debug for Hessenberg<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
|
||||
Owned<T, D, D>: fmt::Debug,
|
||||
Owned<T, DimDiff<D, U1>>: fmt::Debug,
|
||||
InnerOwned<T, D, D>: fmt::Debug,
|
||||
InnerOwned<T, DimDiff<D, U1>>: 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<T, D, D>
|
||||
where
|
||||
Owned<T, D, D>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
{
|
||||
let dim = self.hess.nrows();
|
||||
let mut res = self.hess.clone();
|
||||
|
@ -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<DimMinimum<R, C>>,
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T: Copy, R: DimMin<C>, C: Dim> Copy for LU<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<(usize, usize), DimMinimum<R, C>>,
|
||||
PermutationSequence<DimMinimum<R, C>>: Copy,
|
||||
Owned<T, R, C>: Copy,
|
||||
InnerOwned<T, R, C>: Copy,
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
impl<T: Clone, R: DimMin<C>, C: Dim> Clone for LU<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<(usize, usize), DimMinimum<R, C>>,
|
||||
PermutationSequence<DimMinimum<R, C>>: Clone,
|
||||
Owned<T, R, C>: Clone,
|
||||
InnerOwned<T, R, C>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -63,7 +65,7 @@ impl<T: ComplexField, R: DimMin<C>, C: Dim> fmt::Debug for LU<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<(usize, usize), DimMinimum<R, C>>,
|
||||
PermutationSequence<DimMinimum<R, C>>: fmt::Debug,
|
||||
Owned<T, R, C>: fmt::Debug,
|
||||
InnerOwned<T, R, C>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("LU")
|
||||
|
@ -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<MaybeUninit<(usize, usize)>, D, U1>,
|
||||
InnerOwned<MaybeUninit<(usize, usize)>, D, U1>,
|
||||
>,
|
||||
>,
|
||||
>,
|
||||
|
@ -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<T, DimMinimum<R, C>>,
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T: Copy, R: DimMin<C>, C: Dim> Copy for QR<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<T, DimMinimum<R, C>>,
|
||||
Owned<T, R, C>: Copy,
|
||||
Owned<T, DimMinimum<R, C>>: Copy,
|
||||
InnerOwned<T, R, C>: Copy,
|
||||
InnerOwned<T, DimMinimum<R, C>>: Copy,
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
impl<T: Clone, R: DimMin<C>, C: Dim> Clone for QR<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<T, DimMinimum<R, C>>,
|
||||
Owned<T, R, C>: Clone,
|
||||
Owned<T, DimMinimum<R, C>>: Clone,
|
||||
InnerOwned<T, R, C>: Clone,
|
||||
InnerOwned<T, DimMinimum<R, C>>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -64,8 +66,8 @@ where
|
||||
impl<T: fmt::Debug, R: DimMin<C>, C: Dim> fmt::Debug for QR<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C> + Allocator<T, DimMinimum<R, C>>,
|
||||
Owned<T, R, C>: fmt::Debug,
|
||||
Owned<T, DimMinimum<R, C>>: fmt::Debug,
|
||||
InnerOwned<T, R, C>: fmt::Debug,
|
||||
InnerOwned<T, DimMinimum<R, C>>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("QR")
|
||||
|
@ -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<T, D, D>,
|
||||
}
|
||||
|
||||
impl<T: Copy, D: Dim> Copy for Schur<T, D>
|
||||
impl<T: Copy, D: DimName> Copy for Schur<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D>,
|
||||
Owned<T, D, D>: Copy,
|
||||
@ -52,7 +54,7 @@ where
|
||||
impl<T: Clone, D: Dim> Clone for Schur<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D>,
|
||||
Owned<T, D, D>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -65,7 +67,7 @@ where
|
||||
impl<T: fmt::Debug, D: Dim> fmt::Debug for Schur<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D>,
|
||||
Owned<T, D, D>: fmt::Debug,
|
||||
InnerOwned<T, D, D>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Schur")
|
||||
|
@ -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<T::RealField, DimMinimum<R, C>>,
|
||||
}
|
||||
|
||||
impl<T: ComplexField, R: DimMin<C>, C: Dim> Copy for SVD<T, R, C>
|
||||
impl<T: ComplexField + Copy, R: DimName + DimMin<C>, C: DimName> Copy for SVD<T, R, C>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, DimMinimum<R, C>, C>
|
||||
+ Allocator<T, R, DimMinimum<R, C>>
|
||||
+ Allocator<T::RealField, DimMinimum<R, C>>,
|
||||
Owned<T, R, DimMinimum<R, C>>: Copy,
|
||||
Owned<T, DimMinimum<R, C>, C>: Copy,
|
||||
Owned<T::RealField, DimMinimum<R, C>>: Copy,
|
||||
InnerOwned<T, R, DimMinimum<R, C>>: Copy,
|
||||
InnerOwned<T, DimMinimum<R, C>, C>: Copy,
|
||||
InnerOwned<T::RealField, DimMinimum<R, C>>: Copy,
|
||||
{
|
||||
}
|
||||
|
||||
@ -71,9 +71,9 @@ where
|
||||
DefaultAllocator: Allocator<T, DimMinimum<R, C>, C>
|
||||
+ Allocator<T, R, DimMinimum<R, C>>
|
||||
+ Allocator<T::RealField, DimMinimum<R, C>>,
|
||||
Owned<T, R, DimMinimum<R, C>>: Clone,
|
||||
Owned<T, DimMinimum<R, C>, C>: Clone,
|
||||
Owned<T::RealField, DimMinimum<R, C>>: Clone,
|
||||
InnerOwned<T, R, DimMinimum<R, C>>: Clone,
|
||||
InnerOwned<T, DimMinimum<R, C>, C>: Clone,
|
||||
InnerOwned<T::RealField, DimMinimum<R, C>>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -89,9 +89,9 @@ where
|
||||
DefaultAllocator: Allocator<T, DimMinimum<R, C>, C>
|
||||
+ Allocator<T, R, DimMinimum<R, C>>
|
||||
+ Allocator<T::RealField, DimMinimum<R, C>>,
|
||||
Owned<T, R, DimMinimum<R, C>>: fmt::Debug,
|
||||
Owned<T, DimMinimum<R, C>, C>: fmt::Debug,
|
||||
Owned<T::RealField, DimMinimum<R, C>>: fmt::Debug,
|
||||
InnerOwned<T, R, DimMinimum<R, C>>: fmt::Debug,
|
||||
InnerOwned<T, DimMinimum<R, C>, C>: fmt::Debug,
|
||||
InnerOwned<T::RealField, DimMinimum<R, C>>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("SVD")
|
||||
|
@ -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<T::RealField, D>,
|
||||
}
|
||||
|
||||
impl<T: ComplexField, D: Dim> Copy for SymmetricEigen<T, D>
|
||||
impl<T: ComplexField, D: DimName> Copy for SymmetricEigen<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T::RealField, D>,
|
||||
Owned<T, D, D>: Copy,
|
||||
Owned<T::RealField, D>: Copy,
|
||||
InnerOwned<T, D, D>: Copy,
|
||||
InnerOwned<T::RealField, D>: Copy,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T: ComplexField, D: Dim> Clone for SymmetricEigen<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T::RealField, D>,
|
||||
Owned<T, D, D>: Clone,
|
||||
Owned<T::RealField, D>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
InnerOwned<T::RealField, D>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -67,8 +67,8 @@ where
|
||||
impl<T: ComplexField, D: Dim> fmt::Debug for SymmetricEigen<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T::RealField, D>,
|
||||
Owned<T, D, D>: fmt::Debug,
|
||||
Owned<T::RealField, D>: fmt::Debug,
|
||||
InnerOwned<T, D, D>: fmt::Debug,
|
||||
InnerOwned<T::RealField, D>: 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<T, D, D>
|
||||
where
|
||||
Owned<T, D, D>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
{
|
||||
let mut u_t = self.eigenvectors.clone();
|
||||
for i in 0..self.eigenvalues.len() {
|
||||
|
@ -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<T, DimDiff<D, U1>>,
|
||||
}
|
||||
|
||||
impl<T: Copy, D: DimSub<U1>> Copy for SymmetricTridiagonal<T, D>
|
||||
impl<T: Copy, D: DimSub<U1> + DimName> Copy for SymmetricTridiagonal<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
|
||||
Owned<T, D, D>: Copy,
|
||||
Owned<T, DimDiff<D, U1>>: Copy,
|
||||
InnerOwned<T, D, D>: Copy,
|
||||
InnerOwned<T, DimDiff<D, U1>>: Copy,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T: Clone, D: DimSub<U1>> Clone for SymmetricTridiagonal<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
|
||||
Owned<T, D, D>: Clone,
|
||||
Owned<T, DimDiff<D, U1>>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
InnerOwned<T, DimDiff<D, U1>>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -61,8 +61,8 @@ where
|
||||
impl<T: fmt::Debug, D: DimSub<U1>> fmt::Debug for SymmetricTridiagonal<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
|
||||
Owned<T, D, D>: fmt::Debug,
|
||||
Owned<T, DimDiff<D, U1>>: fmt::Debug,
|
||||
InnerOwned<T, D, D>: fmt::Debug,
|
||||
InnerOwned<T, DimDiff<D, U1>>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("SymmetricTridiagonal")
|
||||
|
@ -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<T, D>,
|
||||
}
|
||||
|
||||
impl<T: Copy, D: Dim> Copy for UDU<T, D>
|
||||
impl<T: Copy, D: DimName> Copy for UDU<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
|
||||
Owned<T, D>: Copy,
|
||||
Owned<T, D, D>: Copy,
|
||||
InnerOwned<T, D>: Copy,
|
||||
InnerOwned<T, D, D>: Copy,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T: Clone, D: Dim> Clone for UDU<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
|
||||
Owned<T, D>: Clone,
|
||||
Owned<T, D, D>: Clone,
|
||||
InnerOwned<T, D>: Clone,
|
||||
InnerOwned<T, D, D>: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@ -56,8 +56,8 @@ where
|
||||
impl<T: fmt::Debug, D: Dim> fmt::Debug for UDU<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
|
||||
Owned<T, D>: fmt::Debug,
|
||||
Owned<T, D, D>: fmt::Debug,
|
||||
InnerOwned<T, D>: fmt::Debug,
|
||||
InnerOwned<T, D, D>: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("UDU")
|
||||
|
Loading…
Reference in New Issue
Block a user