SymSqTensor

Struct SymSqTensor 

Source
pub struct SymSqTensor<C: Memorable, const D: usize> { /* private fields */ }
Expand description

A tensor with D dimensions, where the first two dimensions are equal and symmetric.

Implementations§

Source§

impl<C: Memorable, const D: usize> SymSqTensor<C, D>

Source

pub fn new(data: MemoryBuffer<C>, dims: [usize; D], strides: [usize; D]) -> Self

Creates a new symmetric square tensor with the given data, dimensions, and strides.

Source

pub fn zeros(dims: [usize; D]) -> Self

Creates a new symmetric square tensor filled with zeros.

Source

pub fn dims(&self) -> &[usize; D]

Returns a reference to the dimensions of the tensor.

Source

pub fn strides(&self) -> &[usize; D]

Returns a reference to the strides of the tensor.

Source

pub fn rank(&self) -> usize

Returns the rank (number of dimensions) of the tensor.

Source

pub fn num_elements(&self) -> usize

Returns the total number of elements in the tensor.

Source

pub fn as_ptr(&self) -> *const C

Returns a raw pointer to the tensor’s data.

Source

pub fn as_ptr_mut(&mut self) -> *mut C

Returns a mutable raw pointer to the tensor’s data.

Source

pub fn as_ref(&self) -> SymSqTensorRef<'_, C, D>

Returns an immutable reference to the tensor.

Source

pub fn as_mut(&mut self) -> SymSqTensorMut<'_, C, D>

Returns a mutable reference to the tensor.

Source

pub fn get(&self, indices: &[usize; D]) -> &C

Returns a reference to an element at the given indices.

§Panics

Panics if the indices are out of bounds.

Source

pub fn get_mut(&mut self, indices: &[usize; D]) -> &mut C

Returns a mutable reference to an element at the given indices.

§Panics

Panics if the indices are out of bounds.

Source

pub unsafe fn get_unchecked(&self, indices: &[usize; D]) -> &C

Returns an immutable reference to an element at the given indices, without performing bounds checks.

§Safety

Calling this method with out-of-bounds indices is undefined behavior.

Source

pub unsafe fn get_mut_unchecked(&mut self, indices: &[usize; D]) -> &mut C

Returns a mutable reference to an element at the given indices, without performing bounds checks.

§Safety

Calling this method with out-of-bounds indices is undefined behavior.

Source

pub unsafe fn ptr_at(&self, indices: &[usize; D]) -> *const C

Returns a raw pointer to an element at the given indices, without performing bounds checks.

§Safety

Calling this method with out-of-bounds indices is undefined behavior.

Source

pub unsafe fn ptr_at_mut(&mut self, indices: &[usize; D]) -> *mut C

Returns a mutable raw pointer to an element at the given indices, without performing bounds checks.

§Safety

Calling this method with out-of-bounds indices is undefined behavior.

Source§

impl<C: Memorable> SymSqTensor<C, 5>

Source

pub fn subtensor_ref(&self, m1: usize, m2: usize) -> TensorRef<'_, C, 3>

Returns an immutable reference to the 3D subtensor at the given matrix indices.

Source

pub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> TensorMut<'_, C, 3>

Returns a mutable reference to the 3D subtensor at the given matrix indices.

Source

pub unsafe fn subtensor_ref_unchecked( &self, m1: usize, m2: usize, ) -> TensorRef<'_, C, 3>

Returns an immutable reference to the 3D subtensor at the given matrix indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Source

pub unsafe fn subtensor_mut_unchecked( &mut self, m1: usize, m2: usize, ) -> TensorMut<'_, C, 3>

Returns a mutable reference to the 3D subtensor at the given matrix indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Source§

impl<C: Memorable> SymSqTensor<C, 4>

Source

pub fn subtensor_ref(&self, m1: usize, m2: usize) -> MatRef<'_, C>

Returns an immutable matrix reference to the subtensor at the given indices.

Source

pub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> MatMut<'_, C>

Returns a mutable matrix reference to the subtensor at the given indices.

Source

pub unsafe fn subtensor_ref_unchecked( &self, m1: usize, m2: usize, ) -> MatRef<'_, C>

Returns an immutable matrix reference to the subtensor at the given indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Source

pub unsafe fn subtensor_mut_unchecked( &mut self, m1: usize, m2: usize, ) -> MatMut<'_, C>

Returns a mutable matrix reference to the subtensor at the given indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Source§

impl<C: Memorable> SymSqTensor<C, 3>

Source

pub fn subtensor_ref(&self, m1: usize, m2: usize) -> RowRef<'_, C>

Returns an immutable row reference to the subtensor at the given indices.

Source

pub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> RowMut<'_, C>

Returns a mutable row reference to the subtensor at the given indices.

Source

pub unsafe fn subtensor_ref_unchecked( &self, m1: usize, m2: usize, ) -> RowRef<'_, C>

Returns an immutable row reference to the subtensor at the given indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Source

pub unsafe fn subtensor_mut_unchecked( &mut self, m1: usize, m2: usize, ) -> RowMut<'_, C>

Returns a mutable row reference to the subtensor at the given indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Source§

impl<C: Memorable> SymSqTensor<C, 2>

Source

pub fn subtensor_ref(&self, m1: usize, m2: usize) -> &C

Returns an immutable reference to the element at the given indices.

Source

pub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> &mut C

Returns a mutable reference to the element at the given indices.

Source

pub unsafe fn subtensor_ref_unchecked(&self, m1: usize, m2: usize) -> &C

Returns an immutable reference to the element at the given indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Source

pub unsafe fn subtensor_mut_unchecked(&mut self, m1: usize, m2: usize) -> &mut C

Returns a mutable reference to the element at the given indices without bounds checking.

§Safety

Caller should ensure that m1 and m2 are in bounds.

Trait Implementations§

Source§

impl<C: Memorable, const D: usize> Index<[usize; D]> for SymSqTensor<C, D>

Source§

type Output = C

The returned type after indexing.
Source§

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

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

impl<C: Memorable, const D: usize> IndexMut<[usize; D]> for SymSqTensor<C, D>

Source§

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

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

Auto Trait Implementations§

§

impl<C, const D: usize> Freeze for SymSqTensor<C, D>

§

impl<C, const D: usize> RefUnwindSafe for SymSqTensor<C, D>
where C: RefUnwindSafe,

§

impl<C, const D: usize> Send for SymSqTensor<C, D>
where C: Send,

§

impl<C, const D: usize> Sync for SymSqTensor<C, D>
where C: Sync,

§

impl<C, const D: usize> Unpin for SymSqTensor<C, D>
where C: Unpin,

§

impl<C, const D: usize> UnwindSafe for SymSqTensor<C, D>

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V