pub struct TensorView<T, S, const D: usize> { /* private fields */ }
Expand description

A view into some or all of a tensor.

A TensorView has a similar relationship to a Tensor as a &str has to a String, or an array slice to an array. A TensorView cannot resize its source, and may span only a portion of the source Tensor in each dimension.

However a TensorView is generic not only over the type of the data in the Tensor, but also over the way the Tensor is ‘sliced’ and the two are orthogonal to each other.

TensorView closely mirrors the API of Tensor. Methods that create a new tensor do not return a TensorView, they return a Tensor.

Implementations§

source§

impl<T, S, const D: usize> TensorView<T, S, D>where
    S: TensorRef<T, D>,

TensorView methods which require only read access via a TensorRef source.

source

pub fn from(source: S) -> TensorView<T, S, D>

Creates a TensorView from a source of some type.

The lifetime of the source determines the lifetime of the TensorView created. If the TensorView is created from a reference to a Tensor, then the TensorView cannot live longer than the Tensor referenced.

source

pub fn source(self) -> S

Consumes the tensor view, yielding the source it was created from.

source

pub fn source_ref(&self) -> &S

Gives a reference to the tensor view’s source.

source

pub fn source_ref_mut(&mut self) -> &mut S

Gives a mutable reference to the tensor view’s source.

source

pub fn shape(&self) -> [(Dimension, usize); D]

The shape of this tensor view. Since Tensors are named Tensors, their shape is not just a list of length along each dimension, but instead a list of pairs of names and lengths.

Note that a TensorView may have a shape which is different than the Tensor it is providing access to the data of. The TensorView might be masking dimensions or elements from the shape, or exposing false ones.

See also

source

pub fn index_by(&self, dimensions: [Dimension; D]) -> TensorAccess<T, &S, D>

Returns a TensorAccess which can be indexed in the order of the supplied dimensions to read values from this tensor view.

Panics

If the set of dimensions supplied do not match the set of dimensions in this tensor’s shape.

source

pub fn index_by_mut(
    &mut self,
    dimensions: [Dimension; D]
) -> TensorAccess<T, &mut S, D>

Returns a TensorAccess which can be indexed in the order of the supplied dimensions to read or write values from this tensor view.

Panics

If the set of dimensions supplied do not match the set of dimensions in this tensor’s shape.

source

pub fn index_by_owned(self, dimensions: [Dimension; D]) -> TensorAccess<T, S, D>

Returns a TensorAccess which can be indexed in the order of the supplied dimensions to read or write values from this tensor view.

Panics

If the set of dimensions supplied do not match the set of dimensions in this tensor’s shape.

source

pub fn index(&self) -> TensorAccess<T, &S, D>

Creates a TensorAccess which will index into the dimensions of the source this TensorView was created with in the same order as they were declared. See TensorAccess::from_source_order.

source

pub fn index_mut(&mut self) -> TensorAccess<T, &mut S, D>

Creates a TensorAccess which will index into the dimensions of the source this TensorView was created with in the same order as they were declared. The TensorAccess mutably borrows the source, and can therefore mutate it if it implements TensorMut. See TensorAccess::from_source_order.

source

pub fn index_owned(self) -> TensorAccess<T, S, D>

Creates a TensorAccess which will index into the dimensions this Tensor was created with in the same order as they were provided. The TensorAccess takes ownership of the Tensor, and can therefore mutate it. The TensorAccess takes ownership of the source, and can therefore mutate it if it implements TensorMut. See TensorAccess::from_source_order.

source

pub fn iter_reference(&self) -> TensorReferenceIterator<'_, T, S, D>

Returns an iterator over references to the data in this TensorView.

source

pub fn rename_view(
    &self,
    dimensions: [Dimension; D]
) -> TensorView<T, TensorRename<T, &S, D>, D>

Returns a TensorView with the dimension names of the shape renamed to the provided dimensions. The data of this tensor and the dimension lengths and order remain unchanged.

This is a shorthand for constructing the TensorView from this TensorView. See Tensor::rename_view.

Panics

If a dimension name is not unique

source

pub fn range<R, const P: usize>(
    &self,
    ranges: [(Dimension, R); P]
) -> Result<TensorView<T, TensorRange<T, &S, D>, D>, IndexRangeValidationError<D, P>>where
    R: Into<IndexRange>,

Returns a TensorView with a range taken in P dimensions, hiding the values outside the range from view. Error cases are documented on TensorRange.

This is a shorthand for constructing the TensorView from this TensorView. See Tensor::range.

source

