Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ matrixmultiply-threading = ["matrixmultiply/threading"]

portable-atomic-critical-section = ["portable-atomic/critical-section"]

unstable = []


[target.'cfg(not(target_has_atomic = "ptr"))'.dependencies]
portable-atomic = { version = "1.6.0" }
Expand Down
18 changes: 18 additions & 0 deletions src/dimension/dimension_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use super::conversion::Convert;
use super::ops::DimAdd;
use super::{stride_offset, stride_offset_checked};
use crate::itertools::{enumerate, zip};
#[cfg(feature = "unstable")]
use crate::layout::dimensionality::*;
use crate::IntoDimension;
use crate::RemoveAxis;
use crate::{ArrayView1, ArrayViewMut1};
Expand Down Expand Up @@ -76,6 +78,10 @@ pub trait Dimension:
/// Next larger dimension
type Larger: Dimension + RemoveAxis;

/// The dimensionality of the type, under the new, unstable API.
#[cfg(feature = "unstable")]
type Rank: Dimensionality;

/// Returns the number of dimensions (number of axes).
fn ndim(&self) -> usize;

Expand Down Expand Up @@ -420,6 +426,8 @@ impl Dimension for Dim<[Ix; 0]>
type Pattern = ();
type Smaller = Self;
type Larger = Ix1;
#[cfg(feature = "unstable")]
type Rank = D0;
// empty product is 1 -> size is 1
#[inline]
fn ndim(&self) -> usize
Expand Down Expand Up @@ -470,6 +478,8 @@ impl Dimension for Dim<[Ix; 1]>
type Pattern = Ix;
type Smaller = Ix0;
type Larger = Ix2;
#[cfg(feature = "unstable")]
type Rank = D1;
#[inline]
fn ndim(&self) -> usize
{
Expand Down Expand Up @@ -603,6 +613,8 @@ impl Dimension for Dim<[Ix; 2]>
type Pattern = (Ix, Ix);
type Smaller = Ix1;
type Larger = Ix3;
#[cfg(feature = "unstable")]
type Rank = D2;
#[inline]
fn ndim(&self) -> usize
{
Expand Down Expand Up @@ -778,6 +790,8 @@ impl Dimension for Dim<[Ix; 3]>
type Pattern = (Ix, Ix, Ix);
type Smaller = Ix2;
type Larger = Ix4;
#[cfg(feature = "unstable")]
type Rank = D3;
#[inline]
fn ndim(&self) -> usize
{
Expand Down Expand Up @@ -910,6 +924,8 @@ macro_rules! large_dim {
type Pattern = $pattern;
type Smaller = Dim<[Ix; $n - 1]>;
type Larger = $larger;
#[cfg(feature = "unstable")]
type Rank = NDim<$n>;
#[inline]
fn ndim(&self) -> usize { $n }
#[inline]
Expand Down Expand Up @@ -960,6 +976,8 @@ impl Dimension for IxDyn
type Pattern = Self;
type Smaller = Self;
type Larger = Self;
#[cfg(feature = "unstable")]
type Rank = DDyn;
#[inline]
fn ndim(&self) -> usize
{
Expand Down
Loading