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 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 stride_contiguous(&self) -> Vec<usize>
pub fn stride_contiguous(&self) -> Vec<usize>
The strides given in number of elements for a contiguous n-dimensional arrays using this shape.
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
)