rocsparse_extract Interface Reference#
Sparse matrix extraction. More...
Public Member Functions | |
| integer(kind(rocsparse_status_success)) function | rocsparse_extract_ (handle, descr, source, target, stage, buffer_size_in_bytes, buffer) |
Detailed Description
Sparse matrix extraction.
rocsparse_extract performs the extraction of the lower or upper part of a sparse matrix into a new matrix.
rocsparse_extract requires multiple steps to complete. First, create the source and target sparse matrix descriptors. For example, in the case of CSR matrix format, this might look like:
Next, create the extraction descriptor and call rocsparse_extract_buffer_size with the stage rocsparse_extract_stage_analysis to determine the amount of temporary storage required. Allocate this temporary storage buffer and pass it to rocsparse_extract with the stage rocsparse_extract_stage_analysis.
Then calls rocsparse_extract_nnz to determine the number of non-zeros that will exist in the target matrix. After this is determined, allocate the column indices and values arrays of the target sparse matrix:
Finally, call rocsparse_extract_buffer_size with the stage rocsparse_extract_stage_compute to determine the size of the temporary user-allocated storage needed for the computation of the column indices and values in the sparse target. Allocate this buffer and complete the conversion by calling rocsparse_extract using the rocsparse_extract_stage_compute stage:
The target row pointer, column indices, and values arrays will now be filled with the upper or lower part of the source matrix.
The source and the target matrices must have the same format (see rocsparse_format ) and the same storage mode (see rocsparse_storage_mode ). The attributes of the target matrix, the fill mode rocsparse_fill_mode, and the diagonal type rocsparse_diag_type are used to parameterize the algorithm. These can be set on the target matrix using rocsparse_spmat_set_attribute. See the full example below.
- Note
- This routine is asynchronous with respect to the host. This routine supports execution in a hipGraph context.
-
Supported formats are
rocsparse_format_csrandrocsparse_format_csc. - This routine does not support batched computation.
- Parameters
-
[in] handle - handle to the rocSPARSE library context queue. [in] descr - descriptor of the extract algorithm. [in] source - sparse matrix descriptor. [in] target - sparse matrix descriptor. [in] stage - stage of the extract computation. [in] buffer_size_in_bytes - size in bytes of the buffer.[in] buffer - temporary storage buffer allocated by the user.
- Return values
-
rocsparse_status_success the operation completed successfully. rocsparse_status_invalid_handle the library context was not initialized. rocsparse_status_invalid_value if stageis invalid.rocsparse_status_invalid_pointer descr,source,target, orbufferpointer is invalid.
- Example
- This example extracts the lower part of CSR matrix into a CSR matrix.
Member Function/Subroutine Documentation
◆ rocsparse_extract_()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_extract::rocsparse_extract_ | ( | type(c_ptr), value | handle, |
| type(c_ptr), value | descr, | ||
| type(c_ptr), value | source, | ||
| type(c_ptr), value | target, | ||
| integer(kind(rocsparse_extract_stage_analysis)), value | stage, | ||
| integer(c_size_t), value | buffer_size_in_bytes, | ||
| type(c_ptr), value | buffer | ||
| ) |
The documentation for this interface was generated from the following file: