pub struct TensorViewMut<'a> { /* private fields */ }Expand description
A mutable zero-copy view of a multi-dimensional f64 tensor.
This struct is Send but NOT Sync. It is Send because &mut [f64] is Send.
It is not Sync because &mut [f64] is not Sync.
Implementations§
Source§impl<'a> TensorViewMut<'a>
impl<'a> TensorViewMut<'a>
Sourcepub fn new(data: &'a mut [f64], shape: Shape, storage_offset: usize) -> Self
pub fn new(data: &'a mut [f64], shape: Shape, storage_offset: usize) -> Self
Constructs a new mutable TensorViewMut.
§Panics
Panics if the buffer is smaller than the maximum addressable flat index.
Sourcepub fn new_default(data: &'a mut [f64], shape: Shape) -> Self
pub fn new_default(data: &'a mut [f64], shape: Shape) -> Self
Constructs a new TensorViewMut with default storage_offset of 0.
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Returns true if this view has a contiguous layout.
Sourcepub fn get_mut(&mut self, idx: &[usize]) -> Option<&mut f64>
pub fn get_mut(&mut self, idx: &[usize]) -> Option<&mut f64>
Returns the element at the multi-dimensional index mutably.
Returns None if any index component is out of bounds.
Sourcepub unsafe fn get_unchecked_mut(&mut self, idx: &[usize]) -> &mut f64
pub unsafe fn get_unchecked_mut(&mut self, idx: &[usize]) -> &mut f64
Returns a mutable reference to the element at the multi-dimensional index without bounds checking.
§Safety
The caller must guarantee that idx is a valid multi-dimensional index
for this tensor view.
Sourcepub fn set(&mut self, idx: &[usize], val: f64) -> bool
pub fn set(&mut self, idx: &[usize], val: f64) -> bool
Sets the element at the multi-dimensional index.
Returns false if the index is out-of-bounds.
Sourcepub const fn as_raw_slice(&self) -> &[f64]
pub const fn as_raw_slice(&self) -> &[f64]
Returns the flat backing buffer immutably (the entire underlying memory).
Use as_slice() to get the view’s active segment.
Sourcepub const fn as_raw_slice_mut(&mut self) -> &mut [f64]
pub const fn as_raw_slice_mut(&mut self) -> &mut [f64]
Returns the flat backing buffer mutably (the entire underlying memory).
Use as_slice_mut() to get the view’s active segment.
Sourcepub fn as_slice_mut(&mut self) -> &mut [f64]
pub fn as_slice_mut(&mut self) -> &mut [f64]
Sourcepub fn as_view(&self) -> TensorView<'_>
pub fn as_view(&self) -> TensorView<'_>
Returns a read-only view of this mutable tensor.