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
impl SparseTensor
pub fn new( rows: usize, cols: usize, col_ptrs: Vec<usize>, row_indices: Vec<usize>, values: Vec<f64>, ) -> Result<Self, String>
Sourcepub fn new_f32(
rows: usize,
cols: usize,
col_ptrs: Vec<usize>,
row_indices: Vec<usize>,
values: Vec<f32>,
) -> Result<Self, String>
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.
Sourcepub fn new_integer(
rows: usize,
cols: usize,
col_ptrs: Vec<usize>,
row_indices: Vec<usize>,
integer_data: IntegerStorage,
) -> Result<Self, String>
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.
Sourcepub fn new_logical(
rows: usize,
cols: usize,
col_ptrs: Vec<usize>,
row_indices: Vec<usize>,
) -> Result<Self, String>
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.
pub fn zeros(rows: usize, cols: usize) -> Self
Sourcepub fn zeros_f32(rows: usize, cols: usize) -> Self
pub fn zeros_f32(rows: usize, cols: usize) -> Self
Creates an all-zero sparse matrix retaining the single class.
Sourcepub fn zeros_logical(rows: usize, cols: usize) -> Self
pub fn zeros_logical(rows: usize, cols: usize) -> Self
Creates an all-false sparse logical matrix.
Sourcepub fn zeros_with_integer_storage(
rows: usize,
cols: usize,
storage: &IntegerStorage,
) -> Self
pub fn zeros_with_integer_storage( rows: usize, cols: usize, storage: &IntegerStorage, ) -> Self
Creates an all-zero sparse matrix retaining an exact integer class.
Sourcepub fn new_integer_like(
rows: usize,
cols: usize,
col_ptrs: Vec<usize>,
row_indices: Vec<usize>,
values: Vec<IntValue>,
prototype: &IntegerStorage,
) -> Result<Self, String>
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.
pub fn nnz(&self) -> usize
pub fn shape(&self) -> Vec<usize>
pub fn to_dense(&self) -> Result<Tensor, String>
pub fn to_dense_logical(&self) -> Result<LogicalArray, String>
pub fn get(&self, row: usize, col: usize) -> Option<f64>
pub fn logical_at(&self, row: usize, col: usize) -> Option<bool>
Sourcepub fn integer_at(&self, row: usize, col: usize) -> Option<IntValue>
pub fn integer_at(&self, row: usize, col: usize) -> Option<IntValue>
Returns an exact stored integer value when this sparse matrix is typed.
pub fn integer_storage(&self) -> Option<&IntegerStorage>
Sourcepub fn as_f64_slice(&self) -> Option<&[f64]>
pub fn as_f64_slice(&self) -> Option<&[f64]>
Borrows stored nonzero values when this sparse matrix is double.
Sourcepub fn as_f32_slice(&self) -> Option<&[f32]>
pub fn as_f32_slice(&self) -> Option<&[f32]>
Borrows stored nonzero values when this sparse matrix is single.
pub fn is_logical(&self) -> bool
pub fn value_byte_size(&self) -> usize
Sourcepub fn materialize_f64(&self) -> Vec<f64>
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.
Sourcepub fn numeric_value_at(&self, index: usize) -> Option<NumericScalar>
pub fn numeric_value_at(&self, index: usize) -> Option<NumericScalar>
Reads one stored nonzero value without routing integers through floating point.
pub fn numeric_dtype(&self) -> Option<NumericDType>
Sourcepub fn with_updated_linear_values(
&self,
updates: &[(usize, f64)],
) -> Result<Self, String>
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.
Sourcepub fn with_updated_f32_linear_values(
&self,
updates: &[(usize, f32)],
) -> Result<Self, String>
pub fn with_updated_f32_linear_values( &self, updates: &[(usize, f32)], ) -> Result<Self, String>
Applies native single-precision updates in one CSC merge.
Sourcepub fn with_updated_integer_linear_values(
&self,
updates: &[(usize, IntValue)],
) -> Result<Self, String>
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.
pub fn with_updated_logical_linear_values( &self, updates: &[(usize, bool)], ) -> Result<Self, String>
pub fn with_updated_value( &self, row: usize, col: usize, value: f64, ) -> Result<Self, String>
pub fn with_updated_f32_value( &self, row: usize, col: usize, value: f32, ) -> Result<Self, String>
pub fn with_updated_integer_value( &self, row: usize, col: usize, value: IntValue, ) -> Result<Self, String>
pub fn with_updated_logical_value( &self, row: usize, col: usize, value: bool, ) -> Result<Self, String>
Sourcepub fn with_expanded_shape(
&self,
rows: usize,
cols: usize,
) -> Result<Self, String>
pub fn with_expanded_shape( &self, rows: usize, cols: usize, ) -> Result<Self, String>
Expands sparse dimensions without materializing implicit zero entries.
Sourcepub fn with_deleted_rows(&self, rows: &[usize]) -> Result<Self, String>
pub fn with_deleted_rows(&self, rows: &[usize]) -> Result<Self, String>
Deletes complete sparse matrix rows without materializing dense storage.
Sourcepub fn with_deleted_columns(&self, columns: &[usize]) -> Result<Self, String>
pub fn with_deleted_columns(&self, columns: &[usize]) -> Result<Self, String>
Deletes complete sparse matrix columns without materializing dense storage.
pub fn class_name(&self) -> &'static str
Trait Implementations§
Source§impl Clone for SparseTensor
impl Clone for SparseTensor
Source§fn clone(&self) -> SparseTensor
fn clone(&self) -> SparseTensor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more