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>) -> TensorBase<S, D>
pub const fn from_ndarray(store: ArrayBase<S, D>) -> TensorBase<S, D>
create a new TensorBase
from the given store.
Sourcepub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> TensorBase<S, D>
pub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> TensorBase<S, D>
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) -> TensorBase<S, D>
pub fn from_fn_with_shape<Sh, F>(shape: Sh, f: F) -> TensorBase<S, D>
create a new TensorBase
from the given shape and a function to fill it.
Sourcepub fn ones<Sh>(shape: Sh) -> TensorBase<S, D>
pub fn ones<Sh>(shape: Sh) -> TensorBase<S, D>
returns a new instance of the TensorBase
with the given shape and values initialized
to zero.
Sourcepub fn zeros<Sh>(shape: Sh) -> TensorBase<S, D>
pub fn zeros<Sh>(shape: Sh) -> TensorBase<S, D>
returns a new instance of the TensorBase
with the given shape and values initialized
to zero.
Sourcepub fn dim(&self) -> <D as Dimension>::Pattern
pub fn dim(&self) -> <D as Dimension>::Pattern
returns the dimension of the tensor as a Pattern
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>
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub fn to_owned(&self) -> TensorBase<OwnedRepr<A>, D>
pub fn to_owned(&self) -> TensorBase<OwnedRepr<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.
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub fn random<Sh, Ds>(shape: Sh, distr: Ds) -> TensorBase<S, D>where
Ds: Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
pub fn random<Sh, Ds>(shape: Sh, distr: Ds) -> TensorBase<S, D>where
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,
) -> TensorBase<S, D>
pub fn random_using<Sh, Ds, R>( shape: Sh, distr: Ds, rng: &mut R, ) -> TensorBase<S, D>
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) -> TensorBase<S, D>
pub fn random_with<Dst, Sh>(shape: Sh, distr: Dst) -> TensorBase<S, D>
Randomly initializes a tensor with the given shape using the provided distribution
Trait Implementations§
Source§impl<A, S, D> Apply<A> for TensorBase<S, D>
impl<A, S, D> Apply<A> for TensorBase<S, D>
Source§impl<A, S, D> Clone for TensorBase<S, D>
impl<A, S, D> Clone for TensorBase<S, D>
Source§fn clone(&self) -> TensorBase<S, D>
fn clone(&self) -> TensorBase<S, D>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<A, S, D> Debug for TensorBase<S, D>
impl<A, S, D> Debug for TensorBase<S, D>
Source§impl<'a, A, S, D> Deserialize<'a> for TensorBase<S, D>
impl<'a, A, S, D> Deserialize<'a> for TensorBase<S, D>
Source§fn deserialize<De>(
deserializer: De,
) -> Result<TensorBase<S, D>, <De as Deserializer<'a>>::Error>where
De: Deserializer<'a>,
fn deserialize<De>(
deserializer: De,
) -> Result<TensorBase<S, D>, <De as Deserializer<'a>>::Error>where
De: Deserializer<'a>,
Source§impl<A, S, D> Display for TensorBase<S, D>
impl<A, S, D> Display for TensorBase<S, D>
Source§impl<A, S, D, X, S2, D2> Dot<X> for TensorBase<S, D>
impl<A, S, D, X, S2, D2> Dot<X> for TensorBase<S, D>
Source§impl<A, S, D> PartialEq<&ArrayBase<S, D>> for TensorBase<S, D>
impl<A, S, D> PartialEq<&ArrayBase<S, D>> for TensorBase<S, D>
Source§impl<A, S, D> PartialEq<&mut ArrayBase<S, D>> for TensorBase<S, D>
impl<A, S, D> PartialEq<&mut ArrayBase<S, D>> for TensorBase<S, D>
Source§impl<A, S, D> PartialEq<ArrayBase<S, D>> for TensorBase<S, D>
impl<A, S, D> PartialEq<ArrayBase<S, D>> for TensorBase<S, D>
Source§impl<A, S, D> PartialEq for TensorBase<S, D>
impl<A, S, D> PartialEq for TensorBase<S, D>
Source§impl<A, S, D> Serialize for TensorBase<S, D>
impl<A, S, D> Serialize for TensorBase<S, D>
Source§fn serialize<Ser>(
&self,
serializer: Ser,
) -> Result<<Ser as Serializer>::Ok, <Ser as Serializer>::Error>where
Ser: Serializer,
fn serialize<Ser>(
&self,
serializer: Ser,
) -> Result<<Ser as Serializer>::Ok, <Ser as Serializer>::Error>where
Ser: Serializer,
Source§impl<'a, A, S, D> Transpose for &'a TensorBase<S, D>
impl<'a, A, S, D> Transpose for &'a TensorBase<S, D>
impl<A, S, D> Copy for TensorBase<S, D>
Auto Trait Implementations§
impl<S, D> Freeze for TensorBase<S, D>
impl<S, D> RefUnwindSafe for TensorBase<S, D>
impl<S, D> Send for TensorBase<S, D>
impl<S, D> Sync for TensorBase<S, D>
impl<S, D> Unpin for TensorBase<S, D>
impl<S, D> UnwindSafe for TensorBase<S, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CallInPlace<T> for Twhere
T: CallInto<T>,
impl<T> CallInPlace<T> for Twhere
T: CallInto<T>,
Source§fn call_inplace<F>(&mut self, f: F) -> <T as CallInto<T>>::Output
fn call_inplace<F>(&mut self, f: F) -> <T as CallInto<T>>::Output
call_on_mut
method allows an object to be passed onto a function that takes a mutable reference
to the object. This is useful for cases where you want to perform an operation on
an object and mutate it in the process.Source§impl<T> CallInto<T> for T
impl<T> CallInto<T> for T
Source§impl<T> CallOn<T> for Twhere
T: CallInto<T>,
impl<T> CallOn<T> for Twhere
T: CallInto<T>,
Source§fn call_on<F>(&self, f: F) -> <T as CallInto<T>>::Output
fn call_on<F>(&self, f: F) -> <T as CallInto<T>>::Output
call_on
method allows an object to be passed onto a function that takes a reference
to the object. This is useful for cases where you want to perform an operation on
an object without needing to extract it from a container or context.