Tensor

Struct Tensor 

Source
pub struct Tensor<T>(pub Vec<T>);
Expand description

Struct to store a tensor of elements of the same type.

Tuple Fields§

§0: Vec<T>

Implementations§

Source§

impl<T> Tensor<T>

Source

pub fn first(&self) -> Option<&T>

Returns the first element in this tensor.

Source

pub fn get(&self, index: usize) -> Option<&T>

Returns the element given by the index.

Source

pub fn len(&self) -> usize

Returns the number of elements in this tensor.

Source

pub fn is_empty(&self) -> bool

Returns true if this tensor contains no elements.

Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the elements of this tensor.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Returns a mutable iterator over the elements of this tensor.

Source

pub fn map<U, F>(&self, f: F) -> Tensor<U>
where F: FnMut(&T) -> U,

Applies the given function to each element in this tensor, returning a new tensor with the results.

Source

pub fn zip<U, V, F>(&self, other: &Tensor<U>, f: F) -> Tensor<V>
where F: FnMut(&T, &U) -> V,

zips two tensors together, applying the given function to each pair of elements.

Source§

impl<T> Tensor<T>
where T: Clone,

Source

pub fn get_cloned(&self, index: usize) -> Option<T>

Returns a cloned copy of the element given by the index.

Source§

impl<T, E> Tensor<Result<T, E>>

Source

pub fn collect(self) -> Result<Tensor<T>, E>

Collects the results in this tensor, returning the successful values.

Trait Implementations§

Source§

impl<T: Clone> Clone for Tensor<T>

Source§

fn clone(&self) -> Tensor<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Tensor<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> FromChunk for Tensor<T>
where T: FromBytes<State = Context>,

Source§

fn from_chunk(context: &Context, chunks: &[Vec<u8>]) -> Result<Self>

Deserialize an object from the given bytes using the given context.
Source§

impl<'a, T> IntoIterator for &'a Tensor<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for Tensor<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> ToChunk for Tensor<T>
where T: ToBytes,

Source§

fn to_chunk(&self) -> Result<Vec<Vec<u8>>>

Returns the object as a byte array.

Auto Trait Implementations§

§

impl<T> Freeze for Tensor<T>

§

impl<T> RefUnwindSafe for Tensor<T>
where T: RefUnwindSafe,

§

impl<T> Send for Tensor<T>
where T: Send,

§

impl<T> Sync for Tensor<T>
where T: Sync,

§

impl<T> Unpin for Tensor<T>
where T: Unpin,

§

impl<T> UnwindSafe for Tensor<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.