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>
impl<C: Memorable, const D: usize> SymSqTensor<C, D>
Sourcepub fn new(data: MemoryBuffer<C>, dims: [usize; D], strides: [usize; D]) -> Self
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.
Sourcepub fn zeros(dims: [usize; D]) -> Self
pub fn zeros(dims: [usize; D]) -> Self
Creates a new symmetric square tensor filled with zeros.
Sourcepub fn num_elements(&self) -> usize
pub fn num_elements(&self) -> usize
Returns the total number of elements in the tensor.
Sourcepub fn as_ptr_mut(&mut self) -> *mut C
pub fn as_ptr_mut(&mut self) -> *mut C
Returns a mutable raw pointer to the tensor’s data.
Sourcepub fn as_ref(&self) -> SymSqTensorRef<'_, C, D>
pub fn as_ref(&self) -> SymSqTensorRef<'_, C, D>
Returns an immutable reference to the tensor.
Sourcepub fn as_mut(&mut self) -> SymSqTensorMut<'_, C, D>
pub fn as_mut(&mut self) -> SymSqTensorMut<'_, C, D>
Returns a mutable reference to the tensor.
Sourcepub fn get(&self, indices: &[usize; D]) -> &C
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.
Sourcepub fn get_mut(&mut self, indices: &[usize; D]) -> &mut C
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.
Sourcepub unsafe fn get_unchecked(&self, indices: &[usize; D]) -> &C
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.
Sourcepub unsafe fn get_mut_unchecked(&mut self, indices: &[usize; D]) -> &mut C
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§impl<C: Memorable> SymSqTensor<C, 5>
impl<C: Memorable> SymSqTensor<C, 5>
Sourcepub fn subtensor_ref(&self, m1: usize, m2: usize) -> TensorRef<'_, C, 3>
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.
Sourcepub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> TensorMut<'_, C, 3>
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§impl<C: Memorable> SymSqTensor<C, 4>
impl<C: Memorable> SymSqTensor<C, 4>
Sourcepub fn subtensor_ref(&self, m1: usize, m2: usize) -> MatRef<'_, C>
pub fn subtensor_ref(&self, m1: usize, m2: usize) -> MatRef<'_, C>
Returns an immutable matrix reference to the subtensor at the given indices.
Sourcepub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> MatMut<'_, C>
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§impl<C: Memorable> SymSqTensor<C, 3>
impl<C: Memorable> SymSqTensor<C, 3>
Sourcepub fn subtensor_ref(&self, m1: usize, m2: usize) -> RowRef<'_, C>
pub fn subtensor_ref(&self, m1: usize, m2: usize) -> RowRef<'_, C>
Returns an immutable row reference to the subtensor at the given indices.
Sourcepub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> RowMut<'_, C>
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§impl<C: Memorable> SymSqTensor<C, 2>
impl<C: Memorable> SymSqTensor<C, 2>
Sourcepub fn subtensor_ref(&self, m1: usize, m2: usize) -> &C
pub fn subtensor_ref(&self, m1: usize, m2: usize) -> &C
Returns an immutable reference to the element at the given indices.
Sourcepub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> &mut C
pub fn subtensor_mut(&mut self, m1: usize, m2: usize) -> &mut C
Returns a mutable reference to the element at the given indices.