pub trait Tensor<S, D>{
type Scalar;
type Container<U: RawData, V: Dimension>;
Show 21 methods
// Required methods
fn from_shape_with_fn<Sh, F>(shape: Sh, f: F) -> Self::Container<S, D>
where Sh: ShapeBuilder<Dim = D>,
F: FnMut(D::Pattern) -> Self::Scalar,
Self: Sized;
fn from_shape_with_value<Sh>(
shape: Sh,
value: Self::Scalar,
) -> Self::Container<S, D>
where Sh: ShapeBuilder<Dim = D>,
Self: Sized;
fn data(&self) -> &Self::Container<S, D>;
fn data_mut(&mut self) -> &mut Self::Container<S, D>;
fn dim(&self) -> D::Pattern;
fn raw_dim(&self) -> D;
fn shape(&self) -> &[usize];
fn apply<F, B>(&self, f: F) -> Self::Container<OwnedRepr<B>, D>
where F: FnMut(Self::Scalar) -> B;
fn apply_mut<F>(&mut self, f: F)
where S: DataMut,
F: FnMut(Self::Scalar) -> Self::Scalar;
fn axis_iter(&self, axis: usize) -> AxisIter<'_, Self::Scalar, D::Smaller>
where D: RemoveAxis;
fn iter(&self) -> Iter<'_, Self::Scalar, D>;
fn iter_mut(&mut self) -> IterMut<'_, Self::Scalar, D>
where S: DataMut;
// Provided methods
fn default<Sh>(shape: Sh) -> Self::Container<S, D>
where Sh: ShapeBuilder<Dim = D>,
Self: Sized,
Self::Scalar: Default { ... }
fn ones<Sh>(shape: Sh) -> Self::Container<S, D>
where Sh: ShapeBuilder<Dim = D>,
Self: Sized,
Self::Scalar: Clone + One { ... }
fn zeros<Sh>(shape: Sh) -> Self::Container<S, D>
where Sh: ShapeBuilder<Dim = D>,
Self: Sized,
Self::Scalar: Clone + Zero { ... }
fn set_data(&mut self, data: Self::Container<S, D>) -> &mut Self { ... }
fn mean(&self) -> Self::Scalar
where Self::Scalar: Scalar { ... }
fn sum(&self) -> Self::Scalar
where Self::Scalar: Clone + Sum { ... }
fn pow2(&self) -> Self::Container<OwnedRepr<Self::Scalar>, D>
where Self::Scalar: Scalar { ... }
fn abs(&self) -> Self::Container<OwnedRepr<Self::Scalar>, D>
where Self::Scalar: Signed { ... }
fn neg(&self) -> Self::Container<OwnedRepr<Self::Scalar>, D>
where Self::Scalar: Neg<Output = Self::Scalar> { ... }
}
Required Associated Types§
Required Methods§
Sourcefn from_shape_with_fn<Sh, F>(shape: Sh, f: F) -> Self::Container<S, D>
fn from_shape_with_fn<Sh, F>(shape: Sh, f: F) -> Self::Container<S, D>
Create a new tensor with the given shape and a function to fill it
Sourcefn from_shape_with_value<Sh>(
shape: Sh,
value: Self::Scalar,
) -> Self::Container<S, D>where
Sh: ShapeBuilder<Dim = D>,
Self: Sized,
fn from_shape_with_value<Sh>(
shape: Sh,
value: Self::Scalar,
) -> Self::Container<S, D>where
Sh: ShapeBuilder<Dim = D>,
Self: Sized,
Create a new tensor with the given shape and value
Sourcefn data_mut(&mut self) -> &mut Self::Container<S, D>
fn data_mut(&mut self) -> &mut Self::Container<S, D>
returns a mutable reference to the data of the object
Sourcefn apply<F, B>(&self, f: F) -> Self::Container<OwnedRepr<B>, D>
fn apply<F, B>(&self, f: F) -> Self::Container<OwnedRepr<B>, D>
returns a new tensor with the same shape as the object and the given function applied to each element
Sourcefn apply_mut<F>(&mut self, f: F)
fn apply_mut<F>(&mut self, f: F)
returns a new tensor with the same shape as the object and the given function applied
fn axis_iter(&self, axis: usize) -> AxisIter<'_, Self::Scalar, D::Smaller>where
D: RemoveAxis,
fn iter(&self) -> Iter<'_, Self::Scalar, D>
fn iter_mut(&mut self) -> IterMut<'_, Self::Scalar, D>where
S: DataMut,
Provided Methods§
Sourcefn default<Sh>(shape: Sh) -> Self::Container<S, D>
fn default<Sh>(shape: Sh) -> Self::Container<S, D>
Create a new tensor with the given shape and all values set to their default
Sourcefn ones<Sh>(shape: Sh) -> Self::Container<S, D>
fn ones<Sh>(shape: Sh) -> Self::Container<S, D>
create a new tensor with the given shape and all values set to one
Sourcefn zeros<Sh>(shape: Sh) -> Self::Container<S, D>
fn zeros<Sh>(shape: Sh) -> Self::Container<S, D>
create a new tensor with the given shape and all values set to zero
fn mean(&self) -> Self::Scalar
fn sum(&self) -> Self::Scalar
fn pow2(&self) -> Self::Container<OwnedRepr<Self::Scalar>, D>
fn abs(&self) -> Self::Container<OwnedRepr<Self::Scalar>, D>
fn neg(&self) -> Self::Container<OwnedRepr<Self::Scalar>, D>
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.