parent
f9ea9f0795
commit
dba752e91e
|
@ -2,12 +2,13 @@
|
|||
|
||||
//! Traits and tags for identifying the dimension of all algebraic entities.
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::any::{Any, TypeId};
|
||||
use std::cmp;
|
||||
use std::fmt::Debug;
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
use typenum::{self, B1, Bit, Diff, Max, Maximum, Min, Minimum, Prod, Quot, Sum, UInt, UTerm,
|
||||
Unsigned};
|
||||
use typenum::{
|
||||
self, B1, Bit, Diff, Max, Maximum, Min, Minimum, Prod, Quot, Sum, UInt, UTerm, Unsigned,
|
||||
};
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
@ -56,7 +57,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: Any + Debug + Copy + PartialEq + Send {
|
||||
pub trait Dim: Any + Debug + Copy + PartialEq + Send + Sync {
|
||||
#[inline(always)]
|
||||
fn is<D: Dim>() -> bool {
|
||||
TypeId::of::<Self>() == TypeId::of::<D>()
|
||||
|
@ -286,157 +287,40 @@ macro_rules! named_dimension(
|
|||
|
||||
// We give explicit names to all Unsigned in [0, 128[
|
||||
named_dimension!(
|
||||
U0,
|
||||
/*U1,*/ U2,
|
||||
U3,
|
||||
U4,
|
||||
U5,
|
||||
U6,
|
||||
U7,
|
||||
U8,
|
||||
U9,
|
||||
U10,
|
||||
U11,
|
||||
U12,
|
||||
U13,
|
||||
U14,
|
||||
U15,
|
||||
U16,
|
||||
U17,
|
||||
U18,
|
||||
U19,
|
||||
U20,
|
||||
U21,
|
||||
U22,
|
||||
U23,
|
||||
U24,
|
||||
U25,
|
||||
U26,
|
||||
U27,
|
||||
U28,
|
||||
U29,
|
||||
U30,
|
||||
U31,
|
||||
U32,
|
||||
U33,
|
||||
U34,
|
||||
U35,
|
||||
U36,
|
||||
U37,
|
||||
U38,
|
||||
U39,
|
||||
U40,
|
||||
U41,
|
||||
U42,
|
||||
U43,
|
||||
U44,
|
||||
U45,
|
||||
U46,
|
||||
U47,
|
||||
U48,
|
||||
U49,
|
||||
U50,
|
||||
U51,
|
||||
U52,
|
||||
U53,
|
||||
U54,
|
||||
U55,
|
||||
U56,
|
||||
U57,
|
||||
U58,
|
||||
U59,
|
||||
U60,
|
||||
U61,
|
||||
U62,
|
||||
U63,
|
||||
U64,
|
||||
U65,
|
||||
U66,
|
||||
U67,
|
||||
U68,
|
||||
U69,
|
||||
U70,
|
||||
U71,
|
||||
U72,
|
||||
U73,
|
||||
U74,
|
||||
U75,
|
||||
U76,
|
||||
U77,
|
||||
U78,
|
||||
U79,
|
||||
U80,
|
||||
U81,
|
||||
U82,
|
||||
U83,
|
||||
U84,
|
||||
U85,
|
||||
U86,
|
||||
U87,
|
||||
U88,
|
||||
U89,
|
||||
U90,
|
||||
U91,
|
||||
U92,
|
||||
U93,
|
||||
U94,
|
||||
U95,
|
||||
U96,
|
||||
U97,
|
||||
U98,
|
||||
U99,
|
||||
U100,
|
||||
U101,
|
||||
U102,
|
||||
U103,
|
||||
U104,
|
||||
U105,
|
||||
U106,
|
||||
U107,
|
||||
U108,
|
||||
U109,
|
||||
U110,
|
||||
U111,
|
||||
U112,
|
||||
U113,
|
||||
U114,
|
||||
U115,
|
||||
U116,
|
||||
U117,
|
||||
U118,
|
||||
U119,
|
||||
U120,
|
||||
U121,
|
||||
U122,
|
||||
U123,
|
||||
U124,
|
||||
U125,
|
||||
U126,
|
||||
U0, /*U1,*/ U2, U3, U4, U5, U6, U7, U8, U9, U10, U11, U12, U13, U14, U15, U16, U17, U18,
|
||||
U19, U20, U21, U22, U23, U24, U25, U26, U27, U28, U29, U30, U31, U32, U33, U34, U35, U36, U37,
|
||||
U38, U39, U40, U41, U42, U43, U44, U45, U46, U47, U48, U49, U50, U51, U52, U53, U54, U55, U56,
|
||||
U57, U58, U59, U60, U61, U62, U63, U64, U65, U66, U67, U68, U69, U70, U71, U72, U73, U74, U75,
|
||||
U76, U77, U78, U79, U80, U81, U82, U83, U84, U85, U86, U87, U88, U89, U90, U91, U92, U93, U94,
|
||||
U95, U96, U97, U98, U99, U100, U101, U102, U103, U104, U105, U106, U107, U108, U109, U110,
|
||||
U111, U112, U113, U114, U115, U116, U117, U118, U119, U120, U121, U122, U123, U124, U125, U126,
|
||||
U127
|
||||
);
|
||||
|
||||
// For values greater than U1023, just use the typenum binary representation directly.
|
||||
impl<
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
> NamedDim for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G> {
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
> NamedDim for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G>
|
||||
{
|
||||
type Name = Self;
|
||||
}
|
||||
|
||||
impl<
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
> Dim for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G> {
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
> Dim for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G>
|
||||
{
|
||||
#[inline]
|
||||
fn try_to_usize() -> Option<usize> {
|
||||
Some(Self::to_usize())
|
||||
|
@ -455,14 +339,15 @@ impl<
|
|||
}
|
||||
|
||||
impl<
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
> DimName for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G> {
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
> DimName for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G>
|
||||
{
|
||||
type Value = Self;
|
||||
|
||||
#[inline]
|
||||
|
@ -472,23 +357,26 @@ impl<
|
|||
}
|
||||
|
||||
impl<
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send,
|
||||
> IsNotStaticOne
|
||||
for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G> {
|
||||
}
|
||||
A: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
B: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
C: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
D: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
E: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
F: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
G: Bit + Any + Debug + Copy + PartialEq + Send + Sync,
|
||||
> IsNotStaticOne
|
||||
for UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, A>, B>, C>, D>, E>, F>, G>
|
||||
{}
|
||||
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send> NamedDim
|
||||
for UInt<U, B> {
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send + Sync> NamedDim
|
||||
for UInt<U, B>
|
||||
{
|
||||
type Name = UInt<U, B>;
|
||||
}
|
||||
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send> Dim for UInt<U, B> {
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send + Sync> Dim
|
||||
for UInt<U, B>
|
||||
{
|
||||
#[inline]
|
||||
fn try_to_usize() -> Option<usize> {
|
||||
Some(Self::to_usize())
|
||||
|
@ -506,7 +394,9 @@ impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send> Dim
|
|||
}
|
||||
}
|
||||
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send> DimName for UInt<U, B> {
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send + Sync> DimName
|
||||
for UInt<U, B>
|
||||
{
|
||||
type Value = UInt<U, B>;
|
||||
|
||||
#[inline]
|
||||
|
@ -515,6 +405,6 @@ impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send> DimN
|
|||
}
|
||||
}
|
||||
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send> IsNotStaticOne
|
||||
for UInt<U, B> {
|
||||
}
|
||||
impl<U: Unsigned + DimName, B: Bit + Any + Debug + Copy + PartialEq + Send + Sync> IsNotStaticOne
|
||||
for UInt<U, B>
|
||||
{}
|
||||
|
|
|
@ -2,12 +2,12 @@ use std::marker::PhantomData;
|
|||
use std::ops::{Range, RangeFrom, RangeFull, RangeTo};
|
||||
use std::slice;
|
||||
|
||||
use base::{Matrix, Scalar};
|
||||
use base::allocator::Allocator;
|
||||
use base::default_allocator::DefaultAllocator;
|
||||
use base::dimension::{Dim, DimName, Dynamic, U1};
|
||||
use base::iter::MatrixIter;
|
||||
use base::storage::{Owned, Storage, StorageMut};
|
||||
use base::allocator::Allocator;
|
||||
use base::default_allocator::DefaultAllocator;
|
||||
use base::{Matrix, Scalar};
|
||||
|
||||
macro_rules! slice_storage_impl(
|
||||
($doc: expr; $Storage: ident as $SRef: ty; $T: ident.$get_addr: ident ($Ptr: ty as $Ref: ty)) => {
|
||||
|
@ -20,6 +20,14 @@ macro_rules! slice_storage_impl(
|
|||
_phantoms: PhantomData<$Ref>,
|
||||
}
|
||||
|
||||
unsafe impl<'a, N: Scalar + Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send
|
||||
for $T<'a, N, R, C, RStride, CStride>
|
||||
{}
|
||||
|
||||
unsafe impl<'a, N: Scalar + Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync
|
||||
for $T<'a, N, R, C, RStride, CStride>
|
||||
{}
|
||||
|
||||
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> $T<'a, N, R, C, RStride, CStride> {
|
||||
/// Create a new matrix slice without bound checking and from a raw pointer.
|
||||
#[inline]
|
||||
|
@ -82,11 +90,12 @@ slice_storage_impl!("A mutable matrix data storage for mutable matrix slice. Onl
|
|||
);
|
||||
|
||||
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy
|
||||
for SliceStorage<'a, N, R, C, RStride, CStride> {
|
||||
}
|
||||
for SliceStorage<'a, N, R, C, RStride, CStride>
|
||||
{}
|
||||
|
||||
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
|
||||
for SliceStorage<'a, N, R, C, RStride, CStride> {
|
||||
for SliceStorage<'a, N, R, C, RStride, CStride>
|
||||
{
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
SliceStorage {
|
||||
|
@ -171,7 +180,8 @@ macro_rules! storage_impl(
|
|||
storage_impl!(SliceStorage, SliceStorageMut);
|
||||
|
||||
unsafe impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> StorageMut<N, R, C>
|
||||
for SliceStorageMut<'a, N, R, C, RStride, CStride> {
|
||||
for SliceStorageMut<'a, N, R, C, RStride, CStride>
|
||||
{
|
||||
#[inline]
|
||||
fn ptr_mut(&mut self) -> *mut N {
|
||||
self.ptr
|
||||
|
|
Loading…
Reference in New Issue