pub struct Shape(/* private fields */);
Implementations§
Source§impl Shape
impl Shape
pub fn from_dims(dims: &[usize]) -> Self
Sourcepub fn rank(&self) -> usize
pub fn rank(&self) -> usize
The rank is the number of dimensions, 0 for a scalar value, 1 for a vector, etc.
pub fn into_dims(self) -> Vec<usize>
Sourcepub fn dim<D: Dim>(&self, dim: D) -> Result<usize>
pub fn dim<D: Dim>(&self, dim: D) -> Result<usize>
The dimension size for a specified dimension index.
Sourcepub fn elem_count(&self) -> usize
pub fn elem_count(&self) -> usize
The total number of elements, this is the product of all dimension sizes.
Sourcepub fn is_contiguous(&self, stride: &[usize]) -> bool
pub fn is_contiguous(&self, stride: &[usize]) -> bool
Returns true if the strides are C contiguous (aka row major).
Sourcepub fn is_fortran_contiguous(&self, stride: &[usize]) -> bool
pub fn is_fortran_contiguous(&self, stride: &[usize]) -> bool
Returns true if the strides are Fortran contiguous (aka column major).
Sourcepub fn extend(self, additional_dims: &[usize]) -> Self
pub fn extend(self, additional_dims: &[usize]) -> Self
Modifies the shape by adding a list of additional dimensions at the end of the existing dimensions.
Sourcepub fn broadcast_shape_binary_op(
&self,
rhs: &Self,
op: &'static str,
) -> Result<Shape>
pub fn broadcast_shape_binary_op( &self, rhs: &Self, op: &'static str, ) -> Result<Shape>
Check whether the two shapes are compatible for broadcast, and if it is the case return the broadcasted shape. This is to be used for binary pointwise ops.
Trait Implementations§
impl Eq for Shape
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnwindSafe for Shape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more