Struct rds::array::NDArray
[−]
[src]
pub struct NDArray<T> { /* fields omitted */ }
Structure representing an owned n-dimensional array. The underlying storage is in row-major order.
Methods
impl<T: Clone> NDArray<T>
[src]
fn new(shape: &[usize], v: T) -> NDArray<T>
Allocate a new array of the specified shape with all elements initialized with the value v.
fn copy<R: NDData<T>>(data: &R) -> NDArray<T>
Allocate a new array which is a copy of data.
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.
fn cast<U: Copy>(data: &NDData<U>) -> NDArray<T> where
T: Copy,
U: Cast<T>,
T: Copy,
U: Cast<T>,
Allocate a new array where each element has been casted from data.
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.
fn insert(&mut self, dim: usize, pos: usize, other: &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.
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.
fn remove(&mut self, dim: usize, start: usize, end: usize)
Remove a part of this NDArray. The removal is made in dimension dim from the position start until end (not included). This can be seen as the opposite operation of insert.
fn split(&mut self, dim: usize, pos: usize) -> NDArray<T>
Split this NDArray at position pos of dimension dim. The lower indices are kept in dim while the upper indices are returned. This is in fact an extract operation followed by a remove operation.
Trait Implementations
impl<T> NDData<T> for NDArray<T>
[src]
fn shape(&self) -> &[usize]
Return a slice of length N where each element is the length of the dimension. For a 2 dimensional matrix, the first dimension is the number of rows and the second dimension is the number of columns. Read more
fn strides(&self) -> &[usize]
Return a slice of length N where each element is the stride of the dimension.
fn get_data(&self) -> &[T]
Return the underlying storage array as a slice.
fn dim(&self) -> usize
Return N, the number of dimensions.
fn size(&self) -> usize
Return the total number of element of the N-dimensional array.
fn idx<'a>(&'a self, idx: &[usize]) -> &'a T
Take a slice of length N representing an N-dimensional index in the array and return a reference to the element at this position. Read more
impl<T: Clone + Display> NDDataMut<T> for NDArray<T>
[src]
fn get_data_mut(&mut self) -> &mut [T]
Return the underlying storage array as a mutable slice.
fn transpose(&mut self)
The transpose function of a NDArray allow to transpose any shape.
fn idx_mut<'a>(&'a mut self, idx: &[usize]) -> &'a mut T
Take a slice of length N representing an -index in the array and return a mutable reference to the element at this position. Read more
fn assign(&mut self, other: &NDData<T>)
Assign another NDData to the NDDataMut. The shapes need to be identical.
impl<'a, T: 'a> NDSliceable<'a, T> for NDArray<T>
[src]
fn slice(&'a self, idx: &[usize]) -> NDSlice<'a, T>
Take a slice of length < N representing the sub slice index and return immutable borrow of the sub slice as an NDSlice. Because the storage is in row-major order and the slice need to be contiguous in the underlying storage array it means, for example, only the rows of a matrix can be borrowed. Read more
impl<'a, T: 'a> NDSliceableMut<'a, T> for NDArray<T>
[src]
fn slice_mut(&'a mut self, idx: &[usize]) -> NDSliceMut<'a, T>
Take a slice of length < N representing the sub slice index and return immutable borrow of the sub slice as an NDSlice. Because the storage is in row-major order and the slice need to be contiguous in the underlying storage array it means, for example, only the rows of a matrix can be borrowed. Read more
impl<'b, T> Index<&'b [usize]> for NDArray<T>
[src]
type Output = T
The returned type after indexing
fn index<'c>(&'c self, idx: &'b [usize]) -> &'c T
The method for the indexing (container[index]
) operation
impl<'b, T> Index<&'b [usize; 1]> for NDArray<T>
[src]
type Output = T
The returned type after indexing
fn index<'c>(&'c self, idx: &'b [usize; 1]) -> &'c T
The method for the indexing (container[index]
) operation
impl<'b, T> Index<&'b [usize; 2]> for NDArray<T>
[src]
type Output = T
The returned type after indexing
fn index<'c>(&'c self, idx: &'b [usize; 2]) -> &'c T
The method for the indexing (container[index]
) operation
impl<'b, T> Index<&'b [usize; 3]> for NDArray<T>
[src]
type Output = T
The returned type after indexing
fn index<'c>(&'c self, idx: &'b [usize; 3]) -> &'c T
The method for the indexing (container[index]
) operation
impl<'b, T: Clone + Display> IndexMut<&'b [usize]> for NDArray<T>
[src]
fn index_mut<'c>(&'c mut self, idx: &[usize]) -> &'c mut T
The method for the mutable indexing (container[index]
) operation
impl<'b, T: Clone + Display> IndexMut<&'b [usize; 1]> for NDArray<T>
[src]
fn index_mut<'c>(&'c mut self, idx: &[usize; 1]) -> &'c mut T
The method for the mutable indexing (container[index]
) operation
impl<'b, T: Clone + Display> IndexMut<&'b [usize; 2]> for NDArray<T>
[src]
fn index_mut<'c>(&'c mut self, idx: &[usize; 2]) -> &'c mut T
The method for the mutable indexing (container[index]
) operation
impl<'b, T: Clone + Display> IndexMut<&'b [usize; 3]> for NDArray<T>
[src]
fn index_mut<'c>(&'c mut self, idx: &[usize; 3]) -> &'c mut T
The method for the mutable indexing (container[index]
) operation
impl<T: PartialEq, O: NDData<T> + Sized> PartialEq<O> for NDArray<T>
[src]
fn eq(&self, other: &O) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<T: Eq> Eq for NDArray<T>
[src]
impl<'a, T: Clone + Display + From<f32>, R: NDData<T> + Sized> AddAssign<&'a R> for NDArray<T> where
NDArray<T>: Blas<T>,
[src]
NDArray<T>: Blas<T>,
fn add_assign(&mut self, rhs: &'a R)
The method for the +=
operator
impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Add<&'a R> for &'b NDArray<T> where
NDArray<T>: Blas<T>,
[src]
NDArray<T>: Blas<T>,
type Output = NDArray<T>
The resulting type after applying the +
operator
fn add(self, rhs: &'a R) -> NDArray<T>
The method for the +
operator
impl<'a, T: Clone + Display + From<f32>, R: NDData<T> + Sized> SubAssign<&'a R> for NDArray<T> where
NDArray<T>: Blas<T>,
[src]
NDArray<T>: Blas<T>,
fn sub_assign(&mut self, rhs: &'a R)
The method for the -=
operator
impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Sub<&'a R> for &'b NDArray<T> where
NDArray<T>: Blas<T>,
[src]
NDArray<T>: Blas<T>,
type Output = NDArray<T>
The resulting type after applying the -
operator
fn sub(self, rhs: &'a R) -> NDArray<T>
The method for the -
operator
impl<'a, T: Clone + Display + From<f32>, I: NDData<T> + Sized> MulAssign<&'a I> for NDArray<T> where
NDArray<T>: Blas<T> + NDData<T>,
[src]
NDArray<T>: Blas<T> + NDData<T>,
fn mul_assign(&mut self, rhs: &'a I)
The method for the *=
operator
impl<'a, 'b, T: Clone + Display + From<f32>, R: NDData<T> + Sized> Mul<&'a R> for &'b NDArray<T> where
NDArray<T>: Blas<T>,
[src]
NDArray<T>: Blas<T>,
type Output = NDArray<T>
The resulting type after applying the *
operator
fn mul(self, rhs: &'a R) -> NDArray<T>
The method for the *
operator
impl<T> SizedBuffer for NDArray<T>
[src]
unsafe fn get_raw_ptr(&self) -> *const c_void
fn get_raw_size(&self) -> usize
impl<T: Clone + Display> SizedBufferMut for NDArray<T> where
NDArray<T>: SizedBuffer,
[src]
NDArray<T>: SizedBuffer,