pub fn range_mut<R, const P: usize>(
    &mut self,
    ranges: [(Dimension, R); P]
) -> Result<TensorView<T, TensorRange<T, &mut S, D>, D>, IndexRangeValidationError<D, P>>where
    R: Into<IndexRange>,

Returns a TensorView with a range taken in P dimensions, hiding the values outside the range from view. Error cases are documented on TensorRange. The TensorRange mutably borrows the source, and can therefore mutate it if it implements TensorMut.

This is a shorthand for constructing the TensorView from this TensorView. See Tensor::range.

source

pub fn range_owned<R, const P: usize>(
    self,
    ranges: [(Dimension, R); P]
) -> Result<TensorView<T, TensorRange<T, S, D>, D>, IndexRangeValidationError<D, P>>where
    R: Into<IndexRange>,

Returns a TensorView with a range taken in P dimensions, hiding the values outside the range from view. Error cases are documented on TensorRange. The TensorRange takes ownership of the source, and can therefore mutate it if it implements TensorMut.

This is a shorthand for constructing the TensorView from this TensorView. See Tensor::range.

source

pub fn mask<R, const P: usize>(
    &self,
    masks: [(Dimension, R); P]
) -> Result<TensorView<T, TensorMask<T, &S, D>, D>, IndexRangeValidationError<D, P>>where
    R: Into<IndexRange>,

Returns a TensorView with a mask taken in P dimensions, hiding the values inside the range from view. Error cases are documented on TensorMask.

This is a shorthand for constructing the TensorView from this TensorView. See Tensor::mask.

source

pub fn mask_mut<R, const P: usize>(
    &mut self,
    masks: [(Dimension, R); P]
) -> Result<TensorView<T, TensorMask<T, &mut S, D>, D>, IndexRangeValidationError<D, P>>where
    R: Into<IndexRange>,

Returns a TensorView with a mask taken in P dimensions, hiding the values inside the range from view. Error cases are documented on TensorMask. The TensorMask mutably borrows the source, and can therefore mutate it if it implements TensorMut.

This is a shorthand for constructing the TensorView from this TensorView. See Tensor::mask.

source

pub fn mask_owned<R, const P: usize>(
    self,
    masks: [(Dimension, R); P]
) -> Result<TensorView<T, TensorMask<T, S, D>, D>, IndexRangeValidationError<D, P>>where
    R: Into<IndexRange>,

Returns a TensorView with a mask taken in P dimensions, hiding the values inside the range from view. Error cases are documented on TensorMask. The TensorMask takes ownership of the source, and can therefore mutate it if it implements TensorMut.

This is a shorthand for constructing the TensorView from this TensorView. See Tensor::mask.

source

pub fn elementwise_reference<S2, I, M>(
    &self,
    rhs: I,
    mapping_function: M
) -> Tensor<T, D>where
    I: Into<TensorView<T, S2, D>>,
    S2: TensorRef<T, D>,
    M: Fn(&T, &T) -> T,

Creates and returns a new tensor with all value pairs of two tensors with the same shape mapped by a function. The value pairs are not copied for you, if you’re using Copy types or need to clone the values anyway, you can use TensorView::elementwise instead.

Generics

This method can be called with any right hand side that can be converted to a TensorView, which includes Tensor, &Tensor, &mut Tensor as well as references to a TensorView.

Panics

If the two tensors have different shapes.

source

pub fn elementwise_reference_with_index<S2, I, M>(
    &self,
    rhs: I,
    mapping_function: M
) -> Tensor<T, D>where
    I: Into<TensorView<T, S2, D>>,
    S2: TensorRef<T, D>,
    M: Fn([usize; D], &T, &T) -> T,

Creates and returns a new tensor with all value pairs of two tensors with the same shape mapped by a function. The mapping function also receives each index corresponding to the value pairs. The value pairs are not copied for you, if you’re using Copy types or need to clone the values anyway, you can use TensorView::elementwise_with_index instead.

Generics

This method can be called with any right hand side that can be converted to a TensorView, which includes Tensor, &Tensor, &mut Tensor as well as references to a TensorView.

Panics

If the two tensors have different shapes.

source

pub fn transpose_view(
    &self,
    dimensions: [Dimension; D]
) -> TensorView<T, TensorTranspose<T, &S, D>, D>

Returns a TensorView which makes the order of the data in this tensor appear to be in a different order. The order of the dimension names is unchanged, although their lengths may swap.

This is a shorthand for constructing the TensorView from this TensorView.

See also: transpose, TensorTranspose

Panics

If the set of dimensions in the tensor does not match the set of dimensions provided. The order need not match.

