Struct metatensor::TensorBlock
source · #[repr(transparent)]pub struct TensorBlock { /* private fields */ }
Expand description
A single block, containing both values & optionally gradients of these values w.r.t. any relevant quantity.
Implementations§
source§impl TensorBlock
impl TensorBlock
sourcepub fn as_ref(&self) -> TensorBlockRef<'_>
pub fn as_ref(&self) -> TensorBlockRef<'_>
Get a non mutable reference to this block
sourcepub fn as_ref_mut(&mut self) -> TensorBlockRefMut<'_>
pub fn as_ref_mut(&mut self) -> TensorBlockRefMut<'_>
Get a non mutable reference to this block
sourcepub fn components(&self) -> Vec<Labels>
pub fn components(&self) -> Vec<Labels>
Get the components for this block
sourcepub fn properties(&self) -> Labels
pub fn properties(&self) -> Labels
Get the properties for this block
sourcepub fn new(
data: impl Array,
samples: &Labels,
components: &[Labels],
properties: &Labels
) -> Result<TensorBlock, Error>
pub fn new( data: impl Array, samples: &Labels, components: &[Labels], properties: &Labels ) -> Result<TensorBlock, Error>
Create a new TensorBlock
containing the given data, described by the
samples
, components
, and properties
labels. The block is
initialized without any gradients.
sourcepub fn add_gradient(
&mut self,
parameter: &str,
gradient: TensorBlock
) -> Result<(), Error>
pub fn add_gradient( &mut self, parameter: &str, gradient: TensorBlock ) -> Result<(), Error>
Add a gradient with respect to parameter
to this block.
The property of the gradient should match the ones of this block. The components of the gradients must contain at least the same entries as the value components, and can prepend other components.
Trait Implementations§
source§impl Debug for TensorBlock
impl Debug for TensorBlock
source§impl Drop for TensorBlock
impl Drop for TensorBlock
impl Send for TensorBlock
impl Sync for TensorBlock
Auto Trait Implementations§
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