Trait nalgebra::base::storage::Storage [−][src]
pub unsafe trait Storage<N: Scalar, R: Dim, C: Dim = U1>: Debug + Sized { 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) -> Owned<N, R, C>
where
DefaultAllocator: Allocator<N, R, C>; fn clone_owned(&self) -> Owned<N, R, C>
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.
TODO: 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 VecStorage::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
type RStride: Dim
[src]
The static stride of this storage’s rows.
type CStride: Dim
[src]
The static stride of this storage’s columns.
Required methods
fn ptr(&self) -> *const N
[src]
The matrix data pointer.
fn shape(&self) -> (R, C)
[src]
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
.
fn strides(&self) -> (Self::RStride, Self::CStride)
[src]
The spacing between consecutive row elements and consecutive column elements.
For example this returns (1, 5)
for a row-major matrix with 5 columns.
fn is_contiguous(&self) -> bool
[src]
Indicates whether this data buffer stores its elements contiguously.
fn as_slice(&self) -> &[N]
[src]
Retrieves the data buffer as a contiguous slice.
The matrix components may not be stored in a contiguous way, depending on the strides.
fn into_owned(self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
Builds a matrix data storage that does not contain any reference.
fn clone_owned(&self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
Clones this data storage to one that does not contain any reference.
Provided methods
fn linear_index(&self, irow: usize, icol: usize) -> usize
[src]
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:
let lindex = self.linear_index(irow, icol); assert!(*self.get_unchecked(irow, icol) == *self.get_unchecked_linear(lindex))
unsafe fn get_address_unchecked_linear(&self, i: usize) -> *const N
[src]
Gets the address of the i-th matrix component without performing bound-checking.
unsafe fn get_address_unchecked(&self, irow: usize, icol: usize) -> *const N
[src]
Gets the address of the i-th matrix component without performing bound-checking.
unsafe fn get_unchecked_linear(&self, i: usize) -> &N
[src]
Retrieves a reference to the i-th element without bound-checking.
unsafe fn get_unchecked(&self, irow: usize, icol: usize) -> &N
[src]
Retrieves a reference to the i-th element without bound-checking.
Implementors
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage<N, R, C> for SliceStorage<'a, N, R, C, RStride, CStride>
[src]
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage<N, R, C> for SliceStorage<'a, N, R, C, RStride, CStride>
[src]type RStride = RStride
type CStride = CStride
fn ptr(&self) -> *const N
[src]
fn shape(&self) -> (R, C)
[src]
fn strides(&self) -> (Self::RStride, Self::CStride)
[src]
fn is_contiguous(&self) -> bool
[src]
fn into_owned(self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
fn clone_owned(&self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
fn as_slice(&self) -> &[N]
[src]
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage<N, R, C> for SliceStorageMut<'a, N, R, C, RStride, CStride>
[src]
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage<N, R, C> for SliceStorageMut<'a, N, R, C, RStride, CStride>
[src]type RStride = RStride
type CStride = CStride
fn ptr(&self) -> *const N
[src]
fn shape(&self) -> (R, C)
[src]
fn strides(&self) -> (Self::RStride, Self::CStride)
[src]
fn is_contiguous(&self) -> bool
[src]
fn into_owned(self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
fn clone_owned(&self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
fn as_slice(&self) -> &[N]
[src]
impl<N, R, C> Storage<N, R, C> for ArrayStorage<N, R, C> where
N: Scalar,
R: DimName,
C: DimName,
R::Value: Mul<C::Value>,
Prod<R::Value, C::Value>: ArrayLength<N>,
DefaultAllocator: Allocator<N, R, C, Buffer = Self>,
[src]
impl<N, R, C> Storage<N, R, C> for ArrayStorage<N, R, C> where
N: Scalar,
R: DimName,
C: DimName,
R::Value: Mul<C::Value>,
Prod<R::Value, C::Value>: ArrayLength<N>,
DefaultAllocator: Allocator<N, R, C, Buffer = Self>,
[src]type RStride = U1
type CStride = R
fn ptr(&self) -> *const N
[src]
fn shape(&self) -> (R, C)
[src]
fn strides(&self) -> (Self::RStride, Self::CStride)
[src]
fn is_contiguous(&self) -> bool
[src]
fn into_owned(self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
fn clone_owned(&self) -> Owned<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
[src]
DefaultAllocator: Allocator<N, R, C>,
fn as_slice(&self) -> &[N]
[src]
impl<N: Scalar, C: Dim> Storage<N, Dynamic, C> for VecStorage<N, Dynamic, C> where
DefaultAllocator: Allocator<N, Dynamic, C, Buffer = Self>,
[src]
impl<N: Scalar, C: Dim> Storage<N, Dynamic, C> for VecStorage<N, Dynamic, C> where
DefaultAllocator: Allocator<N, Dynamic, C, Buffer = Self>,
[src]type RStride = U1
type CStride = Dynamic
fn ptr(&self) -> *const N
[src]
fn shape(&self) -> (Dynamic, C)
[src]
fn strides(&self) -> (Self::RStride, Self::CStride)
[src]
fn is_contiguous(&self) -> bool
[src]
fn into_owned(self) -> Owned<N, Dynamic, C> where
DefaultAllocator: Allocator<N, Dynamic, C>,
[src]
DefaultAllocator: Allocator<N, Dynamic, C>,
fn clone_owned(&self) -> Owned<N, Dynamic, C> where
DefaultAllocator: Allocator<N, Dynamic, C>,
[src]
DefaultAllocator: Allocator<N, Dynamic, C>,
fn as_slice(&self) -> &[N]
[src]
impl<N: Scalar, R: DimName> Storage<N, R, Dynamic> for VecStorage<N, R, Dynamic> where
DefaultAllocator: Allocator<N, R, Dynamic, Buffer = Self>,
[src]
impl<N: Scalar, R: DimName> Storage<N, R, Dynamic> for VecStorage<N, R, Dynamic> where
DefaultAllocator: Allocator<N, R, Dynamic, Buffer = Self>,
[src]type RStride = U1
type CStride = R
fn ptr(&self) -> *const N
[src]
fn shape(&self) -> (R, Dynamic)
[src]
fn strides(&self) -> (Self::RStride, Self::CStride)
[src]
fn is_contiguous(&self) -> bool
[src]
fn into_owned(self) -> Owned<N, R, Dynamic> where
DefaultAllocator: Allocator<N, R, Dynamic>,
[src]
DefaultAllocator: Allocator<N, R, Dynamic>,
fn clone_owned(&self) -> Owned<N, R, Dynamic> where
DefaultAllocator: Allocator<N, R, Dynamic>,
[src]
DefaultAllocator: Allocator<N, R, Dynamic>,