Expression

Trait Expression 

Source
pub trait Expression: IntoIterator {
    type Shape: Shape;

    const IS_REPEATABLE: bool;
Show 17 methods // Required method fn shape(&self) -> &Self::Shape; // Provided methods fn cloned<'a, T: 'a + Clone>(self) -> Cloned<Self> where Self: Expression<Item = &'a T> + Sized { ... } fn copied<'a, T: 'a + Copy>(self) -> Copied<Self> where Self: Expression<Item = &'a T> + Sized { ... } fn dim(&self, index: usize) -> usize { ... } fn enumerate(self) -> Enumerate<Self> where Self: Sized { ... } fn eq<I: IntoExpression>(self, other: I) -> bool where Self: Expression<Item: PartialEq<I::Item>> + Sized { ... } fn eq_by<I: IntoExpression, F>(self, other: I, eq: F) -> bool where Self: Sized, F: FnMut(Self::Item, I::Item) -> bool { ... } fn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item> where Self: Sized { ... } fn eval_into<S: Shape, A: Allocator>( self, tensor: &mut Tensor<Self::Item, S, A>, ) -> &mut Tensor<Self::Item, S, A> where Self: Sized { ... } fn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> T where Self: Sized { ... } fn for_each<F: FnMut(Self::Item)>(self, f: F) where Self: Sized { ... } fn is_empty(&self) -> bool { ... } fn len(&self) -> usize { ... } fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F> where Self: Sized { ... } fn ne<I: IntoExpression>(self, other: I) -> bool where Self: Expression<Item: PartialEq<I::Item>> + Sized { ... } fn rank(&self) -> usize { ... } fn zip<I: IntoExpression>(self, other: I) -> Zip<Self, I::IntoExpr> where Self: Sized { ... }
}
Expand description

Expression trait, for multidimensional iteration.

Required Associated Constants§

Source

const IS_REPEATABLE: bool

True if the expression can be restarted from the beginning after the last element.

Required Associated Types§

Source

type Shape: Shape

Array shape type.

Required Methods§

Source

fn shape(&self) -> &Self::Shape

Returns the array shape.

Provided Methods§

Source

fn cloned<'a, T: 'a + Clone>(self) -> Cloned<Self>
where Self: Expression<Item = &'a T> + Sized,

Creates an expression which clones all of its elements.

Source

fn copied<'a, T: 'a + Copy>(self) -> Copied<Self>
where Self: Expression<Item = &'a T> + Sized,

Creates an expression which copies all of its elements.

Source

fn dim(&self, index: usize) -> usize

Returns the number of elements in the specified dimension.

§Panics

Panics if the dimension is out of bounds.

Source

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Creates an expression which gives tuples of the current count and the element.

Source

fn eq<I: IntoExpression>(self, other: I) -> bool
where Self: Expression<Item: PartialEq<I::Item>> + Sized,

Determines if the elements of the expression are equal to those of another.

Source

fn eq_by<I: IntoExpression, F>(self, other: I, eq: F) -> bool
where Self: Sized, F: FnMut(Self::Item, I::Item) -> bool,

Determines if the elements of the expression are equal to those of another with respect to the specified equality function.

Source

fn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item>
where Self: Sized,

Evaluates the expression into a new array.

The resulting type is Array if the shape has constant-sized dimensions, or otherwise Tensor. If the shape type is generic, FromExpression::from_expr can be used to evaluate the expression into a specific array type.

Source

fn eval_into<S: Shape, A: Allocator>( self, tensor: &mut Tensor<Self::Item, S, A>, ) -> &mut Tensor<Self::Item, S, A>
where Self: Sized,

Evaluates the expression with broadcasting and appends to the given array along the first dimension.

If the array is empty, it is reshaped to match the shape of the expression.

§Panics

Panics if the inner dimensions do not match, if the rank is not the same and at least 1, or if the first dimension is not dynamically-sized.

