Trait na::Storage[][src]

pub unsafe trait Storage<N, R, C = U1>: Debug where
    C: Dim,
    N: Scalar,
    R: Dim
{ type RStride: Dim; type CStride: Dim; fn ptr(&self) -> *const N;
fn shape(&self) -> (R, C);
fn strides(&self) -> (Self::RStride, Self::CStride);
fn is_contiguous(&self) -> bool;
fn as_slice(&self) -> &[N];
fn into_owned(self) -> <DefaultAllocator as Allocator<N, R, C>>::Buffer
    where
        DefaultAllocator: Allocator<N, R, C>
;
fn clone_owned(&self) -> <DefaultAllocator as Allocator<N, R, C>>::Buffer
    where
        DefaultAllocator: Allocator<N, R, C>
; fn linear_index(&self, irow: usize, icol: usize) -> usize { ... }
unsafe fn get_address_unchecked_linear(&self, i: usize) -> *const N { ... }
unsafe fn get_address_unchecked(&self, irow: usize, icol: usize) -> *const N { ... }
unsafe fn get_unchecked_linear(&self, i: usize) -> &N { ... }
unsafe fn get_unchecked(&self, irow: usize, icol: usize) -> &N { ... } }

The trait shared by all matrix data storage.

FIXME: doc

Note that Self must always have a number of elements compatible with the matrix length (given by R and C if they are known at compile-time). For example, implementors of this trait should not allow the user to modify the size of the underlying buffer with safe methods (for example the MatrixVec::data_mut method is unsafe because the user could change the vector's size so that it no longer contains enough elements: this will lead to UB.

Associated Types

The static stride of this storage's rows.

The static stride of this storage's columns.

Required Methods

The matrix data pointer.

The dimension of the matrix at run-time. Arr length of zero indicates the additive identity element of any dimension. Must be equal to Self::dimension() if it is not None.

The spacing between concecutive row elements and consecutive column elements.

For example this returns (1, 5) for a row-major matrix with 5 columns.

Indicates whether this data buffer stores its elements contiguously.

Important traits for &'a [u8]

Retrieves the data buffer as a contiguous slice.

The matrix components may not be stored in a contiguous way, depending on the strides.

Builds a matrix data storage that does not contain any reference.

Clones this data storage to one that does not contain any reference.

Provided Methods

Compute the index corresponding to the irow-th row and icol-th column of this matrix. The index must be such that the following holds:

This example is not tested
let lindex = self.linear_index(irow, icol);
assert!(*self.get_unchecked(irow, icol) == *self.get_unchecked_linear(lindex)

Gets the address of the i-th matrix component without performing bound-checking.

Gets the address of the i-th matrix component without performing bound-checking.

Important traits for &'a mut R

Retrieves a reference to the i-th element without bound-checking.

Important traits for &'a mut R

Retrieves a reference to the i-th element without bound-checking.

Implementations on Foreign Types

impl<'a, N, R, C, RStride, CStride> Storage<N, R, C> for SliceStorage<'a, N, R, C, RStride, CStride> where
    C: Dim,
    CStride: Dim,
    N: Scalar,
    R: Dim,
    RStride: Dim
[src]

Important traits for &'a [u8]

Important traits for &'a mut R

Important traits for &'a mut R

impl<'a, N, R, C, RStride, CStride> Storage<N, R, C> for SliceStorageMut<'a, N, R, C, RStride, CStride> where
    C: Dim,
    CStride: Dim,
    N: Scalar,
    R: Dim,
    RStride: Dim
[src]

Important traits for &'a [u8]

Important traits for &'a mut R

Important traits for &'a mut R

impl<N, R, C> Storage<N, R, C> for MatrixArray<N, R, C> where
    C: DimName,
    N: Scalar,
    R: DimName,
    <R as DimName>::Value: Mul<<C as DimName>::Value>,
    <<R as DimName>::Value as Mul<<C as DimName>::Value>>::Output: ArrayLength<N>,
    DefaultAllocator: Allocator<N, R, C>,
    <DefaultAllocator as Allocator<N, R, C>>::Buffer == MatrixArray<N, R, C>, 
[src]

Important traits for &'a [u8]

Important traits for &'a mut R

Important traits for &'a mut R

impl<N, C> Storage<N, Dynamic, C> for MatrixVec<N, Dynamic, C> where
    C: Dim,
    N: Scalar,
    DefaultAllocator: Allocator<N, Dynamic, C>,
    <DefaultAllocator as Allocator<N, Dynamic, C>>::Buffer == MatrixVec<N, Dynamic, C>, 
[src]

Important traits for &'a [u8]

Important traits for &'a mut R

Important traits for &'a mut R

impl<N, R> Storage<N, R, Dynamic> for MatrixVec<N, R, Dynamic> where
    N: Scalar,
    R: DimName,
    DefaultAllocator: Allocator<N, R, Dynamic>,
    <DefaultAllocator as Allocator<N, R, Dynamic>>::Buffer == MatrixVec<N, R, Dynamic>, 
[src]

Important traits for &'a [u8]

Important traits for &'a mut R

Important traits for &'a mut R

Implementors