pub struct Tensor<T>where
T: TensorElement,{ /* private fields */ }Implementations§
Source§impl<T> Tensor<T>where
T: TensorElement,
impl<T> Tensor<T>where
T: TensorElement,
pub fn new(data: Box<[T]>, shape: Vec<usize>) -> Tensor<T>
pub fn shape(&self) -> &[usize]
pub fn size(&self) -> usize
pub fn flat_to_index(&self, index: usize) -> Vec<usize>
pub fn zeros(shape: &[usize]) -> Tensor<T>
pub fn ones(shape: &[usize]) -> Tensor<T>
pub fn eye(shape: &[usize]) -> Tensor<T>
pub fn diag(tensor: &Tensor<T>) -> Tensor<T>
pub fn scalar(value: T) -> Tensor<T>
pub fn is_scalar(&self) -> bool
pub fn extract_scalar(&self) -> Result<T, Error>
pub fn from_vec(data: Vec<T>, shape: Option<Vec<usize>>) -> Tensor<T>
pub fn to_vec(&self) -> Vec<T>
pub fn reshape(&mut self, new_shape: &[usize]) -> Result<(), Error>
pub fn transpose(&self) -> Tensor<T>
pub fn map(&self, f: impl Fn(T) -> T) -> Tensor<T>
pub fn apply_binary_op( &self, other: &Tensor<T>, f: impl Fn(T, T) -> T, ) -> Option<Tensor<T>>
pub fn reduce(&self, f: impl Fn(T, T) -> T) -> T
pub fn sub_tensor( &self, indices: Vec<Option<usize>>, ) -> Result<Tensor<T>, Error>
pub fn multi_index( &self, indices: Vec<Tensor<usize>>, ) -> Result<Tensor<T>, Error>
pub fn generalized_contraction( &self, other: &Tensor<T>, f: impl Fn(&Tensor<T>) -> T, g: impl Fn(T, T) -> T, ) -> Result<Tensor<T>, Error>
pub fn dot(&self, other: &Tensor<T>) -> Result<Tensor<T>, Error>
Sourcepub fn from_tensors(tensors: &[Tensor<T>]) -> Result<Tensor<T>, Error>
pub fn from_tensors(tensors: &[Tensor<T>]) -> Result<Tensor<T>, Error>
Concatenates a list of tensors of the same shape along a new axis
pub fn to_ndarray2(&self) -> ArrayBase<OwnedRepr<T>, Dim<[usize; 2]>>
pub fn from_ndarray<D>(array: ArrayBase<OwnedRepr<T>, D>) -> Tensor<T>where
D: Dimension,
pub fn to_ndarray(&self) -> ArrayBase<OwnedRepr<T>, Dim<IxDynImpl>>
pub fn range(start: T, end: T) -> Tensor<T>
Trait Implementations§
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>
impl<T> UnwindSafe for Tensor<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more