pub struct NDArray<T> { /* private fields */ }
Expand description
Structure representing an owned n-dimensional array. The underlying storage is in row-major order.
Implementations§
Source§impl<T: Clone> NDArray<T>
impl<T: Clone> NDArray<T>
Sourcepub fn new(shape: &[usize], v: T) -> NDArray<T>
pub fn new(shape: &[usize], v: T) -> NDArray<T>
Allocate a new array of the specified shape with all elements initialized with the value v.
Sourcepub fn copy<R: NDData<T>>(data: &R) -> NDArray<T>
pub fn copy<R: NDData<T>>(data: &R) -> NDArray<T>
Allocate a new array which is a copy of data.
Sourcepub fn from_slice(shape: &[usize], data: &[T]) -> NDArray<T>
pub fn from_slice(shape: &[usize], data: &[T]) -> NDArray<T>
Allocate a new array from a row-major order contiguous array and a shape. The size of the shape (product of all its elements) must be equal to the array length.
Sourcepub fn cast<U>(data: &dyn NDData<U>) -> NDArray<T>
pub fn cast<U>(data: &dyn NDData<U>) -> NDArray<T>
Allocate a new array where each element has been casted from data.
Sourcepub fn reshape(&mut self, new_shape: &[usize])
pub fn reshape(&mut self, new_shape: &[usize])
Reshape this NDArray. The size of the new shape (product of all its elements) must be equal to the size of the current shape.
Sourcepub fn insert(&mut self, dim: usize, pos: usize, other: &dyn NDData<T>)
pub fn insert(&mut self, dim: usize, pos: usize, other: &dyn NDData<T>)
Insert another NDData of the same dimensionality in this NDArray. The insertion is made at the position pos in the dimension dim. The shape of NDData need to be the same as this NDArray in every dimension except for the insertion dimension.
Sourcepub fn extract(&self, start: &[usize], end: &[usize]) -> NDArray<T>
pub fn extract(&self, start: &[usize], end: &[usize]) -> NDArray<T>
Extract a sub part of this NDArray as a new NDArray. start and end are two index of the same dimensionality ad this NDArray.
Trait Implementations§
Source§impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Add<&'a R> for &'b NDArray<T>
impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Add<&'a R> for &'b NDArray<T>
Source§impl<'a, T: Clone + Display + From<f32>, R: NDData<T> + Sized> AddAssign<&'a R> for NDArray<T>
impl<'a, T: Clone + Display + From<f32>, R: NDData<T> + Sized> AddAssign<&'a R> for NDArray<T>
Source§fn add_assign(&mut self, rhs: &'a R)
fn add_assign(&mut self, rhs: &'a R)
+=
operation. Read moreSource§impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Mul<&'a R> for &'b NDArray<T>
impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Mul<&'a R> for &'b NDArray<T>
Source§impl<'a, T: Clone + Display + From<f32>, I: NDData<T> + Sized> MulAssign<&'a I> for NDArray<T>
impl<'a, T: Clone + Display + From<f32>, I: NDData<T> + Sized> MulAssign<&'a I> for NDArray<T>
Source§fn mul_assign(&mut self, rhs: &'a I)
fn mul_assign(&mut self, rhs: &'a I)
*=
operation. Read moreSource§impl<T> NDData<T> for NDArray<T>
impl<T> NDData<T> for NDArray<T>
Source§fn shape(&self) -> &[usize]
fn shape(&self) -> &[usize]
Source§impl<T: Clone + Display> NDDataMut<T> for NDArray<T>
impl<T: Clone + Display> NDDataMut<T> for NDArray<T>
Source§impl<'a, T: 'a> NDSliceable<'a, T> for NDArray<T>
impl<'a, T: 'a> NDSliceable<'a, T> for NDArray<T>
Source§fn slice(&'a self, idx: &[usize]) -> NDSlice<'a, T>
fn slice(&'a self, idx: &[usize]) -> NDSlice<'a, T>
Source§impl<'a, T: 'a> NDSliceableMut<'a, T> for NDArray<T>
impl<'a, T: 'a> NDSliceableMut<'a, T> for NDArray<T>
Source§fn slice_mut(&'a mut self, idx: &[usize]) -> NDSliceMut<'a, T>
fn slice_mut(&'a mut self, idx: &[usize]) -> NDSliceMut<'a, T>
Source§impl<T> SizedBuffer for NDArray<T>
impl<T> SizedBuffer for NDArray<T>
unsafe fn get_raw_ptr(&self) -> *const c_void
fn get_raw_size(&self) -> usize
Source§impl<T: Clone + Display> SizedBufferMut for NDArray<T>where
NDArray<T>: SizedBuffer,
impl<T: Clone + Display> SizedBufferMut for NDArray<T>where
NDArray<T>: SizedBuffer,
unsafe fn get_raw_ptr_mut(&mut self) -> *mut c_void
Source§impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Sub<&'a R> for &'b NDArray<T>
impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Sub<&'a R> for &'b NDArray<T>
Source§impl<'a, T: Clone + Display + From<f32>, R: NDData<T> + Sized> SubAssign<&'a R> for NDArray<T>
impl<'a, T: Clone + Display + From<f32>, R: NDData<T> + Sized> SubAssign<&'a R> for NDArray<T>
Source§fn sub_assign(&mut self, rhs: &'a R)
fn sub_assign(&mut self, rhs: &'a R)
-=
operation. Read more