Struct numeric::tensor::Tensor [] [src]

pub struct Tensor<T> { /* fields omitted */ }

An implementation of an N-dimensional matrix. A quick example:

use numeric::Tensor;
let t = Tensor::new(vec![1.0f64, 3.0, 2.0, 2.0]).reshape(&[2, 2]);
println!("t = {}", t);

Will output:

t =
 1 3
 2 2
[Tensor<f64> of shape 2x2]

Methods

impl Tensor<f32>
[src]

Takes the product of two tensors. If the tensors are both matrices (2D), then a matrix multiplication is taken. If the tensors are both vectors (1D), the scalar product is taken.

impl Tensor<f64>
[src]

Takes the product of two tensors. If the tensors are both matrices (2D), then a matrix multiplication is taken. If the tensors are both vectors (1D), the scalar product is taken.

impl<T: TensorTrait + Add<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + Sub<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + Mul<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + Div<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + Rem<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + BitAnd<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + BitOr<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + BitXor<Output = T>> Tensor<T>
[src]

impl<T: NumericTrait> Tensor<T>
[src]

impl<T: TensorTrait + Add<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + Mul<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + BitAnd<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + BitOr<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait + BitXor<Output = T>> Tensor<T>
[src]

impl<T: TensorTrait> Tensor<T>
[src]

impl<T: NumericTrait> Tensor<T>
[src]

Returns a new tensor with the elements converted to the selected type.

use numeric::Tensor;

let tdouble = tensor![1.0f64, 2.0, 3.0];
let tsingle = tdouble.convert::<f32>();

Short-hand for convert::<f32>().

Short-hand for convert::<f64>().

impl<T: TensorTrait + PartialOrd> Tensor<T>
[src]

Element-wise comparison.

impl<T: TensorTrait + PartialOrd> Tensor<T>
[src]

Element-wise comparison.

impl<T: TensorTrait + PartialOrd> Tensor<T>
[src]

Element-wise comparison.

impl<T: TensorTrait + PartialOrd> Tensor<T>
[src]

Element-wise comparison.

impl<T: TensorTrait + PartialOrd> Tensor<T>
[src]

Element-wise comparison.

impl<T: TensorTrait + PartialOrd> Tensor<T>
[src]

Element-wise comparison.

impl Tensor<bool>
[src]

impl<T: TensorTrait> Tensor<T>
[src]

Creates a new tensor from a Vec object. It will take ownership of the vector.

Creates a zero-filled tensor of the specified shape.

Returns a flat slice of the tensor. Only works for canonical tensors.

Returns a mutable flat slice of the tensor. Only works for canonical tensors. Will make a copy of the underyling data if the tensor is not unique.

Creates a Tensor representing a scalar

Creates a new tensor of a given shape filled with the specified value.

Returns the shape of the tensor.

Returns length of single dimension.

Returns a reference of the underlying data vector.

Flattens the tensor to one-dimensional.

Make a dense copy of the tensor. This means it will have default strides and no memory offset.

Returns number of elements in the tensor.

Returns the number of axes. This is the same as the length of the shape array.

Takes slices (subsets) of tensors and returns a tensor as a new object. Uses the AxisIndex enum to specify indexing for each axis.

use numeric::{DoubleTensor, Ellipsis, StridedSlice, Index, Full};

let t = DoubleTensor::ones(&[2, 3, 4]);

t.index(&[Ellipsis, StridedSlice(Some(1), Some(3), 1)]); // shape [2, 3, 2]
t.index(&[Index(-1)]); // shape [3, 4]
t.index(&[Full, StridedSlice(Some(1), None, 1), Index(1)]); // shape [2, 2]

Returns the underlying memory as a vector.

Similar to index, except this updates the tensor with other instead of returning them.

Takes a flatten index (if in row-major order) and returns a vector of the per-axis indices.

Takes an array of per-axis indices and returns a flattened index (in row-major order).

Reshapes the data. This moves the data, so no memory is allocated.

Sets all the values according to another tensor.

Swaps two axes.

Transposes a matrix (for now, requires it to be 2D).

impl<T: Copy + Zero> Tensor<T>
[src]

Creates a zero-filled tensor of the specified shape.

