Skip to main content

HybMatrix

Struct HybMatrix 

Source
pub struct HybMatrix<T: GpuFloat> { /* private fields */ }
Expand description

A sparse matrix in HYB (Hybrid ELL+COO) format, stored on host.

The ELL portion uses column-major layout: element (row, k) is at index k * rows + row. Unused ELL slots have column index HYB_ELL_SENTINEL and a zero value.

The COO portion stores overflow entries as unsorted (row, col, value) triplets.

Implementations§

Source§

impl<T: GpuFloat> HybMatrix<T>

Source

pub fn new( rows: usize, cols: usize, ell_width: usize, ell_col_indices: Vec<i32>, ell_values: Vec<T>, coo_row_indices: Vec<i32>, coo_col_indices: Vec<i32>, coo_values: Vec<T>, ) -> SparseResult<Self>

Creates a new HYB matrix from raw host-side arrays.

§Arguments
  • rows – Number of rows.
  • cols – Number of columns.
  • ell_width – Maximum entries per row in the ELL portion.
  • ell_col_indices – ELL column indices, length rows * ell_width, column-major. Unused entries must be HYB_ELL_SENTINEL.
  • ell_values – ELL values, length rows * ell_width, column-major.
  • coo_row_indices – COO overflow row indices.
  • coo_col_indices – COO overflow column indices.
  • coo_values – COO overflow values.
§Errors

Returns SparseError::InvalidFormat if array lengths are inconsistent.

Source

pub fn from_csr( csr: &CsrMatrix<T>, partition: HybPartition, ) -> SparseResult<Self>

Constructs a HYB matrix from a CSR matrix using the given partition strategy.

Downloads the CSR data from GPU, computes per-row nnz, determines the ELL width according to partition, then fills ELL up to that width and overflows the remainder into COO.

§Errors

Returns SparseError::Cuda on GPU transfer failure.

Source

pub fn from_coo( coo: &CooMatrix<T>, partition: HybPartition, ) -> SparseResult<Self>

Constructs a HYB matrix from a COO matrix (via CSR intermediate) using the given partition strategy.

Converts COO to CSR first, then builds HYB from the CSR data.

§Errors

Returns SparseError::Cuda on GPU transfer failure.

Source

pub fn to_csr(&self) -> SparseResult<CsrMatrix<T>>

Converts this HYB matrix back to CSR format, uploading to GPU.

Merges the ELL and COO portions into a single CSR representation.

§Errors

Returns SparseError::Cuda on GPU allocation failure. Returns SparseError::ZeroNnz if the matrix has no non-zeros.

Source

pub fn total_nnz(&self) -> usize

Returns the total number of non-zeros (ELL + COO).

Source

pub fn nnz(&self) -> usize

Returns the number of non-zeros (alias for total_nnz).

Source

pub fn is_empty(&self) -> bool

Returns true if the matrix contains no non-zero entries.

Source

pub fn ell_nnz(&self) -> usize

Returns the number of non-zeros stored in the ELL portion.

Source

pub fn rows(&self) -> usize

Returns the number of rows.

Source

pub fn cols(&self) -> usize

Returns the number of columns.

Source

pub fn ell_width(&self) -> usize

Returns the ELL width (max entries per row in ELL portion).

Source

pub fn ell_col_indices(&self) -> &[i32]

Returns a reference to the ELL column indices (column-major).

Source

pub fn ell_values(&self) -> &[T]

Returns a reference to the ELL values (column-major).

Source

pub fn coo_nnz(&self) -> usize

Returns the number of overflow entries in the COO portion.

Source

pub fn coo_row_indices(&self) -> &[i32]

Returns a reference to the COO overflow row indices.

Source

pub fn coo_col_indices(&self) -> &[i32]

Returns a reference to the COO overflow column indices.

Source

pub fn coo_values(&self) -> &[T]

Returns a reference to the COO overflow values.

Source

pub fn statistics(&self) -> HybStatistics

Computes statistics describing the quality of the HYB partition.

The returned HybStatistics includes the fraction of nnz in each portion, the ELL padding ratio, and memory consumption compared to an equivalent CSR matrix.

Trait Implementations§

Source§

impl<T: Clone + GpuFloat> Clone for HybMatrix<T>

Source§

fn clone(&self) -> HybMatrix<T>

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<T: Debug + GpuFloat> Debug for HybMatrix<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for HybMatrix<T>

§

impl<T> RefUnwindSafe for HybMatrix<T>
where T: RefUnwindSafe,

§

impl<T> Send for HybMatrix<T>

§

impl<T> Sync for HybMatrix<T>

§

impl<T> Unpin for HybMatrix<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for HybMatrix<T>

§

impl<T> UnwindSafe for HybMatrix<T>
where T: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more