pub struct TensorBase<S, D>{ /* private fields */ }Expand description
the TensorBase struct is the base type for all tensors in the library.
Implementations§
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub const fn from_ndarray(store: ArrayBase<S, D>) -> Self
pub const fn from_ndarray(store: ArrayBase<S, D>) -> Self
create a new TensorBase from the given store.
Sourcepub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> Self
pub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> Self
create a new TensorBase from the given shape and a function to fill it.
Sourcepub fn from_fn_with_shape<Sh, F>(shape: Sh, f: F) -> Self
pub fn from_fn_with_shape<Sh, F>(shape: Sh, f: F) -> Self
create a new TensorBase from the given shape and a function to fill it.
Sourcepub fn ones<Sh>(shape: Sh) -> Self
pub fn ones<Sh>(shape: Sh) -> Self
returns a new instance of the TensorBase with the given shape and values initialized
to zero.
Sourcepub fn zeros<Sh>(shape: Sh) -> Self
pub fn zeros<Sh>(shape: Sh) -> Self
returns a new instance of the TensorBase with the given shape and values initialized
to zero.
Sourcepub fn get<Ix>(&self, index: Ix) -> Option<&A>
pub fn get<Ix>(&self, index: Ix) -> Option<&A>
returns a reference to the element at the given index, if any
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub fn transpose(&self) -> TensorView<'_, A, D>where
S: Data,
pub fn transpose(&self) -> TensorView<'_, A, D>where
S: Data,
transpose the current tensor, returning a new instance with a view of the transposed data.
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub fn to_owned(&self) -> Tensor<A, D>
pub fn to_owned(&self) -> Tensor<A, D>
returns a new tensor with the same shape and values, but with an owned representation of the data.
returns a new tensor with the same shape and values, but with an shared representation of the current data.
Sourcepub fn view(&self) -> TensorView<'_, A, D>where
S: Data,
pub fn view(&self) -> TensorView<'_, A, D>where
S: Data,
returns a new tensor with the same shape and values, but with a view of the current data.
Sourcepub fn view_mut(&mut self) -> TensorViewMut<'_, A, D>where
S: DataMut,
pub fn view_mut(&mut self) -> TensorViewMut<'_, A, D>where
S: DataMut,
returns a new tensor with the same shape and values, but with a mutable view of the current data.
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub fn random<Sh, Ds>(shape: Sh, distr: Ds) -> Selfwhere
Ds: Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
pub fn random<Sh, Ds>(shape: Sh, distr: Ds) -> Selfwhere
Ds: Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
generate a new tensor with the given shape and randomly initialized values
Sourcepub fn random_using<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
pub fn random_using<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
randomly initializes a tensor with the given shape using the provided distribution and random number generator
Sourcepub fn random_with<Dst, Sh>(shape: Sh, distr: Dst) -> Self
pub fn random_with<Dst, Sh>(shape: Sh, distr: Dst) -> Self
Randomly initializes a tensor with the given shape using the provided distribution