pub struct Array3<T> { /* private fields */ }Expand description
Owned 3D row-major array.
Implementations§
Source§impl<T> Array3<T>
impl<T> Array3<T>
Sourcepub fn from_vec(shape: [usize; 3], data: Vec<T>) -> Result<Self>
pub fn from_vec(shape: [usize; 3], data: Vec<T>) -> Result<Self>
Build an array from row-major data.
Sourcepub fn from_fn(
shape: [usize; 3],
f: impl FnMut(usize, usize, usize) -> T,
) -> Self
pub fn from_fn( shape: [usize; 3], f: impl FnMut(usize, usize, usize) -> T, ) -> Self
Build an array from a function over (i, j, k).
Sourcepub fn try_from_fn(
shape: [usize; 3],
f: impl FnMut(usize, usize, usize) -> T,
) -> Result<Self>
pub fn try_from_fn( shape: [usize; 3], f: impl FnMut(usize, usize, usize) -> T, ) -> Result<Self>
Fallibly build an array from a function over (i, j, k).
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Borrow the backing slice mutably.
Sourcepub fn view(&self) -> ArrayView3<'_, T>
pub fn view(&self) -> ArrayView3<'_, T>
Immutable strided view.
Sourcepub fn view_mut(&mut self) -> ArrayViewMut3<'_, T>
pub fn view_mut(&mut self) -> ArrayViewMut3<'_, T>
Mutable strided view.
Sourcepub fn get_mut(&mut self, i: usize, j: usize, k: usize) -> Option<&mut T>
pub fn get_mut(&mut self, i: usize, j: usize, k: usize) -> Option<&mut T>
Get a mutable element reference.
Sourcepub fn matrix_at(&self, axis: Axis3, index: usize) -> Result<ArrayView2<'_, T>>
pub fn matrix_at(&self, axis: Axis3, index: usize) -> Result<ArrayView2<'_, T>>
Extract a 2D matrix view by fixing one axis.
Sourcepub fn for_each_matrix(
&self,
axis: Axis3,
f: impl FnMut(usize, ArrayView2<'_, T>) -> Result<()>,
) -> Result<()>
pub fn for_each_matrix( &self, axis: Axis3, f: impl FnMut(usize, ArrayView2<'_, T>) -> Result<()>, ) -> Result<()>
Visit each 2D matrix slice along axis in order.
Sourcepub fn matrix_at_mut(
&mut self,
axis: Axis3,
index: usize,
) -> Result<ArrayViewMut2<'_, T>>
pub fn matrix_at_mut( &mut self, axis: Axis3, index: usize, ) -> Result<ArrayViewMut2<'_, T>>
Extract a mutable 2D matrix view by fixing one axis.
Sourcepub fn for_each_matrix_mut(
&mut self,
axis: Axis3,
f: impl FnMut(usize, ArrayViewMut2<'_, T>) -> Result<()>,
) -> Result<()>
pub fn for_each_matrix_mut( &mut self, axis: Axis3, f: impl FnMut(usize, ArrayViewMut2<'_, T>) -> Result<()>, ) -> Result<()>
Visit each mutable 2D matrix slice along axis in order.
Source§impl<T: Clone> Array3<T>
impl<T: Clone> Array3<T>
Sourcepub fn try_filled(shape: [usize; 3], value: T) -> Result<Self>
pub fn try_filled(shape: [usize; 3], value: T) -> Result<Self>
Fallibly fill a new array with value.
Sourcepub fn clone_contiguous(view: ArrayView3<'_, T>) -> Self
pub fn clone_contiguous(view: ArrayView3<'_, T>) -> Self
Clone into compact row-major storage.
Source§impl<T: Float> Array3<T>
impl<T: Float> Array3<T>
Sourcepub fn try_zeros(shape: [usize; 3]) -> Result<Self>
pub fn try_zeros(shape: [usize; 3]) -> Result<Self>
Fallibly allocate an array filled with zeros.
Sourcepub fn try_ones(shape: [usize; 3]) -> Result<Self>
pub fn try_ones(shape: [usize; 3]) -> Result<Self>
Fallibly allocate an array filled with ones.
Sourcepub fn zeros_like(&self) -> Self
pub fn zeros_like(&self) -> Self
Allocate another array with the same shape, filled with zeros.
Sourcepub fn scaled_into(&self, alpha: T, out: ArrayViewMut3<'_, T>) -> Result<()>
pub fn scaled_into(&self, alpha: T, out: ArrayViewMut3<'_, T>) -> Result<()>
Write self * alpha into out without modifying self.
Sourcepub fn add(&self, other: ArrayView3<'_, T>) -> Result<Self>
pub fn add(&self, other: ArrayView3<'_, T>) -> Result<Self>
Return self + other without modifying either input.
Sourcepub fn add_into(
&self,
other: ArrayView3<'_, T>,
out: ArrayViewMut3<'_, T>,
) -> Result<()>
pub fn add_into( &self, other: ArrayView3<'_, T>, out: ArrayViewMut3<'_, T>, ) -> Result<()>
Write self + other into out without modifying either input.
Sourcepub fn sub(&self, other: ArrayView3<'_, T>) -> Result<Self>
pub fn sub(&self, other: ArrayView3<'_, T>) -> Result<Self>
Return self - other without modifying either input.
Sourcepub fn sub_into(
&self,
other: ArrayView3<'_, T>,
out: ArrayViewMut3<'_, T>,
) -> Result<()>
pub fn sub_into( &self, other: ArrayView3<'_, T>, out: ArrayViewMut3<'_, T>, ) -> Result<()>
Write self - other into out without modifying either input.
Sourcepub fn mul(&self, other: ArrayView3<'_, T>) -> Result<Self>
pub fn mul(&self, other: ArrayView3<'_, T>) -> Result<Self>
Return the elementwise product self * other without modifying either input.
Sourcepub fn mul_into(
&self,
other: ArrayView3<'_, T>,
out: ArrayViewMut3<'_, T>,
) -> Result<()>
pub fn mul_into( &self, other: ArrayView3<'_, T>, out: ArrayViewMut3<'_, T>, ) -> Result<()>
Write the elementwise product into out without modifying either input.
Sourcepub fn hadamard(&self, other: ArrayView3<'_, T>) -> Result<Self>
pub fn hadamard(&self, other: ArrayView3<'_, T>) -> Result<Self>
Return the Hadamard product without modifying either input.
Sourcepub fn hadamard_into(
&self,
other: ArrayView3<'_, T>,
out: ArrayViewMut3<'_, T>,
) -> Result<()>
pub fn hadamard_into( &self, other: ArrayView3<'_, T>, out: ArrayViewMut3<'_, T>, ) -> Result<()>
Write the Hadamard product into out without modifying either input.
Sourcepub fn div(&self, other: ArrayView3<'_, T>) -> Result<Self>
pub fn div(&self, other: ArrayView3<'_, T>) -> Result<Self>
Return the elementwise quotient self / other without modifying either input.
Sourcepub fn div_into(
&self,
other: ArrayView3<'_, T>,
out: ArrayViewMut3<'_, T>,
) -> Result<()>
pub fn div_into( &self, other: ArrayView3<'_, T>, out: ArrayViewMut3<'_, T>, ) -> Result<()>
Write the elementwise quotient into out without modifying either input.
Sourcepub fn axpy_result(&self, alpha: T, x: ArrayView3<'_, T>) -> Result<Self>
pub fn axpy_result(&self, alpha: T, x: ArrayView3<'_, T>) -> Result<Self>
Return self + alpha * x without modifying either input.
Sourcepub fn axpy_into(
&self,
alpha: T,
x: ArrayView3<'_, T>,
out: ArrayViewMut3<'_, T>,
) -> Result<()>
pub fn axpy_into( &self, alpha: T, x: ArrayView3<'_, T>, out: ArrayViewMut3<'_, T>, ) -> Result<()>
Write self + alpha * x into out without modifying either input.
Sourcepub fn add_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
pub fn add_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
In-place addition.
Sourcepub fn sub_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
pub fn sub_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
In-place subtraction.
Sourcepub fn mul_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
pub fn mul_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
Hadamard product in place.
Sourcepub fn div_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
pub fn div_assign_view(&mut self, other: ArrayView3<'_, T>) -> Result<()>
In-place elementwise division.
Sourcepub fn axpy(&mut self, alpha: T, x: ArrayView3<'_, T>) -> Result<()>
pub fn axpy(&mut self, alpha: T, x: ArrayView3<'_, T>) -> Result<()>
Compute self += alpha * x.
Sourcepub fn zip_map(
&self,
other: ArrayView3<'_, T>,
f: impl FnMut(T, T) -> T,
) -> Result<Self>
pub fn zip_map( &self, other: ArrayView3<'_, T>, f: impl FnMut(T, T) -> T, ) -> Result<Self>
Return an elementwise zip-map without modifying either input.
Sourcepub fn zip_map_into(
&self,
other: ArrayView3<'_, T>,
out: ArrayViewMut3<'_, T>,
f: impl FnMut(T, T) -> T,
) -> Result<()>
pub fn zip_map_into( &self, other: ArrayView3<'_, T>, out: ArrayViewMut3<'_, T>, f: impl FnMut(T, T) -> T, ) -> Result<()>
Write an elementwise zip-map into out without modifying either input.
Sourcepub fn map_inplace(&mut self, f: impl FnMut(T) -> T)
pub fn map_inplace(&mut self, f: impl FnMut(T) -> T)
Map values in place.
Sourcepub fn zip_map_inplace(
&mut self,
other: ArrayView3<'_, T>,
f: impl FnMut(T, T) -> T,
) -> Result<()>
pub fn zip_map_inplace( &mut self, other: ArrayView3<'_, T>, f: impl FnMut(T, T) -> T, ) -> Result<()>
Zip-map another view into this array in place.
Sourcepub fn fill_uniform(&mut self, seed: u64)
pub fn fill_uniform(&mut self, seed: u64)
Fill with deterministic uniform random values in [0, 1).
Sourcepub fn fill_randn(&mut self, seed: u64)
pub fn fill_randn(&mut self, seed: u64)
Fill with deterministic standard-normal random values.
Sourcepub fn norm_frobenius(&self) -> T
pub fn norm_frobenius(&self) -> T
Frobenius norm.
Sourcepub fn dot(&self, other: ArrayView3<'_, T>) -> Result<T>
pub fn dot(&self, other: ArrayView3<'_, T>) -> Result<T>
Dot product of two tensors treated as flattened row-major buffers.
Trait Implementations§
impl<T> StructuralPartialEq for Array3<T>
Auto Trait Implementations§
impl<T> Freeze for Array3<T>
impl<T> RefUnwindSafe for Array3<T>where
T: RefUnwindSafe,
impl<T> Send for Array3<T>where
T: Send,
impl<T> Sync for Array3<T>where
T: Sync,
impl<T> Unpin for Array3<T>where
T: Unpin,
impl<T> UnsafeUnpin for Array3<T>
impl<T> UnwindSafe for Array3<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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