Struct easy_ml::tensors::views::TensorView
source · 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>,
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.
sourcepub fn from(source: S) -> TensorView<T, S, D>
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.
sourcepub fn source_ref(&self) -> &S
pub fn source_ref(&self) -> &S
Gives a reference to the tensor view’s source.
sourcepub fn source_ref_mut(&mut self) -> &mut S
pub fn source_ref_mut(&mut self) -> &mut S
Gives a mutable reference to the tensor view’s source.
sourcepub fn shape(&self) -> [(Dimension, usize); D]
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
sourcepub fn index_by(&self, dimensions: [Dimension; D]) -> TensorAccess<T, &S, D>
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.
sourcepub fn index_by_mut(
&mut self,
dimensions: [Dimension; D]
) -> TensorAccess<T, &mut S, D>
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.
sourcepub fn index_by_owned(self, dimensions: [Dimension; D]) -> TensorAccess<T, S, D>
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.
sourcepub fn index(&self) -> TensorAccess<T, &S, D>
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.
sourcepub fn index_mut(&mut self) -> TensorAccess<T, &mut S, D>
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.
sourcepub fn index_owned(self) -> TensorAccess<T, S, D>
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.
sourcepub fn iter_reference(&self) -> TensorReferenceIterator<'_, T, S, D> ⓘ
pub fn iter_reference(&self) -> TensorReferenceIterator<'_, T, S, D> ⓘ
Returns an iterator over references to the data in this TensorView.
sourcepub fn rename_view(
&self,
dimensions: [Dimension; D]
) -> TensorView<T, TensorRename<T, &S, D>, D>
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
sourcepub 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>,
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
.
sourcepub 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>,
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
.
sourcepub 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>,
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
.
sourcepub 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>,
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
.
sourcepub 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>,
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
.
sourcepub 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>,
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
.
sourcepub 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,
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.
sourcepub 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,
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.
sourcepub fn transpose_view(
&self,
dimensions: [Dimension; D]
) -> TensorView<T, TensorTranspose<T, &S, D>, D>
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>,
impl<T, S, const D: usize> TensorView<T, S, D>where
S: TensorMut<T, D>,
sourcepub fn iter_reference_mut(&mut self) -> TensorReferenceMutIterator<'_, T, S, D> ⓘ
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>,
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.
sourcepub fn first(&self) -> T
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.
sourcepub fn transpose(&self, dimensions: [Dimension; D]) -> Tensor<T, D>
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).
sourcepub fn reorder(&self, dimensions: [Dimension; D]) -> Tensor<T, D>
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).
sourcepub fn map<U>(&self, mapping_function: impl Fn(T) -> U) -> Tensor<U, D>
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);
sourcepub fn map_with_index<U>(
&self,
mapping_function: impl Fn([usize; D], T) -> U
) -> Tensor<U, D>
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.
sourcepub fn iter(&self) -> TensorIterator<'_, T, S, D> ⓘ
pub fn iter(&self) -> TensorIterator<'_, T, S, D> ⓘ
Returns an iterator over copies of the data in this TensorView.
sourcepub 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,
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.
sourcepub 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,
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>,
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§impl<T, S, const D: usize> TensorView<T, S, D>where
T: Clone,
S: TensorMut<T, D>,
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.
sourcepub fn map_mut(&mut self, mapping_function: impl Fn(T) -> T)
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.
sourcepub fn map_mut_with_index(
&mut self,
mapping_function: impl Fn([usize; D], T) -> T
)
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>,
impl<T, S> TensorView<T, S, 1>where
T: Numeric,
for<'a> &'a T: NumericRef<T>,
S: TensorRef<T, 1>,
sourcepub fn scalar_product<S2, I>(&self, rhs: I) -> Twhere
I: Into<TensorView<T, S2, 1>>,
S2: TensorRef<T, 1>,
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>,
impl<T, S> TensorView<T, S, 2>where
T: Numeric,
for<'a> &'a T: NumericRef<T>,
S: TensorRef<T, 2>,
sourcepub fn determinant(&self) -> Option<T>
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
sourcepub fn inverse(&self) -> Option<Tensor<T, 2>>
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
sourcepub fn covariance(&self, feature_dimension: Dimension) -> Tensor<T, 2>
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>,
impl<T, S> TensorView<T, S, 6>where
S: TensorRef<T, 6>,
sourcepub fn select(
&self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 6, { _ }>, { _ }>
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 TensorIndex
es with multiple provided
indexes if you need to reduce dimensionality by more than 1 dimension at a time.
sourcepub fn select_mut(
&mut self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 6, { _ }>, { _ }>
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
sourcepub fn select_owned(
self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 6, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 5>where
S: TensorRef<T, 5>,
sourcepub fn select(
&self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 5, { _ }>, { _ }>
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 TensorIndex
es with multiple provided
indexes if you need to reduce dimensionality by more than 1 dimension at a time.
sourcepub fn select_mut(
&mut self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 5, { _ }>, { _ }>
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
sourcepub fn select_owned(
self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 5, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 4>where
S: TensorRef<T, 4>,
sourcepub fn select(
&self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 4, { _ }>, { _ }>
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 TensorIndex
es with multiple provided
indexes if you need to reduce dimensionality by more than 1 dimension at a time.
sourcepub fn select_mut(
&mut self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 4, { _ }>, { _ }>
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
sourcepub fn select_owned(
self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 4, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 3>where
S: TensorRef<T, 3>,
sourcepub fn select(
&self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 3, { _ }>, { _ }>
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 TensorIndex
es with multiple provided
indexes if you need to reduce dimensionality by more than 1 dimension at a time.
sourcepub fn select_mut(
&mut self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 3, { _ }>, { _ }>
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
sourcepub fn select_owned(
self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 3, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 2>where
S: TensorRef<T, 2>,
sourcepub fn select(
&self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 2, { _ }>, { _ }>
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 TensorIndex
es with multiple provided
indexes if you need to reduce dimensionality by more than 1 dimension at a time.
sourcepub fn select_mut(
&mut self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 2, { _ }>, { _ }>
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
sourcepub fn select_owned(
self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 2, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 1>where
S: TensorRef<T, 1>,
sourcepub fn select(
&self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &S, 1, { _ }>, { _ }>
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 TensorIndex
es with multiple provided
indexes if you need to reduce dimensionality by more than 1 dimension at a time.
sourcepub fn select_mut(
&mut self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, &mut S, 1, { _ }>, { _ }>
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
sourcepub fn select_owned(
self,
provided_indexes: [(Dimension, usize); 1]
) -> TensorView<T, TensorIndex<T, S, 1, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 0>where
S: TensorRef<T, 0>,
sourcepub fn expand(
&self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 0, { _ }>, { _ }>
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 TensorExpansion
s with multiple provided
indexes if you need to increase dimensionality by more than 1 dimension at a time.
sourcepub fn expand_mut(
&mut self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 0, { _ }>, { _ }>
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
sourcepub fn expand_owned(
self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 0, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 1>where
S: TensorRef<T, 1>,
sourcepub fn expand(
&self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 1, { _ }>, { _ }>
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 TensorExpansion
s with multiple provided
indexes if you need to increase dimensionality by more than 1 dimension at a time.
sourcepub fn expand_mut(
&mut self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 1, { _ }>, { _ }>
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
sourcepub fn expand_owned(
self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 1, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 2>where
S: TensorRef<T, 2>,
sourcepub fn expand(
&self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 2, { _ }>, { _ }>
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 TensorExpansion
s with multiple provided
indexes if you need to increase dimensionality by more than 1 dimension at a time.
sourcepub fn expand_mut(
&mut self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 2, { _ }>, { _ }>
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
sourcepub fn expand_owned(
self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 2, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 3>where
S: TensorRef<T, 3>,
sourcepub fn expand(
&self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 3, { _ }>, { _ }>
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 TensorExpansion
s with multiple provided
indexes if you need to increase dimensionality by more than 1 dimension at a time.
sourcepub fn expand_mut(
&mut self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 3, { _ }>, { _ }>
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
sourcepub fn expand_owned(
self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 3, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 4>where
S: TensorRef<T, 4>,
sourcepub fn expand(
&self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 4, { _ }>, { _ }>
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 TensorExpansion
s with multiple provided
indexes if you need to increase dimensionality by more than 1 dimension at a time.
sourcepub fn expand_mut(
&mut self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 4, { _ }>, { _ }>
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
sourcepub fn expand_owned(
self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 4, { _ }>, { _ }>
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>,
impl<T, S> TensorView<T, S, 5>where
S: TensorRef<T, 5>,
sourcepub fn expand(
&self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &S, 5, { _ }>, { _ }>
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 TensorExpansion
s with multiple provided
indexes if you need to increase dimensionality by more than 1 dimension at a time.
sourcepub fn expand_mut(
&mut self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, &mut S, 5, { _ }>, { _ }>
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
sourcepub fn expand_owned(
self,
extra_dimension_names: [(usize, Dimension); 1]
) -> TensorView<T, TensorExpansion<T, S, 5, { _ }>, { _ }>
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
source§impl<T, S, const D: usize> Debug for TensorView<T, S, D>where
T: Debug,
S: Debug + TensorRef<T, D>,
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§impl<T, S, const D: usize> Display for TensorView<T, S, D>where
T: Display,
S: TensorRef<T, D>,
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§impl<'a, T, const D: usize> From<&'a Tensor<T, D>> for TensorView<T, &'a Tensor<T, D>, D>
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§impl<'a, T, S, const D: usize> From<&'a TensorView<T, S, D>> for TensorView<T, &'a S, D>where
S: TensorRef<T, D>,
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>
fn from(tensor_view: &TensorView<T, S, D>) -> TensorView<T, &S, D>
source§impl<'a, T, const D: usize> From<&'a mut Tensor<T, D>> for TensorView<T, &'a mut Tensor<T, D>, D>
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§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>,
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>
fn from(tensor_view: &mut TensorView<T, S, D>) -> TensorView<T, &mut S, D>
source§impl<T, const D: usize> From<Tensor<T, D>> for TensorView<T, Tensor<T, D>, D>
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§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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
source§impl<T, S, const D: usize> PartialEq<Tensor<T, D>> for TensorView<T, S, D>where
T: PartialEq,
S: TensorRef<T, D>,
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§impl<T, S, const D: usize> PartialEq<TensorView<T, S, D>> for Tensor<T, D>where
T: PartialEq,
S: TensorRef<T, D>,
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
fn eq(&self, other: &TensorView<T, S, D>) -> bool
self
and other
values to be equal, and is used
by ==
.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>,
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
fn eq(&self, other: &TensorView<T, S2, D>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T, S, const D: usize> Similar<Tensor<T, D>> for TensorView<T, S, D>where
T: PartialEq,
S: TensorRef<T, D>,
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§impl<T, S, const D: usize> Similar<TensorView<T, S, D>> for Tensor<T, D>where
T: PartialEq,
S: TensorRef<T, D>,
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§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>,
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§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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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
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>,
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