Source

fn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> T
where Self: Sized,

Folds all elements into an accumulator by applying an operation, and returns the result.

Source

fn for_each<F: FnMut(Self::Item)>(self, f: F)
where Self: Sized,

Calls a closure on each element of the expression.

Source

fn is_empty(&self) -> bool

Returns true if the array contains no elements.

Source

fn len(&self) -> usize

Returns the number of elements in the array.

Source

fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F>
where Self: Sized,

Creates an expression that calls a closure on each element.

Source

fn ne<I: IntoExpression>(self, other: I) -> bool
where Self: Expression<Item: PartialEq<I::Item>> + Sized,

Determines if the elements of the expression are not equal to those of another.

Source

fn rank(&self) -> usize

Returns the array rank, i.e. the number of dimensions.

Source

fn zip<I: IntoExpression>(self, other: I) -> Zip<Self, I::IntoExpr>
where Self: Sized,

Creates an expression that gives tuples (x, y) of the elements from each expression.

§Panics

Panics if the expressions cannot be broadcast to a common shape.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T, S: Shape, L: Layout> Expression for View<'a, T, S, L>

Source§

impl<'a, T, S: Shape, L: Layout> Expression for ViewMut<'a, T, S, L>

Source§

impl<'a, T, S: Shape, L: Layout, A: Axis> Expression for AxisExpr<'a, T, S, L, A>

Source§

const IS_REPEATABLE: bool = true

Source§

type Shape = (<A as Axis>::Dim<S>,)

Source§

impl<'a, T, S: Shape, L: Layout, A: Axis> Expression for AxisExprMut<'a, T, S, L, A>

Source§

const IS_REPEATABLE: bool = false

Source§

type Shape = (<A as Axis>::Dim<S>,)

Source§

impl<'a, T, S: Shape, L: Layout, A: Axis> Expression for Lanes<'a, T, S, L, A>

Source§

const IS_REPEATABLE: bool = true

Source§

type Shape = <A as Axis>::Remove<S>

Source§

impl<'a, T, S: Shape, L: Layout, A: Axis> Expression for LanesMut<'a, T, S, L, A>

Source§

const IS_REPEATABLE: bool = false

Source§

type Shape = <A as Axis>::Remove<S>

Source§

impl<'a, T: 'a + Clone, E: Expression<Item = &'a T>> Expression for Cloned<E>

Source§

const IS_REPEATABLE: bool = E::IS_REPEATABLE

Source§

type Shape = <E as Expression>::Shape

Source§

impl<'a, T: 'a + Copy, E: Expression<Item = &'a T>> Expression for Copied<E>

Source§

const IS_REPEATABLE: bool = E::IS_REPEATABLE

Source§

type Shape = <E as Expression>::Shape

Source§

impl<B: Buffer> Expression for IntoExpr<B>

Source§

const IS_REPEATABLE: bool = false

Source§

type Shape = <B as Buffer>::Shape

Source§

impl<E: Expression> Expression for Enumerate<E>

Source§

const IS_REPEATABLE: bool = E::IS_REPEATABLE

Source§

type Shape = <E as Expression>::Shape

Source§

impl<S: Shape, R: Shape, A, B> Expression for Zip<A, B>
where A: Expression<Shape = S>, B: Expression<Shape = R>,

Source§

impl<T, E: Expression, F: FnMut(E::Item) -> T> Expression for Map<E, F>

Source§

const IS_REPEATABLE: bool = E::IS_REPEATABLE

Source§

type Shape = <E as Expression>::Shape

Source§

impl<T, F: FnMut() -> T> Expression for FillWith<F>

Source§

impl<T, S: Shape, F: FnMut(&[usize]) -> T> Expression for FromFn<S, F>

Source§

impl<T: Clone> Expression for Fill<T>

Source§

impl<T: Clone, S: Shape> Expression for FromElem<T, S>