impl<T: Copy + One> Tensor<T>
[src]

Creates a one-filled tensor of the specified shape.

impl<T: Copy + Zero + One> Tensor<T>
[src]

Creates an identity 2-D tensor (matrix). That is, all elements are zero except the diagonal which is filled with ones.

impl<T: Copy + Add + Zero + One> Tensor<T>
[src]

Creates a new vector with integer values starting at 0 and counting up:

use numeric::DoubleTensor;

let t = DoubleTensor::range(5); // [  0.00   1.00   2.00   3.00   4.00]

impl<T: TensorTrait + Num + NumCast> Tensor<T>
[src]

Creates a new vector between two values at constant increments. The number of elements is specified.

impl<T: NumericTrait> Tensor<T>
[src]

Creates a scalar specified as a f64 and internally casted to T

impl Tensor<f64>
[src]

Solves the linear equation Ax = b and returns x. The matrix A is self and must be a square matrix. The input b must be a vector.

Panics if matrix is singular.

impl Tensor<f32>
[src]

Solves the linear equation Ax = b and returns x. The matrix A is self and must be a square matrix. The input b must be a vector.

Panics if matrix is singular.

impl Tensor<f64>
[src]

Performs a singular value decomposition on the matrix.

impl Tensor<f32>
[src]

Performs a singular value decomposition on the matrix.

impl Tensor<u8>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<u16>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<u32>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<u64>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<i8>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<i16>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<i32>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<i64>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<f32>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

impl Tensor<f64>
[src]

Saves tensor to an HDF5 file.

Warning: This function is not thread-safe (unless you compiled HDF5 to be thread-safe). Do no call this function concurrently from multiple threads.

Trait Implementations

impl Display for Tensor<f32>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<f64>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<usize>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<u8>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<u16>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<u32>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<u64>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<isize>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<i8>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<i16>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<i32>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<i64>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<bool>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<Complex32>
[src]

Formats the value using the given formatter. Read more

impl Display for Tensor<Complex64>
[src]

Formats the value using the given formatter. Read more

impl<T: TensorTrait + Add<Output = T>> Add for Tensor<T>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, T: TensorTrait + Add<Output = T>> Add<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, T: TensorTrait + Add<Output = T>> Add<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<T: TensorTrait + Add<Output = T>> Add<T> for Tensor<T>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, T: TensorTrait + Add<Output = T>> Add<T> for &'a Tensor<T>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<T: TensorTrait + Sub<Output = T>> Sub for Tensor<T>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a, T: TensorTrait + Sub<Output = T>> Sub<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a, T: TensorTrait + Sub<Output = T>> Sub<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<T: TensorTrait + Sub<Output = T>> Sub<T> for Tensor<T>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a, T: TensorTrait + Sub<Output = T>> Sub<T> for &'a Tensor<T>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<T: TensorTrait + Mul<Output = T>> Mul for Tensor<T>
[src]

The resulting type after applying the * operator

The method for the * operator

impl<'a, T: TensorTrait + Mul<Output = T>> Mul<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the * operator

The method for the * operator

impl<'a, T: TensorTrait + Mul<Output = T>> Mul<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the * operator

The method for the * operator

impl<T: TensorTrait + Mul<Output = T>> Mul<T> for Tensor<T>
[src]

The resulting type after applying the * operator

The method for the * operator

impl<'a, T: TensorTrait + Mul<Output = T>> Mul<T> for &'a Tensor<T>
[src]

The resulting type after applying the * operator

The method for the * operator

impl<T: TensorTrait + Div<Output = T>> Div for Tensor<T>
[src]

The resulting type after applying the / operator

The method for the / operator

impl<'a, T: TensorTrait + Div<Output = T>> Div<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the / operator

The method for the / operator

impl<'a, T: TensorTrait + Div<Output = T>> Div<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the / operator

The method for the / operator

impl<T: TensorTrait + Div<Output = T>> Div<T> for Tensor<T>
[src]

The resulting type after applying the / operator

The method for the / operator

impl<'a, T: TensorTrait + Div<Output = T>> Div<T> for &'a Tensor<T>
[src]

The resulting type after applying the / operator

The method for the / operator

impl<T: TensorTrait + Rem<Output = T>> Rem for Tensor<T>
[src]

