|
| integer(c_int) function | rocsparse_sbsrgeam_ (handle, dir, mb, nb, block_dim, alpha, descr_a, nnzb_a, bsr_val_a, bsr_row_ptr_a, bsr_col_ind_a, beta, descr_b, nnzb_b, bsr_val_b, bsr_row_ptr_b, bsr_col_ind_b, descr_c, bsr_val_c, bsr_row_ptr_c, bsr_col_ind_c) |
| |
| integer(kind(rocsparse_status_success)) function | rocsparse_sbsrgeam_typed (handle, dir, mb, nb, block_dim, alpha, descr_a, nnzb_a, bsr_val_a, bsr_row_ptr_a, bsr_col_ind_a, beta, descr_b, nnzb_b, bsr_val_b, bsr_row_ptr_b, bsr_col_ind_b, descr_c, bsr_val_c, bsr_row_ptr_c, bsr_col_ind_c) |
| |
| integer(kind(rocsparse_status_success)) function | rocsparse_sbsrgeam_rank_0 (handle, dir, mb, nb, block_dim, alpha, descr_a, nnzb_a, bsr_val_a, bsr_row_ptr_a, bsr_col_ind_a, beta, descr_b, nnzb_b, bsr_val_b, bsr_row_ptr_b, bsr_col_ind_b, descr_c, bsr_val_c, bsr_row_ptr_c, bsr_col_ind_c) |
| |
| integer(kind(rocsparse_status_success)) function | rocsparse_sbsrgeam_rank_0_devptr (handle, dir, mb, nb, block_dim, alpha, descr_a, nnzb_a, bsr_val_a, bsr_row_ptr_a, bsr_col_ind_a, beta, descr_b, nnzb_b, bsr_val_b, bsr_row_ptr_b, bsr_col_ind_b, descr_c, bsr_val_c, bsr_row_ptr_c, bsr_col_ind_c) |
| |
| integer(kind(rocsparse_status_success)) function | rocsparse_sbsrgeam_rank_1 (handle, dir, mb, nb, block_dim, alpha, descr_a, nnzb_a, bsr_val_a, bsr_row_ptr_a, bsr_col_ind_a, beta, descr_b, nnzb_b, bsr_val_b, bsr_row_ptr_b, bsr_col_ind_b, descr_c, bsr_val_c, bsr_row_ptr_c, bsr_col_ind_c) |
| |
| integer(kind(rocsparse_status_success)) function | rocsparse_sbsrgeam_rank_1_devptr (handle, dir, mb, nb, block_dim, alpha, descr_a, nnzb_a, bsr_val_a, bsr_row_ptr_a, bsr_col_ind_a, beta, descr_b, nnzb_b, bsr_val_b, bsr_row_ptr_b, bsr_col_ind_b, descr_c, bsr_val_c, bsr_row_ptr_c, bsr_col_ind_c) |
| |
Sparse matrix sparse matrix addition using the BSR storage format.
rocsparse_bsrgeam multiplies the scalar \(\alpha\) with the sparse \(m \times n\) matrix \(A\), defined in BSR storage format, multiplies the scalar \(\beta\) with the sparse \(mb \times nb\) matrix \(B\), defined in BSR storage format, and adds both resulting matrices to obtain the sparse \(mb \times nb\) matrix \(C\), defined in BSR storage format, such that
\[
C := \alpha \cdot A + \beta \cdot B.
\]
It is assumed that bsr_row_ptr_C has already been filled and that bsr_val_C and bsr_col_ind_C are allocated by the user. bsr_row_ptr_C and the allocation size of bsr_col_ind_C and bsr_val_C is defined by the number of non-zero block elements of the sparse BSR matrix C. Both can be obtained by rocsparse_bsrgeam_nnzb().
- Note
- Both scalars \(\alpha\) and \(beta\) have to be valid.
-
Currently, only
rocsparse_matrix_type_general is supported.
-
This function is blocking with respect to the host.
-
This routine does not support execution in a hipGraph context.
- Parameters
-
| [in] | handle | - handle to the rocSPARSE library context queue. |
| [in] | dir | - direction that specifies whether to count non-zero elements by rocsparse_direction_row or by rocsparse_direction_column in the BSR matrices \(A\), \(B\), and \(C\). |
| [in] | mb | - number of rows of the sparse BSR matrix \(A\), \(B\), and \(C\). |
| [in] | nb | - number of columns of the sparse BSR matrix \(A\), \(B\), and \(C\). |
| [in] | block_dim | - the block dimension of the BSR matrix \(A\). Between 1 and m where m=mb*block_dim. |
| [in] | alpha | - scalar \(\alpha\). |
| [in] | descr_A | - descriptor of the sparse CSR matrix \(A\). Currently, only rocsparse_matrix_type_general is supported. |
| [in] | nnzb_A | - number of non-zero block entries of the sparse BSR matrix \(A\). |
| [in] | bsr_val_A | - array of nnzb_A block elements of the sparse BSR matrix \(A\). |
| [in] | bsr_row_ptr_A | - array of mb+1 block elements that point to the start of every block row of the sparse BSR matrix \(A\). |
| [in] | bsr_col_ind_A | - array of nnzb_A block elements containing the block column indices of the sparse BSR matrix \(A\). |
| [in] | beta | - scalar \(\beta\). |
| [in] | descr_B | - descriptor of the sparse BSR matrix \(B\). Currently, only rocsparse_matrix_type_general is supported. |
| [in] | nnzb_B | - number of non-zero block entries of the sparse BSR matrix \(B\). |
| [in] | bsr_val_B | - array of nnzb_B block elements of the sparse BSR matrix \(B\). |
| [in] | bsr_row_ptr_B | - array of mb+1 block elements that point to the start of every block row of the sparse BSR matrix \(B\). |
| [in] | bsr_col_ind_B | - array of nnzb_B block elements containing the block column indices of the sparse BSR matrix \(B\). |
| [in] | descr_C | - descriptor of the sparse BSR matrix \(C\). Currently, only rocsparse_matrix_type_general is supported. |
| [out] | bsr_val_C | - array of block elements of the sparse BSR matrix \(C\). |
| [in] | bsr_row_ptr_C | - array of mb+1 block elements that point to the start of every block row of the sparse BSR matrix \(C\). |
| [out] | bsr_col_ind_C | - array of block elements containing the block column indices of the sparse BSR matrix \(C\). |
- Return values
-
| rocsparse_status_success | the operation completed successfully. |
| rocsparse_status_invalid_handle | the library context was not initialized. |
| rocsparse_status_invalid_size | mb, nb, nnzb_A, or nnzb_B is invalid. |
| rocsparse_status_invalid_pointer | alpha, descr_A, bsr_val_A, bsr_row_ptr_A, bsr_col_ind_A, beta, descr_B, bsr_val_B, bsr_row_ptr_B, bsr_col_ind_B, descr_C, csr_val_C, bsr_row_ptr_C, or bsr_col_ind_C is invalid. |
| rocsparse_status_not_implemented | rocsparse_matrix_type != rocsparse_matrix_type_general. |
- Example
- This example adds two CSR matrices.