aoclsparse_create_?csr() - 5.2 English - 68552

AOCL API Guide (68552)

Document ID
68552
Release Date
2025-12-29
Version
5.2 English
aoclsparse_status aoclsparse_create_scsr(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *row_ptr, aoclsparse_int *col_idx, float *val)#
aoclsparse_status aoclsparse_create_dcsr(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *row_ptr, aoclsparse_int *col_idx, double *val)#
aoclsparse_status aoclsparse_create_ccsr(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *row_ptr, aoclsparse_int *col_idx, aoclsparse_float_complex *val)#
aoclsparse_status aoclsparse_create_zcsr(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *row_ptr, aoclsparse_int *col_idx, aoclsparse_double_complex *val)#

Creates a new aoclsparse_matrix based on CSR (Compressed Sparse Row) format.

aoclsparse_create_?csr creates aoclsparse_matrix and initializes it with input parameters passed. The input arrays are left unchanged by the library except for the call to aoclsparse_order_mat(), which performs ordering of column indices of the matrix, or aoclsparse_sset_value(), aoclsparse_supdate_values() and variants, which modify the values of a nonzero element. To avoid any changes to the input data, aoclsparse_copy() can be used. To convert any other format to CSR, aoclsparse_convert_csr() can be used. Matrix should be destroyed at the end using aoclsparse_destroy().

Parameters:
  • mat[out] the pointer to the CSR sparse matrix allocated in the API.

  • base[in] aoclsparse_index_base_zero or aoclsparse_index_base_one.

  • M[in] number of rows of the sparse CSR matrix.

  • N[in] number of columns of the sparse CSR matrix.

  • nnz[in] number of non-zero entries of the sparse CSR matrix.

  • row_ptr[in] array of m+1 elements that point to the start of every row of the sparse CSR matrix.

  • col_idx[in] array of nnz elements containing the column indices of the sparse CSR matrix.

  • val[in] array of nnz elements of the sparse CSR matrix.

Return values:
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointer – at least one of row_ptr, col_idx or val pointer is NULL.

  • aoclsparse_status_invalid_size – at least one of M, N or nnz has a negative value.

  • aoclsparse_status_invalid_index_value – any col_idx value is not within N.

  • aoclsparse_status_memory_error – memory allocation for matrix failed.