source§

impl<T, S, const D: usize> TensorView<T, S, D>where
    S: TensorMut<T, D>,

source

pub fn iter_reference_mut(&mut self) -> TensorReferenceMutIterator<'_, T, S, D>

Returns an iterator over mutable references to the data in this TensorView.

source§

impl<T, S, const D: usize> TensorView<T, S, D>where
    T: Clone,
    S: TensorRef<T, D>,

TensorView methods which require only read access via a TensorRef source and a clonable type.

source

pub fn first(&self) -> T

Gets a copy of the first value in this tensor. For 0 dimensional tensors this is the only index [], for 1 dimensional tensors this is [0], for 2 dimensional tensors [0,0], etcetera.

source

pub fn transpose(&self, dimensions: [Dimension; D]) -> Tensor<T, D>

Returns a new Tensor which has the same data as this tensor, but with the order of data changed. The order of the dimension names is unchanged, although their lengths may swap.

For example, with a [("x", x), ("y", y)] tensor you could call transpose(["y", "x"]) which would return a new tensor with a shape of [("x", y), ("y", x)] where every (x,y) of its data corresponds to (y,x) in the original.

This method need not shift all the dimensions though, you could also swap the width and height of images in a tensor with a shape of [("batch", b), ("h", h), ("w", w), ("c", c)] via transpose(["batch", "w", "h", "c"]) which would return a new tensor where all the images have been swapped over the diagonal.

See also: TensorAccess, reorder

Panics

If the set of dimensions in the tensor does not match the set of dimensions provided. The order need not match (and if the order does match, this function is just an expensive clone).

source

pub fn reorder(&self, dimensions: [Dimension; D]) -> Tensor<T, D>

Returns a new Tensor which has the same data as this tensor, but with the order of the dimensions and corresponding order of data changed.

For example, with a [("x", x), ("y", y)] tensor you could call reorder(["y", "x"]) which would return a new tensor with a shape of [("y", y), ("x", x)] where every (y,x) of its data corresponds to (x,y) in the original.

This method need not shift all the dimensions though, you could also swap the width and height of images in a tensor with a shape of [("batch", b), ("h", h), ("w", w), ("c", c)] via reorder(["batch", "w", "h", "c"]) which would return a new tensor where every (b,w,h,c) of its data corresponds to (b,h,w,c) in the original.

See also: TensorAccess, transpose

Panics

If the set of dimensions in the tensor does not match the set of dimensions provided. The order need not match (and if the order does match, this function is just an expensive clone).

source

pub fn map<U>(&self, mapping_function: impl Fn(T) -> U) -> Tensor<U, D>

Creates and returns a new tensor with all values from the original with the function applied to each. This can be used to change the type of the tensor such as creating a mask:

use easy_ml::tensors::Tensor;
use easy_ml::tensors::views::TensorView;
let x = TensorView::from(Tensor::from([("a", 2), ("b", 2)], vec![
   0.0, 1.2,
   5.8, 6.9
]));
let y = x.map(|element| element > 2.0);
let result = Tensor::from([("a", 2), ("b", 2)], vec![
   false, false,
   true, true
]);
assert_eq!(&y, &result);
source

pub fn map_with_index<U>(
    &self,
    mapping_function: impl Fn([usize; D], T) -> U
) -> Tensor<U, D>

Creates and returns a new tensor with all values from the original and the index of each value mapped by a function.

source

pub fn iter(&self) -> TensorIterator<'_, T, S, D>

Returns an iterator over copies of the data in this TensorView.

source

pub fn elementwise<S2, I, M>(&self, rhs: I, mapping_function: M) -> Tensor<T, D>where
    I: Into<TensorView<T, S2, D>>,
    S2: TensorRef<T, D>,
    M: Fn(T, T) -> T,

Creates and returns a new tensor with all value pairs of two tensors with the same shape mapped by a function.

use easy_ml::tensors::Tensor;
use easy_ml::tensors::views::TensorView;
let lhs = TensorView::from(Tensor::from([("a", 4)], vec![1, 2, 3, 4]));
let rhs = TensorView::from(Tensor::from([("a", 4)], vec![0, 1, 2, 3]));
let multiplied = lhs.elementwise(&rhs, |l, r| l * r);
assert_eq!(
    multiplied,
    Tensor::from([("a", 4)], vec![0, 2, 6, 12])
);
Generics

This method can be called with any right hand side that can be converted to a TensorView, which includes Tensor, &Tensor, &mut Tensor as well as references to a TensorView.

Panics

If the two tensors have different shapes.

