Skip to main content

SparseMatrix

Struct SparseMatrix 

Source
pub struct SparseMatrix<T: Scalar> { /* private fields */ }
Expand description

RAII wrapper around an aoclsparse_matrix handle holding a CSR matrix.

Construct from raw CSR vectors with SparseMatrix::from_csr (the values are copied into the wrapper) or as the result of an operation like csr2m.

Implementations§

Source§

impl<T: Scalar> SparseMatrix<T>

Source

pub fn from_csr( base: IndexBase, m: usize, n: usize, row_ptr: &[aoclsparse_int], col_ind: &[aoclsparse_int], val: &[T], ) -> Result<Self>

Build a new matrix handle from CSR arrays. The arrays are copied into the wrapper; the caller’s slices are not retained.

Source

pub unsafe fn from_library_owned(raw: aoclsparse_matrix) -> Result<Self>

Adopt a handle returned by an AOCL routine that allocates its own CSR storage (e.g. aoclsparse_dcsr2m). The library will free the arrays when the handle is destroyed.

§Safety

raw must be a valid aoclsparse_matrix whose internal storage is owned by the AOCL library and whose precision matches T.

Source

pub fn dims(&self) -> (usize, usize)

(m, n) dimensions of the matrix.

Source

pub fn nnz(&self) -> usize

Number of explicitly stored non-zeros.

Source

pub fn base(&self) -> IndexBase

Index base used by this matrix’s row-pointer and column-index arrays.

Source

pub fn as_raw(&self) -> aoclsparse_matrix

Borrow the raw underlying handle for raw FFI calls.

§Safety

The returned pointer is valid only for the lifetime of self. Do not call aoclsparse_destroy on it.

Source

pub fn export_csr( &self, ) -> Result<(IndexBase, Vec<aoclsparse_int>, Vec<aoclsparse_int>, Vec<T>)>

Read out the CSR contents as freshly allocated Vecs.

Source

pub fn set_mv_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint that mat-vec (mv) will be called expected_calls times in the given orientation op.

Source

pub fn set_sv_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint for triangular solve (trsv).

Source

pub fn set_mm_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint for sparse-dense matrix multiply (csrmm).

Source

pub fn set_2m_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint for sparse-sparse matrix multiply (csr2m).

Source

pub fn set_sm_hint( &mut self, op: Trans, descr: &MatDescr, order: Order, expected_calls: usize, ) -> Result<()>

Hint for sparse triangular solve with multiple right-hand sides (trsm). order is the layout of the dense B/X matrices.

Source

pub fn set_lu_smoother_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint for ILU smoothing.

Source

pub fn set_symgs_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint for symmetric Gauss-Seidel.

Source

pub fn set_dotmv_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint for the fused dot-mat-vec routine.

Source

pub fn set_sorv_hint( &mut self, sor_type: SorType, descr: &MatDescr, expected_calls: usize, ) -> Result<()>

Hint for SOR / Gauss-Seidel sweeps.

Trait Implementations§

Source§

impl<T: Scalar> Debug for SparseMatrix<T>

Source§

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

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

impl<T: Scalar> Drop for SparseMatrix<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SparseMatrix<T>

§

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

§

impl<T> !Send for SparseMatrix<T>

§

impl<T> !Sync for SparseMatrix<T>

§

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

§

impl<T> UnsafeUnpin for SparseMatrix<T>

§

impl<T> UnwindSafe for SparseMatrix<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<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.