Struct dense_mats::Tensor
[−]
[src]
pub struct Tensor<N, DimArray, Storage> where Storage: Deref<Target=[N]> {
// some fields omitted
}
A simple dense matrix
Methods
impl<'a, N: 'a, DimArray> Tensor<N, DimArray, &'a [N]> where DimArray: ArrayLikeMut<usize>
[src]
Methods available for all tensors regardless of their dimension count
fn middle_outer_views(&self, start: usize, count: usize) -> Result<TensorView<'a, N, DimArray>, DMatError>
Slice along the least varying dimension of the matrix, from
index start
and taking count
vectors.
e.g. for a row major matrix, get a view of count
rows starting
from start
.
impl<'a, N: 'a, DimArray> Tensor<N, DimArray, &'a mut [N]> where DimArray: ArrayLikeMut<usize>
[src]
fn middle_outer_views_mut(&mut self, start: usize, count: usize) -> Result<TensorViewMut<'a, N, DimArray>, DMatError>
Slice mutably along the least varying dimension of the matrix, from
index start
and taking count
vectors.
e.g. for a row major matrix, get a view of count
rows starting
from start
.
impl<N, DimArray> Tensor<N, DimArray, Vec<N>> where DimArray: ArrayLikeMut<usize>
[src]
fn zeros(shape: DimArray, order: StorageOrder) -> TensorOwned<N, DimArray> where N: Num + Copy
Create an all-zero tensor
Defaults to C order if order equals Unordered
fn ones(shape: DimArray, order: StorageOrder) -> TensorOwned<N, DimArray> where N: Num + Copy
Create an all-one tensor
Defaults to C order if order equals Unordered
impl<N, DimArray, Storage> Tensor<N, DimArray, Storage> where DimArray: ArrayLike<usize>, Storage: Deref<Target=[N]>
[src]
Methods available for all tensors regardless of their dimension count
fn strides(&self) -> DimArray
The strides of the tensor.
Explanations on a matrix.
self.strides()[0] gives the number of elements that must be skipped into self.data() to get to the element of the next row with the same column. self.strides()[1] gives the number of elements that must be skipped into self.data() to get to the element of the next column with the same row.
For a row major matrix of shape (3, 4) with contiguous storage, the strides would be [4, 1].
For alignement reasons, it is possible to have strides that don't match the shape of the matrix (meaning that some elements of the data array are unused).
fn strides_ref(&self) -> &[usize]
Get the strides by reference
fn data(&self) -> &[N]
Access to the tensors's data
Explanations on a matrix.
Getting access to the element located at row i and column j can be done by indexing self.data() at the location computed by i * strides[0] + j * strides[1]
fn shape(&self) -> DimArray
The shape of the tensor
fn shape_ref(&self) -> &[usize]
Get the shape by reference
fn ordering(&self) -> StorageOrder
Get the storage order of this tensor
fn outer_dim(&self) -> Option<usize>
Get the slowest varying dimension index
fn inner_dim(&self) -> Option<usize>
Get the fastest varying dimension index
fn outer_stride(&self) -> Option<usize>
The stride for the outer dimension
fn inner_stride(&self) -> Option<usize>
The stride for the inner dimension
fn outer_shape(&self) -> Option<usize>
The shape of the outer dimension
fn inner_shape(&self) -> Option<usize>
The stride for the inner dimension
fn borrowed(&self) -> TensorView<N, DimArray>
Get a view into this tensor
fn outer_block_iter(&self, block_size: usize) -> ChunkOuterBlocks<N, DimArray>
Iteration on outer blocks views of size block_size
fn data_index(&self, index: DimArray) -> usize
Index into the data array for the given N-dimensional index
fn to_owned(&self) -> TensorOwned<N, DimArray> where N: Copy
fn slice_dim(&self, Axis: Axis, index: usize) -> TensorView<N, DimArray::Pred> where DimArray: ArrayLikeMut<usize>
impl<N, DimArray, Storage> Tensor<N, DimArray, Storage> where DimArray: ArrayLike<usize>, Storage: DerefMut<Target=[N]>
[src]
fn outer_block_iter_mut(&mut self, block_size: usize) -> ChunkOuterBlocksMut<N, DimArray>
Iteration on mutable outer blocks views of size block_size
fn borrowed_mut(&mut self) -> TensorViewMut<N, DimArray>
Get a mutable view into this tensor
fn slice_dim_mut(&mut self, Axis: Axis, index: usize) -> TensorViewMut<N, DimArray::Pred> where DimArray: ArrayLikeMut<usize>
impl<N> Tensor<N, [usize; 2], Vec<N>>
[src]
fn new_owned(data: Vec<N>, rows: usize, cols: usize, strides: [usize; 2]) -> MatOwned<N>
Create a dense matrix from owned data
fn eye(dim: usize) -> MatOwned<N> where N: Num + Copy
Return the identity matrix of dimension dim
The storage will be row major, however one can transpose if needed
fn into_data(self) -> Vec<N>
Get the underlying data array as a vector
impl<'a, N: 'a> Tensor<N, [usize; 2], &'a [N]>
[src]
fn new_mat_view(data: &'a [N], rows: usize, cols: usize, strides: [usize; 2]) -> MatView<'a, N>
Create a view of a matrix implementing DenseMatView
impl<N, Storage> Tensor<N, [usize; 2], Storage> where Storage: Deref<Target=[N]>
[src]
fn rows(&self) -> usize
The number of rows of the matrix
fn cols(&self) -> usize
The number of cols of the matrix
fn row(&self, i: usize) -> Result<VecView<N>, DMatError>
Get a view into the specified row
fn col(&self, j: usize) -> Result<VecView<N>, DMatError>
Get a view into the specified column
impl<N, Storage> Tensor<N, [usize; 2], Storage> where Storage: DerefMut<Target=[N]>
[src]
fn data_mut(&mut self) -> &mut [N]
Mutable access to the matrix's data
Getting access to the element located at row i and column j can be done by indexing self.data() at the location computed by i * strides[0] + j * strides[1]
fn row_mut(&mut self, i: usize) -> Result<VecViewMut<N>, DMatError>
Get a mutable view into the specified row
fn col_mut(&mut self, j: usize) -> Result<VecViewMut<N>, DMatError>
Get a mutable view into the specified column
impl<N, Storage> Tensor<N, [usize; 1], Storage> where Storage: Deref<Target=[N]>
[src]
fn iter(&self) -> Map<Chunks<N>, fn(&[N]) -> &N>
Iterate over a dense vector's values by reference
fn dim(&self) -> usize
The number of dimensions
fn stride(&self) -> usize
The stride of this vector
impl<N, Storage> Tensor<N, [usize; 1], Storage> where Storage: DerefMut<Target=[N]>
[src]
fn iter_mut(&mut self) -> Map<ChunksMut<N>, fn(&mut [N]) -> &mut N>
Iterate over a dense vector's values by mutable reference
fn data_mut(&mut self) -> &mut [N]
The underlying data as a mutable slice
Trait Implementations
impl<N: Debug, DimArray: Debug, Storage: Debug> Debug for Tensor<N, DimArray, Storage> where Storage: Deref<Target=[N]>
[src]
impl<N: PartialEq, DimArray: PartialEq, Storage: PartialEq> PartialEq for Tensor<N, DimArray, Storage> where Storage: Deref<Target=[N]>
[src]
fn eq(&self, __arg_0: &Tensor<N, DimArray, Storage>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Tensor<N, DimArray, Storage>) -> bool
This method tests for !=
.
impl<N, DimArray, Storage> Index<DimArray> for Tensor<N, DimArray, Storage> where DimArray: ArrayLike<usize>, Storage: Deref<Target=[N]>
[src]
type Output = N
The returned type after indexing
fn index<'a>(&'a self, index: DimArray) -> &'a N
The method for the indexing (Foo[Bar]
) operation
impl<N, DimArray, Storage> IndexMut<DimArray> for Tensor<N, DimArray, Storage> where DimArray: ArrayLike<usize>, Storage: DerefMut<Target=[N]>
[src]
fn index_mut<'a>(&'a mut self, index: DimArray) -> &'a mut N
The method for the indexing (Foo[Bar]
) operation