Struct dense_mats::tensor::Tensor [] [src]

pub struct Tensor<N, DimArray, Storage> where
    Storage: Deref<Target = [N]>, 
{ /* fields omitted */ }

A simple dense matrix

Methods

impl<N, DimArray> Tensor<N, DimArray, Vec<N>> where
    DimArray: ArrayLikeMut<usize>, 
[src]

Create an all-zero tensor in C order

Create an all-zero tensor in F order

Create an all-one tensor in C order

Create an all-one tensor in F order

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

The number of dimensions of this tensor

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).

Get the strides by reference

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]

The shape of the tensor

Get the shape by reference

Returns true if the array is contiguous, ie the fastest varying axis has stride 1, and no unused data is present in the array

Checks whether all dimensions except the fastest varying one are contiguous. Having that property verified allows flattened views of the tensor using ravel(). Otherwise copies have to be done.

Get the storage order of this tensor

Get the slowest varying dimension index

Get the fastest varying dimension index

The stride for the outer dimension

The stride for the inner dimension

The shape of the outer dimension

The stride for the inner dimension

Get a view into this tensor

Iteration on outer blocks views of size block_size

Index into the data array for the given N-dimensional index

Iteration on the given axis

Get a view as a tensor of lower dimension count, by slicing into the given axis at the given index

Get a view over the tensor's diagonal

The diagonal vector is as long as the smallest dimension.

Panics

Panics if the tensor is zero-dim.

Get a flattened view of the tensor

This only works if the tensor verifies can_ravel()

Panics

If the tensor is not contiguous over all dimensions except the fastest varying one

On zero-dim tensors

impl<N, DimArray, Storage> Tensor<N, DimArray, Storage> where
    DimArray: ArrayLikeMut<usize>,
    Storage: Deref<Target = [N]>, 
[src]

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<N, DimArray, Storage> Tensor<N, DimArray, Storage> where
    DimArray: ArrayLikeMut<usize>,
    Storage: DerefMut<Target = [N]>, 
[src]

Iteration on mutable outer blocks views of size block_size

Get a mutable view into this tensor

Get a mutable view as a tensor of lower dimension count, by slicing into the given axis at the given index

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.

Get a mutable view over the tensor's diagonal

The diagonal vector is as long as the smallest dimension.

Panics

Panics if the tensor is zero-dim.

impl<N> Tensor<N, [usize; 2], Vec<N>>
[src]

Create a dense matrix from owned data

Return the identity matrix of dimension dim

The storage will be row major, however one can transpose if needed

Get the underlying data array as a vector

impl<'a, N: 'a> Tensor<N, [usize; 2], &'a [N]>
[src]

Create a view of a matrix implementing DenseMatView

impl<N, Storage> Tensor<N, [usize; 2], Storage> where
    Storage: Deref<Target = [N]>, 
[src]

The number of rows of the matrix

The number of cols of the matrix

Get a view into the specified row

Get a view into the specified column

impl<N, Storage> Tensor<N, [usize; 2], Storage> where
    Storage: DerefMut<Target = [N]>, 
[src]

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]

Get a mutable view into the specified row

Get a mutable view into the specified column

impl<N, Storage> Tensor<N, [usize; 1], Storage> where
    Storage: Deref<Target = [N]>, 
[src]

Iterate over a dense vector's values by reference

The number of dimensions

The stride of this vector

impl<N, Storage> Tensor<N, [usize; 1], Storage> where
    Storage: DerefMut<Target = [N]>, 
[src]

Iterate over a dense vector's values by mutable reference

The underlying data as a mutable slice

Trait Implementations

impl<N: PartialEq, DimArray: PartialEq, Storage: PartialEq> PartialEq for Tensor<N, DimArray, Storage> where
    Storage: Deref<Target = [N]>, 
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<N: Debug, DimArray: Debug, Storage: Debug> Debug for Tensor<N, DimArray, Storage> where
    Storage: Deref<Target = [N]>, 
[src]

Formats the value using the given formatter.

impl<N, DimArray, Storage> Index<DimArray> for Tensor<N, DimArray, Storage> where
    DimArray: ArrayLike<usize>,
    Storage: Deref<Target = [N]>, 
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl<N, DimArray, Storage> IndexMut<DimArray> for Tensor<N, DimArray, Storage> where
    DimArray: ArrayLike<usize>,
    Storage: DerefMut<Target = [N]>, 
[src]

The method for the mutable indexing (container[index]) operation