Skip to main content

SparseTensor

Struct SparseTensor 

Source
pub struct SparseTensor {
    pub rows: usize,
    pub cols: usize,
    pub col_ptrs: Vec<usize>,
    pub row_indices: Vec<usize>,
    /* private fields */
}

Fields§

§rows: usize§cols: usize§col_ptrs: Vec<usize>

Column pointers into row_indices and the numeric value storage; length is cols + 1.

§row_indices: Vec<usize>

Zero-based row indices, sorted within each column.

Implementations§

Source§

impl SparseTensor

Source

pub fn new( rows: usize, cols: usize, col_ptrs: Vec<usize>, row_indices: Vec<usize>, values: Vec<f64>, ) -> Result<Self, String>

Source

pub fn new_f32( rows: usize, cols: usize, col_ptrs: Vec<usize>, row_indices: Vec<usize>, values: Vec<f32>, ) -> Result<Self, String>

Constructs a sparse matrix backed by native single-precision values.

Source

pub fn new_integer( rows: usize, cols: usize, col_ptrs: Vec<usize>, row_indices: Vec<usize>, integer_data: IntegerStorage, ) -> Result<Self, String>

Constructs a sparse matrix backed by an exact integer value buffer.

Source

pub fn new_logical( rows: usize, cols: usize, col_ptrs: Vec<usize>, row_indices: Vec<usize>, ) -> Result<Self, String>

Constructs a sparse logical matrix whose CSC pattern is the complete authoritative set of true elements.

Source

pub fn zeros(rows: usize, cols: usize) -> Self

Source

pub fn zeros_f32(rows: usize, cols: usize) -> Self

Creates an all-zero sparse matrix retaining the single class.

Source

pub fn zeros_logical(rows: usize, cols: usize) -> Self

Creates an all-false sparse logical matrix.

Source

pub fn zeros_with_integer_storage( rows: usize, cols: usize, storage: &IntegerStorage, ) -> Self

Creates an all-zero sparse matrix retaining an exact integer class.

Source

pub fn new_integer_like( rows: usize, cols: usize, col_ptrs: Vec<usize>, row_indices: Vec<usize>, values: Vec<IntValue>, prototype: &IntegerStorage, ) -> Result<Self, String>

Creates a typed sparse matrix using the class of prototype.

Source

pub fn nnz(&self) -> usize

Source

pub fn shape(&self) -> Vec<usize>

Source

pub fn to_dense(&self) -> Result<Tensor, String>

Source

pub fn to_dense_logical(&self) -> Result<LogicalArray, String>

Source

pub fn get(&self, row: usize, col: usize) -> Option<f64>

Source

pub fn logical_at(&self, row: usize, col: usize) -> Option<bool>

Source

pub fn integer_at(&self, row: usize, col: usize) -> Option<IntValue>

Returns an exact stored integer value when this sparse matrix is typed.

Source

pub fn integer_storage(&self) -> Option<&IntegerStorage>

Source

pub fn as_f64_slice(&self) -> Option<&[f64]>

Borrows stored nonzero values when this sparse matrix is double.

Source

pub fn as_f32_slice(&self) -> Option<&[f32]>

Borrows stored nonzero values when this sparse matrix is single.

Source

pub fn is_logical(&self) -> bool

Source

pub fn value_byte_size(&self) -> usize

Source

pub fn materialize_f64(&self) -> Vec<f64>

Explicitly materializes stored nonzero values in the f64 computation domain.

Integer values outside the exact binary64 range may lose precision.

Source

pub fn numeric_value_at(&self, index: usize) -> Option<NumericScalar>

Reads one stored nonzero value without routing integers through floating point.

Source

pub fn numeric_dtype(&self) -> Option<NumericDType>

Source

pub fn with_updated_linear_values( &self, updates: &[(usize, f64)], ) -> Result<Self, String>

Applies floating updates in one CSC merge. Repeated indices use the final assignment value and zeros are elided without densifying.

Source

pub fn with_updated_f32_linear_values( &self, updates: &[(usize, f32)], ) -> Result<Self, String>

Applies native single-precision updates in one CSC merge.

Source

pub fn with_updated_integer_linear_values( &self, updates: &[(usize, IntValue)], ) -> Result<Self, String>

Applies exact integer updates in one CSC merge. Values must already be in this sparse matrix’s class; coercion belongs to the VM layer.

Source

pub fn with_updated_logical_linear_values( &self, updates: &[(usize, bool)], ) -> Result<Self, String>

Source

pub fn with_updated_value( &self, row: usize, col: usize, value: f64, ) -> Result<Self, String>

Source

pub fn with_updated_f32_value( &self, row: usize, col: usize, value: f32, ) -> Result<Self, String>

Source

pub fn with_updated_integer_value( &self, row: usize, col: usize, value: IntValue, ) -> Result<Self, String>

Source

pub fn with_updated_logical_value( &self, row: usize, col: usize, value: bool, ) -> Result<Self, String>

Source

pub fn with_expanded_shape( &self, rows: usize, cols: usize, ) -> Result<Self, String>

Expands sparse dimensions without materializing implicit zero entries.

Source

pub fn with_deleted_rows(&self, rows: &[usize]) -> Result<Self, String>

Deletes complete sparse matrix rows without materializing dense storage.

Source

pub fn with_deleted_columns(&self, columns: &[usize]) -> Result<Self, String>

Deletes complete sparse matrix columns without materializing dense storage.

Source

pub fn class_name(&self) -> &'static str

Trait Implementations§

Source§

impl Clone for SparseTensor

Source§

fn clone(&self) -> SparseTensor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SparseTensor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SparseTensor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SparseTensor

Source§

fn eq(&self, other: &SparseTensor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SparseTensor

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.