source

pub fn elementwise_with_index<S2, I, M>(
    &self,
    rhs: I,
    mapping_function: M
) -> Tensor<T, D>where
    I: Into<TensorView<T, S2, D>>,
    S2: TensorRef<T, D>,
    M: Fn([usize; D], T, T) -> T,

Creates and returns a new tensor with all value pairs of two tensors with the same shape mapped by a function. The mapping function also receives each index corresponding to the value pairs.

Generics

This method can be called with any right hand side that can be converted to a TensorView, which includes Tensor, &Tensor, &mut Tensor as well as references to a TensorView.

Panics

If the two tensors have different shapes.

source§

impl<T, S> TensorView<T, S, 0>where
    T: Clone,
    S: TensorRef<T, 0>,

TensorView methods which require only read access via a scalar TensorRef source and a clonable type.

source

pub fn scalar(&self) -> T

Returns a copy of the sole element in the 0 dimensional tensor.

source§

impl<T, S, const D: usize> TensorView<T, S, D>where
    T: Clone,
    S: TensorMut<T, D>,

TensorView methods which require mutable access via a TensorMut source.

source

pub fn map_mut(&mut self, mapping_function: impl Fn(T) -> T)

Applies a function to all values in the tensor view, modifying the tensor in place.

source

pub fn map_mut_with_index(
    &mut self,
    mapping_function: impl Fn([usize; D], T) -> T
)

Applies a function to all values and each value’s index in the tensor view, modifying the tensor view in place.

source§

impl<T, S> TensorView<T, S, 1>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 1>,

source

pub fn scalar_product<S2, I>(&self, rhs: I) -> Twhere
    I: Into<TensorView<T, S2, 1>>,
    S2: TensorRef<T, 1>,

Computes the scalar product of two equal length vectors. For two vectors [a,b,c] and [d,e,f], returns a*d + b*e + c*f. This is also known as the dot product.

use easy_ml::tensors::Tensor;
use easy_ml::tensors::views::TensorView;
let tensor_view = TensorView::from(Tensor::from([("sequence", 5)], vec![3, 4, 5, 6, 7]));
assert_eq!(tensor_view.scalar_product(&tensor_view), 3*3 + 4*4 + 5*5 + 6*6 + 7*7);
Generics

This method can be called with any right hand side that can be converted to a TensorView, which includes Tensor, &Tensor, &mut Tensor as well as references to a TensorView.

Panics

If the two vectors are not of equal length or their dimension names do not match.

source§

impl<T, S> TensorView<T, S, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

source

pub fn determinant(&self) -> Option<T>

Returns the determinant of this square matrix, or None if the matrix does not have a determinant. See linear_algebra

source

pub fn inverse(&self) -> Option<Tensor<T, 2>>

Computes the inverse of a matrix provided that it exists. To have an inverse a matrix must be square (same number of rows and columns) and it must also have a non zero determinant. See linear_algebra

source

pub fn covariance(&self, feature_dimension: Dimension) -> Tensor<T, 2>

Computes the covariance matrix for this feature matrix along the specified feature dimension in this matrix. See linear_algebra.

source§

impl<T, S> TensorView<T, S, 6>where
    S: TensorRef<T, 6>,

source

