Skip to main content

SpMat

Struct SpMat 

Source
pub struct SpMat<'buf, T> { /* private fields */ }
Expand description

A sparse-matrix descriptor (CSR / CSC / COO / BSR). The descriptor keeps pointers to externally-owned device buffers; the lifetime parameter ties those buffers to the descriptor.

Implementations§

Source§

impl<'buf, T: SparseScalar + DeviceRepr> SpMat<'buf, T>

Source

pub fn csr( rows: i64, cols: i64, nnz: i64, row_offsets: &'buf mut DeviceBuffer<i32>, col_indices: &'buf mut DeviceBuffer<i32>, values: &'buf mut DeviceBuffer<T>, ) -> Result<Self>

Build a CSR (compressed sparse row) descriptor.

row_offsets.len() must equal rows + 1; col_indices.len() and values.len() must equal nnz.

Source

pub fn csc( rows: i64, cols: i64, nnz: i64, col_offsets: &'buf mut DeviceBuffer<i32>, row_indices: &'buf mut DeviceBuffer<i32>, values: &'buf mut DeviceBuffer<T>, ) -> Result<Self>

Build a CSC (compressed sparse column) descriptor.

Source

pub fn bsr( brows: i64, bcols: i64, bnnz: i64, row_block_dim: i64, col_block_dim: i64, order: Order, row_offsets: &'buf mut DeviceBuffer<i32>, col_indices: &'buf mut DeviceBuffer<i32>, values: &'buf mut DeviceBuffer<T>, ) -> Result<Self>

Build a BSR (block-sparse-row) descriptor.

Source

pub fn coo( rows: i64, cols: i64, nnz: i64, row_indices: &'buf mut DeviceBuffer<i32>, col_indices: &'buf mut DeviceBuffer<i32>, values: &'buf mut DeviceBuffer<T>, ) -> Result<Self>

Build a COO (coordinate) descriptor.

Source§

impl<T> SpMat<'_, T>

Source

pub fn shape(&self) -> Result<(i64, i64, i64)>

Sparse matrix dimensions: (rows, cols, nnz).

Source

pub unsafe fn set_csr_pointers( &self, row_offsets: *mut c_void, col_indices: *mut c_void, values: *mut c_void, ) -> Result<()>

Rebind a CSR descriptor’s underlying device pointers without rebuilding it. Saves descriptor recreation when the same shape is reused with new data.

§Safety

All three pointers must be live device allocations matching the original (rows + 1, nnz, nnz) element counts and the original element types. They must stay valid until the next operation on this descriptor completes.

Source

pub unsafe fn set_csc_pointers( &self, col_offsets: *mut c_void, row_indices: *mut c_void, values: *mut c_void, ) -> Result<()>

Rebind a CSC descriptor’s underlying device pointers.

§Safety

See Self::set_csr_pointers.

Source

pub unsafe fn set_coo_pointers( &self, row_indices: *mut c_void, col_indices: *mut c_void, values: *mut c_void, ) -> Result<()>

Rebind a COO descriptor’s underlying device pointers.

§Safety

See Self::set_csr_pointers.

Source

pub fn set_fill(&self, fill: Fill) -> Result<()>

Set the fill-triangle attribute (for triangular solves).

Source

pub fn set_diag(&self, diag: Diag) -> Result<()>

Set the diagonal-type attribute (unit vs non-unit, for triangular solves).

Source

pub fn as_raw(&self) -> cusparseSpMatDescr_t

Trait Implementations§

Source§

impl<T> Debug for SpMat<'_, T>

Source§

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

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

impl<T> Drop for SpMat<'_, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T> Send for SpMat<'_, T>

Auto Trait Implementations§

§

impl<'buf, T> Freeze for SpMat<'buf, T>

§

impl<'buf, T> RefUnwindSafe for SpMat<'buf, T>
where T: RefUnwindSafe,

§

impl<'buf, T> !Sync for SpMat<'buf, T>

§

impl<'buf, T> Unpin for SpMat<'buf, T>

§

impl<'buf, T> UnsafeUnpin for SpMat<'buf, T>

§

impl<'buf, T> !UnwindSafe for SpMat<'buf, T>

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> 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, 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.