Skip to main content

Tensor

Struct Tensor 

Source
pub struct Tensor<const N: usize, const R: usize, I, S> { /* private fields */ }
Expand description

Basic tensor object. Depends on dimension (N), rank (R), Symmetries (I) and storage array (S).

Implementations§

Source§

impl<const N: usize, const R: usize, I, S> Tensor<N, R, I, S>

Source

pub fn dim() -> usize

Retrieves the dimension of the tensor.

Source

pub fn rank() -> usize

Retrieves the rank of the tensor.

Source§

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageOwned + Default> Tensor<N, R, I, S>

Source

pub fn new() -> Self

Constructs a new tensor with undefined internal values.

Source

pub fn from_fn(f: impl Fn([usize; R]) -> f64) -> Self

Constructs a new tensor by repeatidly calling a function on each index.

Source

pub fn splat(v: f64) -> Self

Constructs a tensor with all components initialized to v.

Source

pub fn zeros() -> Self

Constructs a tensor initialized with all components inititialized to zero.

Source

pub fn from_eq<const C: usize>( f: impl Fn([usize; R], [usize; C]) -> f64, ) -> Self

Constructs a tensor from a tensorial expression.

Source§

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageMut> Tensor<N, R, I, S>

Source

pub fn fill(&mut self, v: f64)

Sets all free components of the tensor to v.

Source

pub fn fill_from_fn(&mut self, f: impl Fn([usize; R]) -> f64)

Sets values of components of the tensor be invoking the given function.

Source§

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageRef> Tensor<N, R, I, S>

Source

pub fn get(&self, index: [usize; R]) -> &f64

Retrieves the component at the given index of the tensor.

Source§

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageMut> Tensor<N, R, I, S>

Source

pub fn get_mut(&mut self, index: [usize; R]) -> &mut f64

Retrieves a mutable reference to the degree of freedom corresponding to the given index of the tensor.

Trait Implementations§

Source§

impl<const N: usize, const R: usize, I, S: Clone> Clone for Tensor<N, R, I, S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const N: usize, const R: usize, I, S: Copy> Copy for Tensor<N, R, I, S>

Source§

impl<const N: usize, const R: usize, I, S: Debug> Debug for Tensor<N, R, I, S>

Source§

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

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

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageOwned + Default> Default for Tensor<N, R, I, S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageRef> From<S> for Tensor<N, R, I, S>

Source§

fn from(value: S) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageRef> Index<[usize; R]> for Tensor<N, R, I, S>

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, index: [usize; R]) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<const N: usize, const R: usize, I: TensorIndex<N, R>, S: TensorStorageMut> IndexMut<[usize; R]> for Tensor<N, R, I, S>

Source§

fn index_mut(&mut self, index: [usize; R]) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<const N: usize, const R: usize, I, S> Freeze for Tensor<N, R, I, S>
where S: Freeze, PhantomData<I>: Freeze,

§

impl<const N: usize, const R: usize, I, S> RefUnwindSafe for Tensor<N, R, I, S>

§

impl<const N: usize, const R: usize, I, S> Send for Tensor<N, R, I, S>
where S: Send, PhantomData<I>: Send,

§

impl<const N: usize, const R: usize, I, S> Sync for Tensor<N, R, I, S>
where S: Sync, PhantomData<I>: Sync,

§

impl<const N: usize, const R: usize, I, S> Unpin for Tensor<N, R, I, S>
where S: Unpin, PhantomData<I>: Unpin,

§

impl<const N: usize, const R: usize, I, S> UnsafeUnpin for Tensor<N, R, I, S>

§

impl<const N: usize, const R: usize, I, S> UnwindSafe for Tensor<N, R, I, S>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.