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>
impl<T: Scalar> SparseMatrix<T>
Sourcepub fn from_csr(
base: IndexBase,
m: usize,
n: usize,
row_ptr: &[aoclsparse_int],
col_ind: &[aoclsparse_int],
val: &[T],
) -> Result<Self>
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.
Sourcepub unsafe fn from_library_owned(raw: aoclsparse_matrix) -> Result<Self>
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.
Sourcepub fn base(&self) -> IndexBase
pub fn base(&self) -> IndexBase
Index base used by this matrix’s row-pointer and column-index arrays.
Sourcepub fn as_raw(&self) -> aoclsparse_matrix
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.
Sourcepub fn export_csr(
&self,
) -> Result<(IndexBase, Vec<aoclsparse_int>, Vec<aoclsparse_int>, Vec<T>)>
pub fn export_csr( &self, ) -> Result<(IndexBase, Vec<aoclsparse_int>, Vec<aoclsparse_int>, Vec<T>)>
Read out the CSR contents as freshly allocated Vecs.
Sourcepub fn set_mv_hint(
&mut self,
op: Trans,
descr: &MatDescr,
expected_calls: usize,
) -> Result<()>
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.
Sourcepub fn set_sv_hint(
&mut self,
op: Trans,
descr: &MatDescr,
expected_calls: usize,
) -> Result<()>
pub fn set_sv_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>
Hint for triangular solve (trsv).
Sourcepub fn set_mm_hint(
&mut self,
op: Trans,
descr: &MatDescr,
expected_calls: usize,
) -> Result<()>
pub fn set_mm_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>
Hint for sparse-dense matrix multiply (csrmm).
Sourcepub fn set_2m_hint(
&mut self,
op: Trans,
descr: &MatDescr,
expected_calls: usize,
) -> Result<()>
pub fn set_2m_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>
Hint for sparse-sparse matrix multiply (csr2m).
Sourcepub fn set_sm_hint(
&mut self,
op: Trans,
descr: &MatDescr,
order: Order,
expected_calls: usize,
) -> Result<()>
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.
Sourcepub fn set_lu_smoother_hint(
&mut self,
op: Trans,
descr: &MatDescr,
expected_calls: usize,
) -> Result<()>
pub fn set_lu_smoother_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>
Hint for ILU smoothing.
Sourcepub fn set_symgs_hint(
&mut self,
op: Trans,
descr: &MatDescr,
expected_calls: usize,
) -> Result<()>
pub fn set_symgs_hint( &mut self, op: Trans, descr: &MatDescr, expected_calls: usize, ) -> Result<()>
Hint for symmetric Gauss-Seidel.