pub struct DenseTensor {
pub shape: Vec<usize>,
pub data: Vec<f64>,
}Expand description
A dense tensor of arbitrary rank stored in row-major (C-order) layout.
The shape is given as a Vecusize` and the flat data length must equal
the product of all dimensions.
Fields§
§shape: Vec<usize>Shape of the tensor, e.g. [2, 3, 4] for a 2×3×4 tensor.
data: Vec<f64>Flat row-major storage.
Implementations§
Source§impl DenseTensor
impl DenseTensor
Sourcepub fn flat_index(&self, idx: &[usize]) -> usize
pub fn flat_index(&self, idx: &[usize]) -> usize
Flat index from a multi-index.
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Frobenius norm: sqrt of sum of squared elements.
Source§impl DenseTensor
impl DenseTensor
Sourcepub fn clone_tensor(&self) -> DenseTensor
pub fn clone_tensor(&self) -> DenseTensor
Clone helper (needed since derive(Clone) isn’t on the struct).
Sourcepub fn scale(&self, s: f64) -> DenseTensor
pub fn scale(&self, s: f64) -> DenseTensor
Scale all elements by a scalar.
Sourcepub fn add_tensor(&self, other: &DenseTensor) -> DenseTensor
pub fn add_tensor(&self, other: &DenseTensor) -> DenseTensor
Element-wise addition (shapes must match).
Sourcepub fn sub_tensor(&self, other: &DenseTensor) -> DenseTensor
pub fn sub_tensor(&self, other: &DenseTensor) -> DenseTensor
Element-wise subtraction (shapes must match).
Trait Implementations§
Source§impl Clone for DenseTensor
impl Clone for DenseTensor
Source§fn clone(&self) -> DenseTensor
fn clone(&self) -> DenseTensor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DenseTensor
impl RefUnwindSafe for DenseTensor
impl Send for DenseTensor
impl Sync for DenseTensor
impl Unpin for DenseTensor
impl UnsafeUnpin for DenseTensor
impl UnwindSafe for DenseTensor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.