pub fn select(
    &self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 6, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this TensorView, with the removed dimensions always indexed as the provided values.

This is a shorthand for manually constructing the TensorView and TensorIndex

Note: due to limitations in Rust’s const generics support, this method is only implemented for provided_indexes of length 1 and D from 1 to 6. You can fall back to manual construction to create TensorIndexes with multiple provided indexes if you need to reduce dimensionality by more than 1 dimension at a time.

source

pub fn select_mut(
    &mut self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 6, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See select

source

pub fn select_owned(
    self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 6, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See select

source§

impl<T, S> TensorView<T, S, 5>where
    S: TensorRef<T, 5>,

source

pub fn select(
    &self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 5, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this TensorView, with the removed dimensions always indexed as the provided values.

This is a shorthand for manually constructing the TensorView and TensorIndex

Note: due to limitations in Rust’s const generics support, this method is only implemented for provided_indexes of length 1 and D from 1 to 6. You can fall back to manual construction to create TensorIndexes with multiple provided indexes if you need to reduce dimensionality by more than 1 dimension at a time.

source

pub fn select_mut(
    &mut self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 5, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See select

source

pub fn select_owned(
    self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 5, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See select

source§

impl<T, S> TensorView<T, S, 4>where
    S: TensorRef<T, 4>,

source

pub fn select(
    &self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 4, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this TensorView, with the removed dimensions always indexed as the provided values.

This is a shorthand for manually constructing the TensorView and TensorIndex

Note: due to limitations in Rust’s const generics support, this method is only implemented for provided_indexes of length 1 and D from 1 to 6. You can fall back to manual construction to create TensorIndexes with multiple provided indexes if you need to reduce dimensionality by more than 1 dimension at a time.

source

pub fn select_mut(
    &mut self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 4, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See select

source

pub fn select_owned(
    self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 4, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See select

source§

impl<T, S> TensorView<T, S, 3>where
    S: TensorRef<T, 3>,

source

pub fn select(
    &self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 3, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this TensorView, with the removed dimensions always indexed as the provided values.

This is a shorthand for manually constructing the TensorView and TensorIndex

Note: due to limitations in Rust’s const generics support, this method is only implemented for provided_indexes of length 1 and D from 1 to 6. You can fall back to manual construction to create TensorIndexes with multiple provided indexes if you need to reduce dimensionality by more than 1 dimension at a time.

source

pub fn select_mut(
    &mut self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 3, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See select

source

pub fn select_owned(
    self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 3, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See select

source§

impl<T, S> TensorView<T, S, 2>where
    S: TensorRef<T, 2>,

source

pub fn select(
    &self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 2, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this TensorView, with the removed dimensions always indexed as the provided values.

This is a shorthand for manually constructing the TensorView and TensorIndex

Note: due to limitations in Rust’s const generics support, this method is only implemented for provided_indexes of length 1 and D from 1 to 6. You can fall back to manual construction to create TensorIndexes with multiple provided indexes if you need to reduce dimensionality by more than 1 dimension at a time.

source

pub fn select_mut(
    &mut self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 2, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See select

source

pub fn select_owned(
    self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 2, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See select

source§

impl<T, S> TensorView<T, S, 1>where
    S: TensorRef<T, 1>,

source

pub fn select(
    &self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 1, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this TensorView, with the removed dimensions always indexed as the provided values.

This is a shorthand for manually constructing the TensorView and TensorIndex

Note: due to limitations in Rust’s const generics support, this method is only implemented for provided_indexes of length 1 and D from 1 to 6. You can fall back to manual construction to create TensorIndexes with multiple provided indexes if you need to reduce dimensionality by more than 1 dimension at a time.

source

pub fn select_mut(
    &mut self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 1, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See select

source

pub fn select_owned(
    self,
    provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 1, { _ }>, { _ }>

Selects the provided dimension name and index pairs in this TensorView, returning a TensorView which has fewer dimensions than this Tensor, with the removed dimensions always indexed as the provided values. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See select

source§

impl<T, S> TensorView<T, S, 0>where
    S: TensorRef<T, 0>,

source

pub fn expand(
    &self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 0, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this TensorView.

This is a shorthand for manually constructing the TensorView and TensorExpansion

Note: due to limitations in Rust’s const generics support, this method is only implemented for extra_dimension_names of length 1 and D from 0 to 5. You can fall back to manual construction to create TensorExpansions with multiple provided indexes if you need to increase dimensionality by more than 1 dimension at a time.

source

pub fn expand_mut(
    &mut self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 0, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See expand

source

pub fn expand_owned(
    self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 0, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See expand

source§

impl<T, S> TensorView<T, S, 1>where
    S: TensorRef<T, 1>,

source

pub fn expand(
    &self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 1, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this TensorView.

This is a shorthand for manually constructing the TensorView and TensorExpansion

Note: due to limitations in Rust’s const generics support, this method is only implemented for extra_dimension_names of length 1 and D from 0 to 5. You can fall back to manual construction to create TensorExpansions with multiple provided indexes if you need to increase dimensionality by more than 1 dimension at a time.

source

pub fn expand_mut(
    &mut self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 1, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See expand

source

pub fn expand_owned(
    self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 1, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See expand

source§

impl<T, S> TensorView<T, S, 2>where
    S: TensorRef<T, 2>,

source

pub fn expand(
    &self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 2, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this TensorView.

This is a shorthand for manually constructing the TensorView and TensorExpansion

Note: due to limitations in Rust’s const generics support, this method is only implemented for extra_dimension_names of length 1 and D from 0 to 5. You can fall back to manual construction to create TensorExpansions with multiple provided indexes if you need to increase dimensionality by more than 1 dimension at a time.

source

pub fn expand_mut(
    &mut self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 2, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See expand

source

pub fn expand_owned(
    self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 2, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See expand

source§

impl<T, S> TensorView<T, S, 3>where
    S: TensorRef<T, 3>,

source

pub fn expand(
    &self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 3, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this TensorView.

This is a shorthand for manually constructing the TensorView and TensorExpansion

Note: due to limitations in Rust’s const generics support, this method is only implemented for extra_dimension_names of length 1 and D from 0 to 5. You can fall back to manual construction to create TensorExpansions with multiple provided indexes if you need to increase dimensionality by more than 1 dimension at a time.

source

pub fn expand_mut(
    &mut self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 3, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See expand

source

pub fn expand_owned(
    self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 3, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See expand

source§

impl<T, S> TensorView<T, S, 4>where
    S: TensorRef<T, 4>,

source

pub fn expand(
    &self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 4, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this TensorView.

This is a shorthand for manually constructing the TensorView and TensorExpansion

Note: due to limitations in Rust’s const generics support, this method is only implemented for extra_dimension_names of length 1 and D from 0 to 5. You can fall back to manual construction to create TensorExpansions with multiple provided indexes if you need to increase dimensionality by more than 1 dimension at a time.

source

pub fn expand_mut(
    &mut self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 4, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See expand

source

pub fn expand_owned(
    self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 4, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See expand

source§

impl<T, S> TensorView<T, S, 5>where
    S: TensorRef<T, 5>,

source

pub fn expand(
    &self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 5, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this TensorView.

This is a shorthand for manually constructing the TensorView and TensorExpansion

Note: due to limitations in Rust’s const generics support, this method is only implemented for extra_dimension_names of length 1 and D from 0 to 5. You can fall back to manual construction to create TensorExpansions with multiple provided indexes if you need to increase dimensionality by more than 1 dimension at a time.

source

pub fn expand_mut(
    &mut self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 5, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex mutably borrows this Tensor, and can therefore mutate it

See expand

source

pub fn expand_owned(
    self,
    extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 5, { _ }>, { _ }>

Expands the dimensionality of this tensor by adding dimensions of length 1 at a particular position within the shape, returning a TensorView which has more dimensions than this Tensor. The TensorIndex takes ownership of this Tensor, and can therefore mutate it

See expand

Trait Implementations§

source§

impl<T, S, const D: usize> Add<&Tensor<T, D>> for &TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a referenced tensor view and a referenced tensor

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Tensor<T, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Add<&Tensor<T, D>> for TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a tensor view and a referenced tensor

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Tensor<T, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Add<&TensorView<T, S, D>> for &Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a referenced tensor and a referenced tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &TensorView<T, S, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Add<&TensorView<T, S, D>> for Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a tensor and a referenced tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &TensorView<T, S, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S1, S2, const D: usize> Add<&TensorView<T, S2, D>> for &TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise addition for two referenced tensor views

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &TensorView<T, S2, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S1, S2, const D: usize> Add<&TensorView<T, S2, D>> for TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise addition for two tensor views with one referenced

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &TensorView<T, S2, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Add<Tensor<T, D>> for &TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a referenced tensor view and a tensor

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Tensor<T, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Add<Tensor<T, D>> for TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a tensor view and a tensor

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Tensor<T, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Add<TensorView<T, S, D>> for &Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a referenced tensor and a tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: TensorView<T, S, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Add<TensorView<T, S, D>> for Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise addition for a tensor and a tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: TensorView<T, S, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S1, S2, const D: usize> Add<TensorView<T, S2, D>> for &TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise addition for two tensor views with one referenced

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: TensorView<T, S2, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S1, S2, const D: usize> Add<TensorView<T, S2, D>> for TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise addition for two tensor views

§

type Output = Tensor<T, D>

The resulting type after applying the + operator.
source§

fn add(self, rhs: TensorView<T, S2, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<T, S, const D: usize> Debug for TensorView<T, S, D>where
    T: Debug,
    S: Debug + TensorRef<T, D>,

Debug implementations for TensorView additionally show the visible data and visible dimensions reported by the source as fields. This is in addition to recursive debug content of the actual source.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, S, const D: usize> Display for TensorView<T, S, D>where
    T: Display,
    S: TensorRef<T, D>,

Any tensor view of a Displayable type implements Display

You can control the precision of the formatting using format arguments, i.e. format!("{:.3}", tensor)

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T, const D: usize> From<&'a Tensor<T, D>> for TensorView<T, &'a Tensor<T, D>, D>

A reference to a Tensor can be converted to a TensorView of that referenced Tensor.

source§

fn from(tensor: &Tensor<T, D>) -> TensorView<T, &Tensor<T, D>, D>

Converts to this type from the input type.
source§

impl<'a, T, S, const D: usize> From<&'a TensorView<T, S, D>> for TensorView<T, &'a S, D>where
    S: TensorRef<T, D>,

A reference to a TensorView can be converted to an owned TensorView with a reference to the source type of that first TensorView.

source§

fn from(tensor_view: &TensorView<T, S, D>) -> TensorView<T, &S, D>

Converts to this type from the input type.
source§

impl<'a, T, const D: usize> From<&'a mut Tensor<T, D>> for TensorView<T, &'a mut Tensor<T, D>, D>

A mutable reference to a Tensor can be converted to a TensorView of that mutably referenced Tensor.

source§

fn from(tensor: &mut Tensor<T, D>) -> TensorView<T, &mut Tensor<T, D>, D>

Converts to this type from the input type.
source§

impl<'a, T, S, const D: usize> From<&'a mut TensorView<T, S, D>> for TensorView<T, &'a mut S, D>where
    S: TensorRef<T, D>,

A mutable reference to a TensorView can be converted to an owned TensorView with a mutable reference to the source type of that first TensorView.

source§

fn from(tensor_view: &mut TensorView<T, S, D>) -> TensorView<T, &mut S, D>

Converts to this type from the input type.
source§

impl<T, const D: usize> From<Tensor<T, D>> for TensorView<T, Tensor<T, D>, D>

A Tensor can be converted to a TensorView of that Tensor.

source§

fn from(tensor: Tensor<T, D>) -> TensorView<T, Tensor<T, D>, D>

Converts to this type from the input type.
source§

impl<T, S> Mul<&Tensor<T, 2>> for &TensorView<T, S, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional referenced tensor view and a referenced tensor

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Tensor<T, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S> Mul<&Tensor<T, 2>> for TensorView<T, S, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional tensor view and a referenced tensor

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Tensor<T, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S> Mul<&TensorView<T, S, 2>> for &Tensor<T, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional referenced tensor and a referenced tensor view

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &TensorView<T, S, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S> Mul<&TensorView<T, S, 2>> for Tensor<T, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional tensor and a referenced tensor view

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &TensorView<T, S, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S1, S2> Mul<&TensorView<T, S2, 2>> for &TensorView<T, S1, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, 2>,
    S2: TensorRef<T, 2>,

Matrix multiplication of two referenced 2-dimensional tensors

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &TensorView<T, S2, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S1, S2> Mul<&TensorView<T, S2, 2>> for TensorView<T, S1, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, 2>,
    S2: TensorRef<T, 2>,

Matrix multiplication of two 2-dimensional tensors with one referenced

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &TensorView<T, S2, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S> Mul<Tensor<T, 2>> for &TensorView<T, S, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional referenced tensor view and a tensor

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Tensor<T, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S> Mul<Tensor<T, 2>> for TensorView<T, S, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional tensor view and a tensor

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Tensor<T, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S> Mul<TensorView<T, S, 2>> for &Tensor<T, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional referenced tensor and a tensor view

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: TensorView<T, S, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S> Mul<TensorView<T, S, 2>> for Tensor<T, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, 2>,

Matrix multiplication for a 2-dimensional tensor and a tensor view

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: TensorView<T, S, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S1, S2> Mul<TensorView<T, S2, 2>> for &TensorView<T, S1, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, 2>,
    S2: TensorRef<T, 2>,

Matrix multiplication of two 2-dimensional tensors with one referenced

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: TensorView<T, S2, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S1, S2> Mul<TensorView<T, S2, 2>> for TensorView<T, S1, 2>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, 2>,
    S2: TensorRef<T, 2>,

Matrix multiplication of two 2-dimensional tensors

§

type Output = Tensor<T, 2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: TensorView<T, S2, 2>) -> Self::Output

Performs the * operation. Read more
source§

impl<T, S, const D: usize> PartialEq<Tensor<T, D>> for TensorView<T, S, D>where
    T: PartialEq,
    S: TensorRef<T, D>,

A TensorView and a Tensor can be compared for equality. The tensors are equal if they have an equal shape and all their elements are equal.

source§

fn eq(&self, other: &Tensor<T, D>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, S, const D: usize> PartialEq<TensorView<T, S, D>> for Tensor<T, D>where
    T: PartialEq,
    S: TensorRef<T, D>,

A Tensor and a TensorView can be compared for equality. The tensors are equal if they have an equal shape and all their elements are equal.

source§

fn eq(&self, other: &TensorView<T, S, D>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, S1, S2, const D: usize> PartialEq<TensorView<T, S2, D>> for TensorView<T, S1, D>where
    T: PartialEq,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Two TensorViews are equal if they have an equal shape and all their elements are equal. Differences in their source types are ignored.

source§

fn eq(&self, other: &TensorView<T, S2, D>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, S, const D: usize> Similar<Tensor<T, D>> for TensorView<T, S, D>where
    T: PartialEq,
    S: TensorRef<T, D>,

A TensorView and a Tensor can be compared for similarity. The tensors are similar if they have the same set of dimension names and lengths even if two shapes are not in the same order, and all their elements are equal when comparing both tensors via the same dimension ordering.

source§

fn similar(&self, other: &Tensor<T, D>) -> bool

Tests if two values are similar. This is a looser comparison than PartialEq, but anything which is PartialEq is also similar.
source§

impl<T, S, const D: usize> Similar<TensorView<T, S, D>> for Tensor<T, D>where
    T: PartialEq,
    S: TensorRef<T, D>,

A Tensor and a TensorView can be compared for similarity. The tensors are similar if they have the same set of dimension names and lengths even if two shapes are not in the same order, and all their elements are equal when comparing both tensors via the same dimension ordering.

source§

fn similar(&self, other: &TensorView<T, S, D>) -> bool

Tests if two values are similar. This is a looser comparison than PartialEq, but anything which is PartialEq is also similar.
source§

impl<T, S1, S2, const D: usize> Similar<TensorView<T, S2, D>> for TensorView<T, S1, D>where
    T: PartialEq,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Two TensorViews are similar if they have the same set of dimension names and lengths even if two shapes are not in the same order, and all their elements are equal when comparing both tensors via the same dimension ordering. Differences in their source types are ignored.

source§

fn similar(&self, other: &TensorView<T, S2, D>) -> bool

Tests if two values are similar. This is a looser comparison than PartialEq, but anything which is PartialEq is also similar.
source§

impl<T, S, const D: usize> Sub<&Tensor<T, D>> for &TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a referenced tensor view and a referenced tensor

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Tensor<T, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S, const D: usize> Sub<&Tensor<T, D>> for TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a tensor view and a referenced tensor

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Tensor<T, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S, const D: usize> Sub<&TensorView<T, S, D>> for &Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a referenced tensor and a referenced tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &TensorView<T, S, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S, const D: usize> Sub<&TensorView<T, S, D>> for Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a tensor and a referenced tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &TensorView<T, S, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S1, S2, const D: usize> Sub<&TensorView<T, S2, D>> for &TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise subtraction for two referenced tensor views

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &TensorView<T, S2, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S1, S2, const D: usize> Sub<&TensorView<T, S2, D>> for TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise subtraction for two tensor views with one referenced

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &TensorView<T, S2, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S, const D: usize> Sub<Tensor<T, D>> for &TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a referenced tensor view and a tensor

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Tensor<T, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S, const D: usize> Sub<Tensor<T, D>> for TensorView<T, S, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a tensor view and a tensor

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Tensor<T, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S, const D: usize> Sub<TensorView<T, S, D>> for &Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a referenced tensor and a tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: TensorView<T, S, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S, const D: usize> Sub<TensorView<T, S, D>> for Tensor<T, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S: TensorRef<T, D>,

Elementwise subtraction for a tensor and a tensor view

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: TensorView<T, S, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S1, S2, const D: usize> Sub<TensorView<T, S2, D>> for &TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise subtraction for two tensor views with one referenced

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: TensorView<T, S2, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, S1, S2, const D: usize> Sub<TensorView<T, S2, D>> for TensorView<T, S1, D>where
    T: Numeric,
    for<'a> &'a T: NumericRef<T>,
    S1: TensorRef<T, D>,
    S2: TensorRef<T, D>,

Elementwise subtraction for two tensor views

§

type Output = Tensor<T, D>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: TensorView<T, S2, D>) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T, S, const D: usize> RefUnwindSafe for TensorView<T, S, D>where
    S: RefUnwindSafe,
    T: RefUnwindSafe,

§

impl<T, S, const D: usize> Send for TensorView<T, S, D>where
    S: Send,
    T: Send,

§

impl<T, S, const D: usize> Sync for TensorView<T, S, D>where
    S: Sync,
    T: Sync,

§

impl<T, S, const D: usize> Unpin for TensorView<T, S, D>where
    S: Unpin,
    T: Unpin,

§

impl<T, S, const D: usize> UnwindSafe for TensorView<T, S, D>where
    S: UnwindSafe,
    T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for Twhere
    T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.