The resulting type after applying the % operator

The method for the % operator

impl<'a, T: TensorTrait + Rem<Output = T>> Rem<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the % operator

The method for the % operator

impl<'a, T: TensorTrait + Rem<Output = T>> Rem<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the % operator

The method for the % operator

impl<T: TensorTrait + Rem<Output = T>> Rem<T> for Tensor<T>
[src]

The resulting type after applying the % operator

The method for the % operator

impl<'a, T: TensorTrait + Rem<Output = T>> Rem<T> for &'a Tensor<T>
[src]

The resulting type after applying the % operator

The method for the % operator

impl<T: TensorTrait + BitAnd<Output = T>> BitAnd for Tensor<T>
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a, T: TensorTrait + BitAnd<Output = T>> BitAnd<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a, T: TensorTrait + BitAnd<Output = T>> BitAnd<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the & operator

The method for the & operator

impl<T: TensorTrait + BitAnd<Output = T>> BitAnd<T> for Tensor<T>
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a, T: TensorTrait + BitAnd<Output = T>> BitAnd<T> for &'a Tensor<T>
[src]

The resulting type after applying the & operator

The method for the & operator

impl<T: TensorTrait + BitOr<Output = T>> BitOr for Tensor<T>
[src]

The resulting type after applying the | operator

The method for the | operator

impl<'a, T: TensorTrait + BitOr<Output = T>> BitOr<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the | operator

The method for the | operator

impl<'a, T: TensorTrait + BitOr<Output = T>> BitOr<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the | operator

The method for the | operator

impl<T: TensorTrait + BitOr<Output = T>> BitOr<T> for Tensor<T>
[src]

The resulting type after applying the | operator

The method for the | operator

impl<'a, T: TensorTrait + BitOr<Output = T>> BitOr<T> for &'a Tensor<T>
[src]

The resulting type after applying the | operator

The method for the | operator

impl<T: TensorTrait + BitXor<Output = T>> BitXor for Tensor<T>
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a, T: TensorTrait + BitXor<Output = T>> BitXor<&'a Tensor<T>> for Tensor<T>
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a, T: TensorTrait + BitXor<Output = T>> BitXor<&'a Tensor<T>> for &'a Tensor<T>
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<T: TensorTrait + BitXor<Output = T>> BitXor<T> for Tensor<T>
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a, T: TensorTrait + BitXor<Output = T>> BitXor<T> for &'a Tensor<T>
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<T: TensorTrait + Neg<Output = T>> Neg for Tensor<T>
[src]

The resulting type after applying the - operator

The method for the unary - operator

impl<'a, T: TensorTrait + Neg<Output = T>> Neg for &'a Tensor<T>
[src]

The resulting type after applying the - operator

The method for the unary - operator

impl<T: TensorTrait + PartialOrd> PartialEq<Tensor<T>> for Tensor<T>
[src]

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

This method tests for !=.

impl<T: TensorTrait + PartialOrd> Eq for Tensor<T>
[src]

impl<'b, T: TensorTrait> Index<&'b [usize]> for Tensor<T>
[src]

The returned type after indexing

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

impl<'b, T: Copy> IndexMut<&'b [usize]> for Tensor<T>
[src]

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

impl<'b, T: Copy> Index<&'b Vec<usize>> for Tensor<T>
[src]

The returned type after indexing

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

impl<'b, T: TensorTrait> IndexMut<&'b Vec<usize>> for Tensor<T>
[src]

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

impl<T: TensorTrait> Index<(usize,)> for Tensor<T>
[src]

The returned type after indexing

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

impl<T: TensorTrait> IndexMut<(usize,)> for Tensor<T>
[src]

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

impl<T: TensorTrait> Index<(usize, usize)> for Tensor<T>
[src]

The returned type after indexing

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

impl<T: TensorTrait> IndexMut<(usize, usize)> for Tensor<T>
[src]

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

impl<T: TensorTrait> Index<(usize, usize, usize)> for Tensor<T>
[src]

The returned type after indexing

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

impl<T: TensorTrait> IndexMut<(usize, usize, usize)> for Tensor<T>
[src]

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

impl<T: TensorTrait> Clone for Tensor<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more