pub struct ViewMut<'a, T, S: Shape = DynRank, L: Layout = Dense> { /* private fields */ }Expand description
Mutable multidimensional array view.
Implementations§
Source§impl<'a, T, S: Shape, L: Layout> ViewMut<'a, T, S, L>
impl<'a, T, S: Shape, L: Layout> ViewMut<'a, T, S, L>
Sourcepub fn into_at(self, index: usize) -> ViewMut<'a, T, S::Tail, L>
pub fn into_at(self, index: usize) -> ViewMut<'a, T, S::Tail, L>
Converts the array view into a new array view indexing the first dimension.
§Panics
Panics if the index is out of bounds, or if the rank is not at least 1.
Sourcepub fn into_axis_at<A: Axis>(
self,
axis: A,
index: usize,
) -> ViewMut<'a, T, A::Remove<S>, Split<A, S, L>>
pub fn into_axis_at<A: Axis>( self, axis: A, index: usize, ) -> ViewMut<'a, T, A::Remove<S>, Split<A, S, L>>
Converts the array view into a new array view indexing the specified dimension.
If the dimension to be indexed is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array view has the same layout as the input.
§Panics
Panics if the dimension or the index is out of bounds.
Sourcepub fn into_col(self, index: usize) -> ViewMut<'a, T, (S::Head,), Strided>
pub fn into_col(self, index: usize) -> ViewMut<'a, T, (S::Head,), Strided>
Converts the array view into a new array view for the specified column.
§Panics
Panics if the rank is not equal to 2, or if the index is out of bounds.
Sourcepub fn into_diag(self, index: isize) -> ViewMut<'a, T, (Dyn,), Strided>
pub fn into_diag(self, index: isize) -> ViewMut<'a, T, (Dyn,), Strided>
Converts the array view into a new array view for the given diagonal,
where index > 0 is above and index < 0 is below the main diagonal.
§Panics
Panics if the rank is not equal to 2, or if the absolute index is larger than the number of columns or rows.
Sourcepub fn into_dyn(self) -> ViewMut<'a, T, DynRank, L>
pub fn into_dyn(self) -> ViewMut<'a, T, DynRank, L>
Converts the array view into an array view with dynamic rank.
Sourcepub fn into_flat(self) -> ViewMut<'a, T, (Dyn,), L>
pub fn into_flat(self) -> ViewMut<'a, T, (Dyn,), L>
Converts the array view into a one-dimensional array view.
§Panics
Panics if the array layout is not uniformly strided.
Sourcepub fn into_mapping<R: Shape, K: Layout>(self) -> ViewMut<'a, T, R, K>
pub fn into_mapping<R: Shape, K: Layout>(self) -> ViewMut<'a, T, R, K>
Converts the array view into a remapped array view.
§Panics
Panics if the shape is not matching static rank or constant-sized dimensions, or if the memory layout is not compatible with the new array layout.
Sourcepub fn into_permuted<I: IntoShape<IntoShape: Permutation>>(
self,
perm: I,
) -> ViewMut<'a, T, <I::IntoShape as Permutation>::Shape<S>, <I::IntoShape as Permutation>::Layout<L>>
pub fn into_permuted<I: IntoShape<IntoShape: Permutation>>( self, perm: I, ) -> ViewMut<'a, T, <I::IntoShape as Permutation>::Shape<S>, <I::IntoShape as Permutation>::Layout<L>>
Converts the array view into a new array view with the dimensions permuted.
If the permutation is an identity permutation and known at compile time, the
resulting array view has the same layout as the input. For example, permuting
with (Const::<0>, Const::<1>) will maintain the layout while permuting with
[0, 1] gives strided layout.
§Panics
Panics if the permutation is not valid.
Sourcepub fn into_reordered(
self,
) -> ViewMut<'a, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
👎Deprecated
pub fn into_reordered( self, ) -> ViewMut<'a, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
Converts the array view into a reordered array view.
This method is deprecated, use into_transposed instead.
Sourcepub fn into_row(
self,
index: usize,
) -> ViewMut<'a, T, (<S::Tail as Shape>::Head,), L>
pub fn into_row( self, index: usize, ) -> ViewMut<'a, T, (<S::Tail as Shape>::Head,), L>
Converts the array view into a new array view for the specified row.
§Panics
Panics if the rank is not equal to 2, or if the index is out of bounds.
Sourcepub fn into_shape<I: IntoShape>(
self,
shape: I,
) -> ViewMut<'a, T, I::IntoShape, L>
pub fn into_shape<I: IntoShape>( self, shape: I, ) -> ViewMut<'a, T, I::IntoShape, L>
Converts the array view into a reshaped array view.
At most one dimension can have dynamic size usize::MAX, and is then inferred
from the other dimensions and the array length.
§Examples
use mdarray::view;
let v = view![[1, 2, 3], [4, 5, 6]];
assert_eq!(v.into_shape([!0, 2]), view![[1, 2], [3, 4], [5, 6]]);§Panics
Panics if the array length is changed, or if the memory layout is not compatible.
Sourcepub fn into_split_at(
self,
mid: usize,
) -> (ViewMut<'a, T, Resize<Const<0>, S>, L>, ViewMut<'a, T, Resize<Const<0>, S>, L>)
pub fn into_split_at( self, mid: usize, ) -> (ViewMut<'a, T, Resize<Const<0>, S>, L>, ViewMut<'a, T, Resize<Const<0>, S>, L>)
Divides the array view into two at an index along the first dimension.
§Panics
Panics if the split point is larger than the number of elements in that dimension, or if the rank is not at least 1.
Sourcepub fn into_split_axis_at<A: Axis>(
self,
axis: A,
mid: usize,
) -> (ViewMut<'a, T, Resize<A, S>, Split<A, S, L>>, ViewMut<'a, T, Resize<A, S>, Split<A, S, L>>)
pub fn into_split_axis_at<A: Axis>( self, axis: A, mid: usize, ) -> (ViewMut<'a, T, Resize<A, S>, Split<A, S, L>>, ViewMut<'a, T, Resize<A, S>, Split<A, S, L>>)
Divides the array view into two at an index along the specified dimension.
If the dimension to be divided is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array views have the same layout as the input.
§Panics
Panics if the split point is larger than the number of elements in that dimension, or if the dimension is out of bounds.
Sourcepub fn into_transposed(
self,
) -> ViewMut<'a, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
pub fn into_transposed( self, ) -> ViewMut<'a, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
Converts the array view into a transposed array view, where the dimensions are reversed.
Sourcepub unsafe fn new_unchecked(ptr: *mut T, mapping: L::Mapping<S>) -> Self
pub unsafe fn new_unchecked(ptr: *mut T, mapping: L::Mapping<S>) -> Self
Creates an array view from a raw pointer and layout.
§Safety
The pointer must be non-null and a valid array view for the given layout.
Source§impl<'a, T, X: Dim, Y: Dim, Z: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z), L>
impl<'a, T, X: Dim, Y: Dim, Z: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z), L>
Sourcepub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex>(
self,
a: A,
b: B,
c: C,
) -> ViewMut<'a, T, <(A, B, C) as ViewIndex>::Shape<(X, Y, Z)>, <(A, B, C) as ViewIndex>::Layout<L>>
pub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex>( self, a: A, b: B, c: C, ) -> ViewMut<'a, T, <(A, B, C) as ViewIndex>::Shape<(X, Y, Z)>, <(A, B, C) as ViewIndex>::Layout<L>>
Converts the array view into a new array view for the specified subarray.
§Panics
Panics if the subarray is out of bounds.
Source§impl<'a, T, X: Dim, Y: Dim, Z: Dim, W: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z, W), L>
impl<'a, T, X: Dim, Y: Dim, Z: Dim, W: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z, W), L>
Sourcepub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex, D: DimIndex>(
self,
a: A,
b: B,
c: C,
d: D,
) -> ViewMut<'a, T, <(A, B, C, D) as ViewIndex>::Shape<(X, Y, Z, W)>, <(A, B, C, D) as ViewIndex>::Layout<L>>
pub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex, D: DimIndex>( self, a: A, b: B, c: C, d: D, ) -> ViewMut<'a, T, <(A, B, C, D) as ViewIndex>::Shape<(X, Y, Z, W)>, <(A, B, C, D) as ViewIndex>::Layout<L>>
Converts the array view into a new array view for the specified subarray.
§Panics
Panics if the subarray is out of bounds.
Source§impl<'a, T, X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z, W, U), L>
impl<'a, T, X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z, W, U), L>
Sourcepub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex, D: DimIndex, E: DimIndex>(
self,
a: A,
b: B,
c: C,
d: D,
e: E,
) -> ViewMut<'a, T, <(A, B, C, D, E) as ViewIndex>::Shape<(X, Y, Z, W, U)>, <(A, B, C, D, E) as ViewIndex>::Layout<L>>
pub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex, D: DimIndex, E: DimIndex>( self, a: A, b: B, c: C, d: D, e: E, ) -> ViewMut<'a, T, <(A, B, C, D, E) as ViewIndex>::Shape<(X, Y, Z, W, U)>, <(A, B, C, D, E) as ViewIndex>::Layout<L>>
Converts the array view into a new array view for the specified subarray.
§Panics
Panics if the subarray is out of bounds.
Source§impl<'a, T, X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim, V: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z, W, U, V), L>
impl<'a, T, X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim, V: Dim, L: Layout> ViewMut<'a, T, (X, Y, Z, W, U, V), L>
Sourcepub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex, D: DimIndex, E: DimIndex, F: DimIndex>(
self,
a: A,
b: B,
c: C,
d: D,
e: E,
f: F,
) -> ViewMut<'a, T, <(A, B, C, D, E, F) as ViewIndex>::Shape<(X, Y, Z, W, U, V)>, <(A, B, C, D, E, F) as ViewIndex>::Layout<L>>
pub fn into_view<A: DimIndex, B: DimIndex, C: DimIndex, D: DimIndex, E: DimIndex, F: DimIndex>( self, a: A, b: B, c: C, d: D, e: E, f: F, ) -> ViewMut<'a, T, <(A, B, C, D, E, F) as ViewIndex>::Shape<(X, Y, Z, W, U, V)>, <(A, B, C, D, E, F) as ViewIndex>::Layout<L>>
Converts the array view into a new array view for the specified subarray.
§Panics
Panics if the subarray is out of bounds.
Methods from Deref<Target = Slice<T, S, L>>§
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns a mutable pointer to the array buffer.
Sourcepub fn assign<I: IntoExpression<Item: IntoCloned<T>>>(&mut self, expr: I)
pub fn assign<I: IntoExpression<Item: IntoCloned<T>>>(&mut self, expr: I)
Assigns an expression to the array slice with broadcasting, cloning elements if needed.
§Panics
Panics if the expression cannot be broadcast to the shape of the array slice.
Sourcepub fn at(&self, index: usize) -> View<'_, T, S::Tail, L>
pub fn at(&self, index: usize) -> View<'_, T, S::Tail, L>
Returns an array view after indexing the first dimension.
§Panics
Panics if the index is out of bounds, or if the rank is not at least 1.
Sourcepub fn at_mut(&mut self, index: usize) -> ViewMut<'_, T, S::Tail, L>
pub fn at_mut(&mut self, index: usize) -> ViewMut<'_, T, S::Tail, L>
Returns a mutable array view after indexing the first dimension.
§Panics
Panics if the index is out of bounds, or if the rank is not at least 1.
Sourcepub fn axis_at<A: Axis>(
&self,
axis: A,
index: usize,
) -> View<'_, T, A::Remove<S>, Split<A, S, L>>
pub fn axis_at<A: Axis>( &self, axis: A, index: usize, ) -> View<'_, T, A::Remove<S>, Split<A, S, L>>
Returns an array view after indexing the specified dimension.
If the dimension to be indexed is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array view has the same layout as the input.
§Panics
Panics if the dimension or the index is out of bounds.
Sourcepub fn axis_at_mut<A: Axis>(
&mut self,
axis: A,
index: usize,
) -> ViewMut<'_, T, A::Remove<S>, Split<A, S, L>>
pub fn axis_at_mut<A: Axis>( &mut self, axis: A, index: usize, ) -> ViewMut<'_, T, A::Remove<S>, Split<A, S, L>>
Returns a mutable array view after indexing the specified dimension.
If the dimension to be indexed is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array view has the same layout as the input.
§Panics
Panics if the dimension or the index is out of bounds.
Sourcepub fn axis_expr<A: Axis>(&self, axis: A) -> AxisExpr<'_, T, S, L, A>
pub fn axis_expr<A: Axis>(&self, axis: A) -> AxisExpr<'_, T, S, L, A>
Returns an expression that gives array views iterating over the specified dimension.
If the dimension to be iterated over is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array views have the same layout as the input.
§Panics
Panics if the dimension is out of bounds.
Sourcepub fn axis_expr_mut<A: Axis>(&mut self, axis: A) -> AxisExprMut<'_, T, S, L, A>
pub fn axis_expr_mut<A: Axis>(&mut self, axis: A) -> AxisExprMut<'_, T, S, L, A>
Returns a mutable expression that gives array views iterating over the specified dimension.
If the dimension to be iterated over is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array views have the same layout as the input.
§Panics
Panics if the dimension is out of bounds.
Sourcepub fn col(&self, index: usize) -> View<'_, T, (S::Head,), Strided>
pub fn col(&self, index: usize) -> View<'_, T, (S::Head,), Strided>
Returns an array view for the specified column.
§Panics
Panics if the rank is not equal to 2, or if the index is out of bounds.
Sourcepub fn col_mut(&mut self, index: usize) -> ViewMut<'_, T, (S::Head,), Strided>
pub fn col_mut(&mut self, index: usize) -> ViewMut<'_, T, (S::Head,), Strided>
Returns a mutable array view for the specified column.
§Panics
Panics if the rank is not equal to 2, or if the index is out of bounds.
Sourcepub fn cols(&self) -> Lanes<'_, T, S, L, Cols>
pub fn cols(&self) -> Lanes<'_, T, S, L, Cols>
Returns an expression that gives column views iterating over the other dimensions.
§Panics
Panics if the rank is not at least 2.
Sourcepub fn cols_mut(&mut self) -> LanesMut<'_, T, S, L, Cols>
pub fn cols_mut(&mut self) -> LanesMut<'_, T, S, L, Cols>
Returns a mutable expression that gives column views iterating over the other dimensions.
§Panics
Panics if the rank is not at least 2.
Sourcepub fn contains(&self, x: &T) -> boolwhere
T: PartialEq,
pub fn contains(&self, x: &T) -> boolwhere
T: PartialEq,
Returns true if the array slice contains an element with the given value.
Sourcepub fn diag(&self, index: isize) -> View<'_, T, (Dyn,), Strided>
pub fn diag(&self, index: isize) -> View<'_, T, (Dyn,), Strided>
Returns an array view for the given diagonal of the array slice,
where index > 0 is above and index < 0 is below the main diagonal.
§Panics
Panics if the rank is not equal to 2, or if the absolute index is larger than the number of columns or rows.
Sourcepub fn diag_mut(&mut self, index: isize) -> ViewMut<'_, T, (Dyn,), Strided>
pub fn diag_mut(&mut self, index: isize) -> ViewMut<'_, T, (Dyn,), Strided>
Returns a mutable array view for the given diagonal of the array slice,
where index > 0 is above and index < 0 is below the main diagonal.
§Panics
Panics if the rank is not equal to 2, or if the absolute index is larger than the number of columns or rows.
Sourcepub fn dim(&self, index: usize) -> usize
pub fn dim(&self, index: usize) -> usize
Returns the number of elements in the specified dimension.
§Panics
Panics if the dimension is out of bounds.
Sourcepub fn expr_mut(&mut self) -> ViewMut<'_, T, S, L>
pub fn expr_mut(&mut self) -> ViewMut<'_, T, S, L>
Returns a mutable expression over the array slice.
Sourcepub fn fill(&mut self, value: T)where
T: Clone,
pub fn fill(&mut self, value: T)where
T: Clone,
Fills the array slice with elements by cloning value.
Sourcepub fn fill_with<F: FnMut() -> T>(&mut self, f: F)
pub fn fill_with<F: FnMut() -> T>(&mut self, f: F)
Fills the array slice with elements returned by calling a closure repeatedly.
Sourcepub fn flatten(&self) -> View<'_, T, (Dyn,), L>
pub fn flatten(&self) -> View<'_, T, (Dyn,), L>
Returns a one-dimensional array view of the array slice.
§Panics
Panics if the array layout is not uniformly strided.
Sourcepub fn flatten_mut(&mut self) -> ViewMut<'_, T, (Dyn,), L>
pub fn flatten_mut(&mut self) -> ViewMut<'_, T, (Dyn,), L>
Returns a mutable one-dimensional array view over the array slice.
§Panics
Panics if the array layout is not uniformly strided.
Sourcepub unsafe fn get_unchecked<I: SliceIndex<T, S, L>>(
&self,
index: I,
) -> &I::Output
pub unsafe fn get_unchecked<I: SliceIndex<T, S, L>>( &self, index: I, ) -> &I::Output
Returns a reference to an element or a subslice, without doing bounds checking.
§Safety
The index must be within bounds of the array slice.
Sourcepub unsafe fn get_unchecked_mut<I: SliceIndex<T, S, L>>(
&mut self,
index: I,
) -> &mut I::Output
pub unsafe fn get_unchecked_mut<I: SliceIndex<T, S, L>>( &mut self, index: I, ) -> &mut I::Output
Returns a mutable reference to an element or a subslice, without doing bounds checking.
§Safety
The index must be within bounds of the array slice.
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Returns true if the array strides are consistent with contiguous memory layout.
Sourcepub fn iter_mut(&mut self) -> Iter<ViewMut<'_, T, S, L>> ⓘ
pub fn iter_mut(&mut self) -> Iter<ViewMut<'_, T, S, L>> ⓘ
Returns a mutable iterator over the array slice.
Sourcepub fn lanes<A: Axis>(&self, axis: A) -> Lanes<'_, T, S, L, A>
pub fn lanes<A: Axis>(&self, axis: A) -> Lanes<'_, T, S, L, A>
Returns an expression that gives array views over the specified dimension, iterating over the other dimensions.
If the dimension to give array views over is know at compile time, the resulting shape will maintain a constant-sized dimension. Furthermore, if it is the last dimension the resulting array views have the same layout as the input.
§Panics
Panics if the dimension is out of bounds.
Sourcepub fn lanes_mut<A: Axis>(&mut self, axis: A) -> LanesMut<'_, T, S, L, A>
pub fn lanes_mut<A: Axis>(&mut self, axis: A) -> LanesMut<'_, T, S, L, A>
Returns a mutable expression that gives array views over the specified dimension, iterating over the other dimensions.
If the dimension to give array views over is know at compile time, the resulting shape will maintain a constant-sized dimension. Furthermore, if it is the last dimension the resulting array views have the same layout as the input.
§Panics
Panics if the dimension is out of bounds.
Sourcepub fn outer_expr(&self) -> AxisExpr<'_, T, S, L, Const<0>>
pub fn outer_expr(&self) -> AxisExpr<'_, T, S, L, Const<0>>
Returns an expression that gives array views iterating over the first dimension.
Iterating over the first dimension results in array views with the same layout as the input.
§Panics
Panics if the rank is not at least 1.
Sourcepub fn outer_expr_mut(&mut self) -> AxisExprMut<'_, T, S, L, Const<0>>
pub fn outer_expr_mut(&mut self) -> AxisExprMut<'_, T, S, L, Const<0>>
Returns a mutable expression that gives array views iterating over the first dimension.
Iterating over the first dimension results in array views with the same layout as the input.
§Panics
Panics if the rank is not at least 1.
Sourcepub fn permute<I: IntoShape<IntoShape: Permutation>>(
&self,
perm: I,
) -> View<'_, T, <I::IntoShape as Permutation>::Shape<S>, <I::IntoShape as Permutation>::Layout<L>>
pub fn permute<I: IntoShape<IntoShape: Permutation>>( &self, perm: I, ) -> View<'_, T, <I::IntoShape as Permutation>::Shape<S>, <I::IntoShape as Permutation>::Layout<L>>
Returns an array view with the dimensions permuted.
If the permutation is an identity permutation and known at compile time, the
resulting array view has the same layout as the input. For example, permuting
with (Const::<0>, Const::<1>) will maintain the layout while permuting with
[0, 1] gives strided layout.
§Panics
Panics if the permutation is not valid.
Sourcepub fn permute_mut<I: IntoShape<IntoShape: Permutation>>(
&mut self,
perm: I,
) -> ViewMut<'_, T, <I::IntoShape as Permutation>::Shape<S>, <I::IntoShape as Permutation>::Layout<L>>
pub fn permute_mut<I: IntoShape<IntoShape: Permutation>>( &mut self, perm: I, ) -> ViewMut<'_, T, <I::IntoShape as Permutation>::Shape<S>, <I::IntoShape as Permutation>::Layout<L>>
Returns a mutable array view with the dimensions permuted.
If the permutation is an identity permutation and known at compile time, the
resulting array view has the same layout as the input. For example, permuting
with (Const::<0>, Const::<1>) will maintain the layout while permuting with
[0, 1] gives strided layout.
§Panics
Panics if the permutation is not valid.
Sourcepub fn remap<R: Shape, K: Layout>(&self) -> View<'_, T, R, K>
pub fn remap<R: Shape, K: Layout>(&self) -> View<'_, T, R, K>
Returns a remapped array view of the array slice.
§Panics
Panics if the memory layout is not compatible with the new array layout.
Sourcepub fn remap_mut<R: Shape, K: Layout>(&mut self) -> ViewMut<'_, T, R, K>
pub fn remap_mut<R: Shape, K: Layout>(&mut self) -> ViewMut<'_, T, R, K>
Returns a mutable remapped array view of the array slice.
§Panics
Panics if the memory layout is not compatible with the new array layout.
Sourcepub fn reorder(&self) -> View<'_, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
👎Deprecated
pub fn reorder(&self) -> View<'_, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
Returns a reordered array view of the array slice.
This method is deprecated, use transpose instead.
Sourcepub fn reorder_mut(
&mut self,
) -> ViewMut<'_, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
👎Deprecated
pub fn reorder_mut( &mut self, ) -> ViewMut<'_, T, S::Reverse, <S::Tail as Shape>::Layout<L>>
Returns a mutable reordered array view of the array slice.
This method is deprecated, use transpose_mut instead.
Sourcepub fn reshape<I: IntoShape>(&self, shape: I) -> View<'_, T, I::IntoShape, L>
pub fn reshape<I: IntoShape>(&self, shape: I) -> View<'_, T, I::IntoShape, L>
Returns a reshaped array view of the array slice.
At most one dimension can have dynamic size usize::MAX, and is then inferred
from the other dimensions and the array length.
§Examples
use mdarray::view;
let v = view![[1, 2, 3], [4, 5, 6]];
assert_eq!(v.reshape([!0, 2]), view![[1, 2], [3, 4], [5, 6]]);§Panics
Panics if the array length is changed, or if the memory layout is not compatible.
Sourcepub fn reshape_mut<I: IntoShape>(
&mut self,
shape: I,
) -> ViewMut<'_, T, I::IntoShape, L>
pub fn reshape_mut<I: IntoShape>( &mut self, shape: I, ) -> ViewMut<'_, T, I::IntoShape, L>
Returns a mutable reshaped array view of the array slice.
At most one dimension can have dynamic size usize::MAX, and is then inferred
from the other dimensions and the array length.
See the reshape method above for examples.
§Panics
Panics if the array length is changed, or if the memory layout is not compatible.
Sourcepub fn row(&self, index: usize) -> View<'_, T, (<S::Tail as Shape>::Head,), L>
pub fn row(&self, index: usize) -> View<'_, T, (<S::Tail as Shape>::Head,), L>
Returns an array view for the specified row.
§Panics
Panics if the rank is not equal to 2, or if the index is out of bounds.
Sourcepub fn row_mut(
&mut self,
index: usize,
) -> ViewMut<'_, T, (<S::Tail as Shape>::Head,), L>
pub fn row_mut( &mut self, index: usize, ) -> ViewMut<'_, T, (<S::Tail as Shape>::Head,), L>
Returns a mutable array view for the specified row.
§Panics
Panics if the rank is not equal to 2, or if the index is out of bounds.
Sourcepub fn rows(&self) -> Lanes<'_, T, S, L, Rows>
pub fn rows(&self) -> Lanes<'_, T, S, L, Rows>
Returns an expression that gives row views iterating over the other dimensions.
§Panics
Panics if the rank is not at least 1.
Sourcepub fn rows_mut(&mut self) -> LanesMut<'_, T, S, L, Rows>
pub fn rows_mut(&mut self) -> LanesMut<'_, T, S, L, Rows>
Returns a mutable expression that gives row views iterating over the other dimensions.
§Panics
Panics if the rank is not at least 1.
Sourcepub fn split_at(
&self,
mid: usize,
) -> (View<'_, T, Resize<Const<0>, S>, L>, View<'_, T, Resize<Const<0>, S>, L>)
pub fn split_at( &self, mid: usize, ) -> (View<'_, T, Resize<Const<0>, S>, L>, View<'_, T, Resize<Const<0>, S>, L>)
Divides an array slice into two at an index along the first dimension.
§Panics
Panics if the split point is larger than the number of elements in that dimension, or if the rank is not at least 1.
Sourcepub fn split_at_mut(
&mut self,
mid: usize,
) -> (ViewMut<'_, T, Resize<Const<0>, S>, L>, ViewMut<'_, T, Resize<Const<0>, S>, L>)
pub fn split_at_mut( &mut self, mid: usize, ) -> (ViewMut<'_, T, Resize<Const<0>, S>, L>, ViewMut<'_, T, Resize<Const<0>, S>, L>)
Divides a mutable array slice into two at an index along the first dimension.
§Panics
Panics if the split point is larger than the number of elements in that dimension, or if the rank is not at least 1.
Sourcepub fn split_axis_at<A: Axis>(
&self,
axis: A,
mid: usize,
) -> (View<'_, T, Resize<A, S>, Split<A, S, L>>, View<'_, T, Resize<A, S>, Split<A, S, L>>)
pub fn split_axis_at<A: Axis>( &self, axis: A, mid: usize, ) -> (View<'_, T, Resize<A, S>, Split<A, S, L>>, View<'_, T, Resize<A, S>, Split<A, S, L>>)
Divides an array slice into two at an index along the specified dimension.
If the dimension to be divided is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array views have the same layout as the input.
§Panics
Panics if the split point is larger than the number of elements in that dimension, or if the dimension is out of bounds.
Sourcepub fn split_axis_at_mut<A: Axis>(
&mut self,
axis: A,
mid: usize,
) -> (ViewMut<'_, T, Resize<A, S>, Split<A, S, L>>, ViewMut<'_, T, Resize<A, S>, Split<A, S, L>>)
pub fn split_axis_at_mut<A: Axis>( &mut self, axis: A, mid: usize, ) -> (ViewMut<'_, T, Resize<A, S>, Split<A, S, L>>, ViewMut<'_, T, Resize<A, S>, Split<A, S, L>>)
Divides a mutable array slice into two at an index along the specified dimension.
If the dimension to be divided is know at compile time, the resulting array shape will maintain constant-sized dimensions. Furthermore, if it is the first dimension the resulting array views have the same layout as the input.
§Panics
Panics if the split point is larger than the number of elements in that dimension, or if the dimension is out of bounds.
Sourcepub fn stride(&self, index: usize) -> isize
pub fn stride(&self, index: usize) -> isize
Returns the distance between elements in the specified dimension.
§Panics
Panics if the dimension is out of bounds.
Sourcepub fn swap<I, J>(&mut self, a: I, b: J)where
I: SliceIndex<T, S, L, Output = T>,
J: SliceIndex<T, S, L, Output = T>,
pub fn swap<I, J>(&mut self, a: I, b: J)where
I: SliceIndex<T, S, L, Output = T>,
J: SliceIndex<T, S, L, Output = T>,
Sourcepub fn swap_axis<A: Axis>(&mut self, axis: A, a: usize, b: usize)
pub fn swap_axis<A: Axis>(&mut self, axis: A, a: usize, b: usize)
Swaps the elements in two subarrays after indexing the specified dimension.
§Panics
Panics if a or b are out of bounds.
Sourcepub fn to_array(&self) -> Array<T, S>where
T: Clone,
S: ConstShape,
pub fn to_array(&self) -> Array<T, S>where
T: Clone,
S: ConstShape,
Copies the array slice into a new array.
Sourcepub fn to_tensor(&self) -> Tensor<T, S>where
T: Clone,
pub fn to_tensor(&self) -> Tensor<T, S>where
T: Clone,
Copies the array slice into a new array.
Trait Implementations§
Source§impl<T, S: Shape, L: Layout, I: IntoExpression> AddAssign<I> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout, I: IntoExpression> AddAssign<I> for ViewMut<'_, T, S, L>
Source§fn add_assign(&mut self, rhs: I)
fn add_assign(&mut self, rhs: I)
+= operation. Read moreSource§impl<'a, T, U, S: Shape, L: Layout> Apply<U> for &'a ViewMut<'_, T, S, L>
impl<'a, T, U, S: Shape, L: Layout> Apply<U> for &'a ViewMut<'_, T, S, L>
Source§type Output<F: FnMut(&'a T) -> U> = Map<<&'a ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, F>
type Output<F: FnMut(&'a T) -> U> = Map<<&'a ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, F>
Source§type ZippedWith<I: IntoExpression, F: FnMut((&'a T, I::Item)) -> U> = Map<Zip<<&'a ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, <I as IntoExpression>::IntoExpr>, F>
type ZippedWith<I: IntoExpression, F: FnMut((&'a T, I::Item)) -> U> = Map<Zip<<&'a ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, <I as IntoExpression>::IntoExpr>, F>
Source§fn apply<F: FnMut(&'a T) -> U>(self, f: F) -> Self::Output<F>
fn apply<F: FnMut(&'a T) -> U>(self, f: F) -> Self::Output<F>
Source§fn zip_with<I: IntoExpression, F>(self, expr: I, f: F) -> Self::ZippedWith<I, F>
fn zip_with<I: IntoExpression, F>(self, expr: I, f: F) -> Self::ZippedWith<I, F>
Source§impl<'a, T, U, S: Shape, L: Layout> Apply<U> for &'a mut ViewMut<'_, T, S, L>
impl<'a, T, U, S: Shape, L: Layout> Apply<U> for &'a mut ViewMut<'_, T, S, L>
Source§type Output<F: FnMut(&'a mut T) -> U> = Map<<&'a mut ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, F>
type Output<F: FnMut(&'a mut T) -> U> = Map<<&'a mut ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, F>
Source§type ZippedWith<I: IntoExpression, F: FnMut((&'a mut T, I::Item)) -> U> = Map<Zip<<&'a mut ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, <I as IntoExpression>::IntoExpr>, F>
type ZippedWith<I: IntoExpression, F: FnMut((&'a mut T, I::Item)) -> U> = Map<Zip<<&'a mut ViewMut<'_, T, S, L> as IntoExpression>::IntoExpr, <I as IntoExpression>::IntoExpr>, F>
Source§fn apply<F: FnMut(&'a mut T) -> U>(self, f: F) -> Self::Output<F>
fn apply<F: FnMut(&'a mut T) -> U>(self, f: F) -> Self::Output<F>
Source§fn zip_with<I: IntoExpression, F>(self, expr: I, f: F) -> Self::ZippedWith<I, F>
fn zip_with<I: IntoExpression, F>(self, expr: I, f: F) -> Self::ZippedWith<I, F>
Source§impl<T, S: Shape, L: Layout, I: IntoExpression> BitAndAssign<I> for ViewMut<'_, T, S, L>where
T: BitAndAssign<I::Item>,
impl<T, S: Shape, L: Layout, I: IntoExpression> BitAndAssign<I> for ViewMut<'_, T, S, L>where
T: BitAndAssign<I::Item>,
Source§fn bitand_assign(&mut self, rhs: I)
fn bitand_assign(&mut self, rhs: I)
&= operation. Read moreSource§impl<T, S: Shape, L: Layout, I: IntoExpression> BitOrAssign<I> for ViewMut<'_, T, S, L>where
T: BitOrAssign<I::Item>,
impl<T, S: Shape, L: Layout, I: IntoExpression> BitOrAssign<I> for ViewMut<'_, T, S, L>where
T: BitOrAssign<I::Item>,
Source§fn bitor_assign(&mut self, rhs: I)
fn bitor_assign(&mut self, rhs: I)
|= operation. Read moreSource§impl<T, S: Shape, L: Layout, I: IntoExpression> BitXorAssign<I> for ViewMut<'_, T, S, L>where
T: BitXorAssign<I::Item>,
impl<T, S: Shape, L: Layout, I: IntoExpression> BitXorAssign<I> for ViewMut<'_, T, S, L>where
T: BitXorAssign<I::Item>,
Source§fn bitxor_assign(&mut self, rhs: I)
fn bitxor_assign(&mut self, rhs: I)
^= operation. Read moreSource§impl<T, S: Shape, L: Layout> BorrowMut<Slice<T, S, L>> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout> BorrowMut<Slice<T, S, L>> for ViewMut<'_, T, S, L>
Source§fn borrow_mut(&mut self) -> &mut Slice<T, S, L>
fn borrow_mut(&mut self) -> &mut Slice<T, S, L>
Source§impl<T, S: Shape, L: Layout, I: IntoExpression> DivAssign<I> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout, I: IntoExpression> DivAssign<I> for ViewMut<'_, T, S, L>
Source§fn div_assign(&mut self, rhs: I)
fn div_assign(&mut self, rhs: I)
/= operation. Read moreSource§impl<'a, T, S: Shape, L: Layout> Expression for ViewMut<'a, T, S, L>
impl<'a, T, S: Shape, L: Layout> Expression for ViewMut<'a, T, S, L>
Source§const IS_REPEATABLE: bool = false
const IS_REPEATABLE: bool = false
Source§fn cloned<'a, T: 'a + Clone>(self) -> Cloned<Self>
fn cloned<'a, T: 'a + Clone>(self) -> Cloned<Self>
Source§fn copied<'a, T: 'a + Copy>(self) -> Copied<Self>
fn copied<'a, T: 'a + Copy>(self) -> Copied<Self>
Source§fn dim(&self, index: usize) -> usize
fn dim(&self, index: usize) -> usize
Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Source§fn eq<I: IntoExpression>(self, other: I) -> bool
fn eq<I: IntoExpression>(self, other: I) -> bool
Source§fn eq_by<I: IntoExpression, F>(self, other: I, eq: F) -> bool
fn eq_by<I: IntoExpression, F>(self, other: I, eq: F) -> bool
Source§fn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item>where
Self: Sized,
fn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item>where
Self: Sized,
Source§fn eval_into<S: Shape, A: Allocator>(
self,
tensor: &mut Tensor<Self::Item, S, A>,
) -> &mut Tensor<Self::Item, S, A>where
Self: Sized,
fn eval_into<S: Shape, A: Allocator>(
self,
tensor: &mut Tensor<Self::Item, S, A>,
) -> &mut Tensor<Self::Item, S, A>where
Self: Sized,
Source§fn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> Twhere
Self: Sized,
fn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> Twhere
Self: Sized,
Source§fn for_each<F: FnMut(Self::Item)>(self, f: F)where
Self: Sized,
fn for_each<F: FnMut(Self::Item)>(self, f: F)where
Self: Sized,
Source§fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F>where
Self: Sized,
fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F>where
Self: Sized,
Source§fn ne<I: IntoExpression>(self, other: I) -> bool
fn ne<I: IntoExpression>(self, other: I) -> bool
Source§impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, W: Dim + From<Const<D>>, U: Dim + From<Const<E>>, V: Dim + From<Const<F>>, const A: usize, const B: usize, const C: usize, const D: usize, const E: usize, const F: usize> From<&'a mut [[[[[[T; F]; E]; D]; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z, W, U, V)>
impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, W: Dim + From<Const<D>>, U: Dim + From<Const<E>>, V: Dim + From<Const<F>>, const A: usize, const B: usize, const C: usize, const D: usize, const E: usize, const F: usize> From<&'a mut [[[[[[T; F]; E]; D]; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z, W, U, V)>
Source§impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, W: Dim + From<Const<D>>, U: Dim + From<Const<E>>, const A: usize, const B: usize, const C: usize, const D: usize, const E: usize> From<&'a mut [[[[[T; E]; D]; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z, W, U)>
impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, W: Dim + From<Const<D>>, U: Dim + From<Const<E>>, const A: usize, const B: usize, const C: usize, const D: usize, const E: usize> From<&'a mut [[[[[T; E]; D]; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z, W, U)>
Source§impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, W: Dim + From<Const<D>>, const A: usize, const B: usize, const C: usize, const D: usize> From<&'a mut [[[[T; D]; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z, W)>
impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, W: Dim + From<Const<D>>, const A: usize, const B: usize, const C: usize, const D: usize> From<&'a mut [[[[T; D]; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z, W)>
Source§impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, const A: usize, const B: usize, const C: usize> From<&'a mut [[[T; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z)>
impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, Z: Dim + From<Const<C>>, const A: usize, const B: usize, const C: usize> From<&'a mut [[[T; C]; B]; A]> for ViewMut<'a, T, (X, Y, Z)>
Source§impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, const A: usize, const B: usize> From<&'a mut [[T; B]; A]> for ViewMut<'a, T, (X, Y)>
impl<'a, T, X: Dim + From<Const<A>>, Y: Dim + From<Const<B>>, const A: usize, const B: usize> From<&'a mut [[T; B]; A]> for ViewMut<'a, T, (X, Y)>
Source§impl<'a, T, X: Dim + From<Const<A>>, const A: usize> From<&'a mut [T; A]> for ViewMut<'a, T, (X,)>
impl<'a, T, X: Dim + From<Const<A>>, const A: usize> From<&'a mut [T; A]> for ViewMut<'a, T, (X,)>
Source§impl<T, S: Shape, L: Layout, I: IntoExpression> MulAssign<I> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout, I: IntoExpression> MulAssign<I> for ViewMut<'_, T, S, L>
Source§fn mul_assign(&mut self, rhs: I)
fn mul_assign(&mut self, rhs: I)
*= operation. Read moreSource§impl<T, U, S: Shape, R: Shape, L: Layout, K: Layout, I: ?Sized> PartialEq<I> for ViewMut<'_, T, S, L>
impl<T, U, S: Shape, R: Shape, L: Layout, K: Layout, I: ?Sized> PartialEq<I> for ViewMut<'_, T, S, L>
Source§impl<T, S: Shape, L: Layout, I: IntoExpression> RemAssign<I> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout, I: IntoExpression> RemAssign<I> for ViewMut<'_, T, S, L>
Source§fn rem_assign(&mut self, rhs: I)
fn rem_assign(&mut self, rhs: I)
%= operation. Read moreSource§impl<T, S: Shape, L: Layout, I: IntoExpression> ShlAssign<I> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout, I: IntoExpression> ShlAssign<I> for ViewMut<'_, T, S, L>
Source§fn shl_assign(&mut self, rhs: I)
fn shl_assign(&mut self, rhs: I)
<<= operation. Read moreSource§impl<T, S: Shape, L: Layout, I: IntoExpression> ShrAssign<I> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout, I: IntoExpression> ShrAssign<I> for ViewMut<'_, T, S, L>
Source§fn shr_assign(&mut self, rhs: I)
fn shr_assign(&mut self, rhs: I)
>>= operation. Read moreSource§impl<T, S: Shape, L: Layout, I: IntoExpression> SubAssign<I> for ViewMut<'_, T, S, L>
impl<T, S: Shape, L: Layout, I: IntoExpression> SubAssign<I> for ViewMut<'_, T, S, L>
Source§fn sub_assign(&mut self, rhs: I)
fn sub_assign(&mut self, rhs: I)
-= operation. Read more