Auxiliary Functions - Auxiliary Functions - 5.0 English - 63865

AOCL Sparse Library (63865)

Document ID
63865
Release Date
2024-10-09
Version
5.0 English

Auxiliary Functions#

aoclsparse_create_mat_descr()#

aoclsparse_status aoclsparse_create_mat_descr(aoclsparse_mat_descr *descr)#

Create a matrix descriptor.

aoclsparse_create_mat_descr creates a matrix descriptor. It initializes aoclsparse_matrix_type to aoclsparse_matrix_type_general and aoclsparse_index_base to aoclsparse_index_base_zero. It should be destroyed at the end using aoclsparse_destroy_mat_descr().

Parameters

descr[out] the pointer to the matrix descriptor.

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointerdescr pointer is invalid.

aoclsparse_destroy_mat_descr()#

aoclsparse_status aoclsparse_destroy_mat_descr(aoclsparse_mat_descr descr)#

Destroy a matrix descriptor.

aoclsparse_destroy_mat_descr destroys a matrix descriptor and releases all resources used by the descriptor.

Parameters

descr[in] the matrix descriptor.

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointerdescr is invalid.

aoclsparse_copy_mat_descr()#

aoclsparse_status aoclsparse_copy_mat_descr(aoclsparse_mat_descr dest, const aoclsparse_mat_descr src)#

Copy a matrix descriptor.

aoclsparse_copy_mat_descr copies a matrix descriptor. Both, source and destination matrix descriptors must be initialized prior to calling aoclsparse_copy_mat_descr.

Parameters
  • dest[out] the pointer to the destination matrix descriptor.

  • src[in] the pointer to the source matrix descriptor.

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointersrc or dest pointer is invalid.

aoclsparse_create_?csr()#

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.

aoclsparse_create_?tcsr()#

aoclsparse_status aoclsparse_create_stcsr(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ptr_L, aoclsparse_int *row_ptr_U, aoclsparse_int *col_idx_L, aoclsparse_int *col_idx_U, float *val_L, float *val_U)#
aoclsparse_status aoclsparse_create_dtcsr(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ptr_L, aoclsparse_int *row_ptr_U, aoclsparse_int *col_idx_L, aoclsparse_int *col_idx_U, double *val_L, double *val_U)#
aoclsparse_status aoclsparse_create_ctcsr(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ptr_L, aoclsparse_int *row_ptr_U, aoclsparse_int *col_idx_L, aoclsparse_int *col_idx_U, aoclsparse_float_complex *val_L, aoclsparse_float_complex *val_U)#
aoclsparse_status aoclsparse_create_ztcsr(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ptr_L, aoclsparse_int *row_ptr_U, aoclsparse_int *col_idx_L, aoclsparse_int *col_idx_U, aoclsparse_double_complex *val_L, aoclsparse_double_complex *val_U)#

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

aoclsparse_create_?tcsr creates aoclsparse_matrix and initializes it with input parameters passed. Array data must not be modified by the user while matrix is being used as the pointers are copied, not the data. The input arrays are not modified by the library and the matrix should be destroyed at the end using aoclsparse_destroy().

TCSR matrix structure holds lower triangular (L) and upper triangular (U) part of the matrix separately with diagonal (D) elements stored in both the parts. Both triangles (L+D and D+U) are stored like CSR and assumes partial sorting (L+D and D+U order is followed, but the indices within L or U group may not be sorted)

  • One array with L elements potentially unsorted, followed by D elements in the L+D part for each row of the matrix.

  • Another array with D elements, followed by U elements potentially unsorted in the D+U part for each row of the matrix.

  • Currently TCSR storage format supports only square matrices with full(non-zero) diagonals.

Parameters
  • mat[out] The pointer to the TCSR sparse matrix.

  • base[in] aoclsparse_index_base_zero or aoclsparse_index_base_one.

  • M[in] Total number of rows in the mat.

  • N[in] Total number of columns in the mat.

  • nnz[in] Number of non-zero entries in the mat.

  • row_ptr_L[in] Array of lower triangular elements that point to the start of every row of the mat in col_idx_L and val_L.

  • row_ptr_U[in] Array of upper triangular elements that point to the start of every row of the mat in col_idx_U and val_U.

  • col_idx_L[in] Array of lower triangular elements containing column indices of the mat.

  • col_idx_U[in] Array of upper triangular elements containing column indices of the mat.

  • val_L[in] Array of lower triangular elements of the mat.

  • val_U[in] Array of upper triangular elements of the mat.

Return values
  • aoclsparse_status_success – The operation completed successfully.

  • aoclsparse_status_invalid_pointer – Pointer given to API is invalid or nullptr.

  • aoclsparse_status_invalid_size – M, N, nnz is invalid.

  • aoclsparse_status_invalid_index_value – Index given for mat is out of matrix bounds depending on base given.

  • aoclsparse_status_invalid_value – The cooridante row_ptr or col_idx is out of matrix bound or mat has duplicate diagonals or mat does not have full diagonals.

  • aoclsparse_status_unsorted_input – The mat is unsorted. It supports only fully sorted and partially sorted matrix as input. The lower triangular part must not contain U elements, the upper triangular part must not contain L elements, and the position of the diagonal element must not be altered.

  • aoclsparse_status_memory_error – Memory allocation for matrix failed.

aoclsparse_create_?coo()#

aoclsparse_status aoclsparse_create_scoo(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ind, aoclsparse_int *col_ind, float *val)#
aoclsparse_status aoclsparse_create_dcoo(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ind, aoclsparse_int *col_ind, double *val)#
aoclsparse_status aoclsparse_create_ccoo(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ind, aoclsparse_int *col_ind, aoclsparse_float_complex *val)#
aoclsparse_status aoclsparse_create_zcoo(aoclsparse_matrix *mat, const aoclsparse_index_base base, const aoclsparse_int M, const aoclsparse_int N, const aoclsparse_int nnz, aoclsparse_int *row_ind, aoclsparse_int *col_ind, aoclsparse_double_complex *val)#

Creates a new aoclsparse_matrix based on COO (Co-ordinate format).

aoclsparse_create_?coo creates aoclsparse_matrix and initializes it with input parameters passed. Array data must not be modified by the user while matrix is alive as the pointers are copied, not the data. The input arrays are left unchanged by the library except for the call to aoclsparse_sset_value(), aoclsparse_supdate_values() and variants, which modify the value of a nonzero element. Matrix should be destroyed at the end using aoclsparse_destroy().

Parameters
  • mat[inout] the pointer to the COO sparse matrix.

  • base[in] aoclsparse_index_base_zero or aoclsparse_index_base_one depending on whether the index first element starts from 0 or 1.

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

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

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

  • row_ind[in] array of nnz elements that point to the row of the element in co-ordinate Format.

  • col_ind[in] array of nnz elements that point to the column of the element in co-ordinate Format.

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

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointer – pointer given to API is invalid or nullptr.

  • aoclsparse_status_invalid_sizecoo dimension of matrix or non-zero elements is invalid.

  • aoclsparse_status_invalid_index_value – index given for coo is out of matrix bounds depending on base given

  • aoclsparse_status_memory_error – memory allocation for matrix failed.

aoclsparse_create_?csc()#

aoclsparse_status aoclsparse_create_scsc(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *col_ptr, aoclsparse_int *row_idx, float *val)#
aoclsparse_status aoclsparse_create_dcsc(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *col_ptr, aoclsparse_int *row_idx, double *val)#
aoclsparse_status aoclsparse_create_ccsc(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *col_ptr, aoclsparse_int *row_idx, aoclsparse_float_complex *val)#
aoclsparse_status aoclsparse_create_zcsc(aoclsparse_matrix *mat, aoclsparse_index_base base, aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int *col_ptr, aoclsparse_int *row_idx, aoclsparse_double_complex *val)#

Creates a new aoclsparse_matrix based on CSC (Compressed Sparse Column) format.

aoclsparse_create_?csc 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 row indices of the matrix, or aoclsparse_sset_value(), aoclsparse_supdate_values() and variants, which modify the value of a nonzero element. To avoid any changes to the input data, aoclsparse_copy() can be used. Matrix should be destroyed at the end using aoclsparse_destroy().

Parameters
  • mat[inout] the pointer to the CSC 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 CSC matrix.

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

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

  • col_ptr[in] array of n +1 elements that points to the start of every column in row_idx array of the sparse CSC matrix.

  • row_idx[in] array of nnz elements containing the row indices of the sparse CSC matrix.

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

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointercol_ptr, row_idx or val pointer is NULL.

  • aoclsparse_status_invalid_sizeM, N or nnz are negative values.

  • aoclsparse_status_invalid_index_value – any row_idx value is not within M.

  • aoclsparse_status_memory_error – memory allocation for matrix failed.

aoclsparse_destroy()#

aoclsparse_status aoclsparse_destroy(aoclsparse_matrix *mat)#

Destroy a sparse matrix structure.

aoclsparse_destroy destroys a structure that holds matrix mat.

Parameters

mat[in] the pointer to the sparse matrix.

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointermatrix structure pointer is invalid.

aoclsparse_copy()#

aoclsparse_status aoclsparse_copy(const aoclsparse_matrix src, const aoclsparse_mat_descr descr, aoclsparse_matrix *dest)#

Creates a copy of source aoclsparse_matrix.

aoclsparse_copy creates a deep copy of source aoclsparse_matrix (hints and optimized data are not copied). Matrix should be destroyed using aoclsparse_destroy(). aoclsparse_convert_csr() can also be used to create a copy of the source matrix while converting it in CSR format.

Parameters
  • src[in] the source aoclsparse_matrix to copy.

  • descr[in] the source matrix descriptor, this argument is reserved for future releases and it will not be referenced.

  • dest[out] pointer to the newly allocated copied aoclsparse_matrix.

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointersrc, dest or internal pointers are invalid. or dest points to src.

  • aoclsparse_status_memory_error – memory allocation for matrix failed.

  • aoclsparse_status_invalid_valuesrc matrix type is invalid.

  • aoclsparse_status_wrong_typesrc matrix data type is invalid.

aoclsparse_order_mat()#

aoclsparse_status aoclsparse_order_mat(aoclsparse_matrix mat)#

Performs ordering of index array of the matrix.

aoclsparse_order orders column indices within a row for matrix in CSR format and row indices within a column for CSC format. It also adjusts value array accordingly. Ordering is implemented only for CSR and CSC format. aoclsparse_copy() can be used to get exact copy of data aoclsparse_convert_csr() can be used to convert any format to CSR. Matrix should be destroyed at the end using aoclsparse_destroy().

Parameters

mat[inout] pointer to matrix in either CSR or CSC format

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointermat pointer is invalid.

  • aoclsparse_status_memory_error – internal memory allocation failed.

  • aoclsparse_status_not_implemented – matrix is not in CSR format.

aoclsparse_?set_value()#

aoclsparse_status aoclsparse_sset_value(aoclsparse_matrix A, aoclsparse_int row_idx, aoclsparse_int col_idx, float val)#
aoclsparse_status aoclsparse_dset_value(aoclsparse_matrix A, aoclsparse_int row_idx, aoclsparse_int col_idx, double val)#
aoclsparse_status aoclsparse_cset_value(aoclsparse_matrix A, aoclsparse_int row_idx, aoclsparse_int col_idx, aoclsparse_float_complex val)#
aoclsparse_status aoclsparse_zset_value(aoclsparse_matrix A, aoclsparse_int row_idx, aoclsparse_int col_idx, aoclsparse_double_complex val)#

Set a new value to an existing nonzero in the matrix.

aoclsparse_?set_value modifies the value of an existing nonzero element specified by its coordinates. The row and column coordinates need to match the base (0 or 1-base) of the matrix. The change directly affects user’s arrays if the matrix was created using aoclsparse_create_scsr(), aoclsparse_create_scsc(), aoclsparse_create_scoo() or other variants.

Note

The successful modification invalidates existing optimized data so it is desirable to call aoclsparse_optimize() once all modifications are performed.

Parameters
  • A[inout] The sparse matrix to be modified.

  • row_idx[in] The row index of the element to be updated.

  • col_idx[in] The column index of the element to be updated.

  • val[in] The value to be updated.

Return values
  • aoclsparse_status_success – The operation completed successfully.

  • aoclsparse_status_invalid_pointer – The matrix handler A is invalid

  • aoclsparse_status_invalid_value – The cooridante row_idx or col_idx is out of matrix bound

  • aoclsparse_status_wrong_type – Matrix has different data type then the one used in API

  • aoclsparse_status_not_implemented – Matrix format is not supported for this operation

  • aoclsparse_status_invalid_index_value – The specified element does not exist in the matrix

aoclsparse_?update_values()#

aoclsparse_status aoclsparse_supdate_values(aoclsparse_matrix A, aoclsparse_int len, float *val)#
aoclsparse_status aoclsparse_dupdate_values(aoclsparse_matrix A, aoclsparse_int len, double *val)#
aoclsparse_status aoclsparse_cupdate_values(aoclsparse_matrix A, aoclsparse_int len, aoclsparse_float_complex *val)#
aoclsparse_status aoclsparse_zupdate_values(aoclsparse_matrix A, aoclsparse_int len, aoclsparse_double_complex *val)#

Set new values to all existing nonzero element in the matrix.

aoclsparse_?update_values overwrites all existing nonzeros in the matrix with the new values provided in val array. The order of elements must match the order in the matrix. That would be either the order at the creation of the matrix or the sorted order if aoclsparse_order_mat() has been called. The change directly affects user’s arrays if the matrix was created using aoclsparse_create_scsr(), aoclsparse_create_scsc(), aoclsparse_create_scoo() or other variants.

Note

The successful update invalidates existing optimized data so it is desirable to call aoclsparse_optimize() once all modifications are performed.

Parameters
  • A[inout] The sparse matrix to be modified.

  • len[in] Length of the val array and the number of nonzeros in the matrix.

  • val[in] Array with the values to be copied.

Return values
  • aoclsparse_status_success – The operation completed successfully.

  • aoclsparse_status_invalid_pointer – The matrix A is invalid or val in NULL

  • aoclsparse_status_invalid_sizelen is not equal to nnz of matrix

  • aoclsparse_status_wrong_type – Matrix has different data type then the one used in API

  • aoclsparse_status_not_implemented – Matrix format is not supported for this operation

aoclsparse_export_?csr()#

aoclsparse_status aoclsparse_export_scsr(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ind, float **val)#
aoclsparse_status aoclsparse_export_dcsr(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ind, double **val)#
aoclsparse_status aoclsparse_export_ccsr(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ind, aoclsparse_float_complex **val)#
aoclsparse_status aoclsparse_export_zcsr(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ind, aoclsparse_double_complex **val)#

Export a CSR matrix.

aoclsparse_export_?csr exposes the components defining the CSR matrix in mat structure by copying out the data pointers. No additional memory is allocated. User should not modify the arrays and once aoclsparse_destroy() is called to free mat, these arrays will become inaccessible. If the matrix is not in CSR format, an error is obtained. aoclsparse_convert_csr() can be used to convert non-CSR format to CSR format.

Parameters
  • mat[in] the pointer to the CSR sparse matrix.

  • base[out] aoclsparse_index_base_zero or aoclsparse_index_base_one.

  • m[out] number of rows of the sparse CSR matrix.

  • n[out] number of columns of the sparse CSR matrix.

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

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

  • col_ind[out] array of nnz elements containing the column indices of the sparse CSR matrix.

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

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointermat or any of the output arguments are NULL.

  • aoclsparse_status_invalid_valuemat is not in CSR format.

  • aoclsparse_status_wrong_type – data type of mat does not match the function.

aoclsparse_export_?csc()#

aoclsparse_status aoclsparse_export_scsc(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **col_ptr, aoclsparse_int **row_ind, float **val)#
aoclsparse_status aoclsparse_export_dcsc(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **col_ptr, aoclsparse_int **row_ind, double **val)#
aoclsparse_status aoclsparse_export_ccsc(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **col_ptr, aoclsparse_int **row_ind, aoclsparse_float_complex **val)#
aoclsparse_status aoclsparse_export_zcsc(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **col_ptr, aoclsparse_int **row_ind, aoclsparse_double_complex **val)#

Export CSC matrix.

aoclsparse_export_?csc exposes the components defining the CSC matrix in mat structure by copying out the data pointers. No additional memory is allocated. User should not modify the arrays and once aoclsparse_destroy() is called to free mat, these arrays will become inaccessible. If the matrix is not in CSC format, an error is obtained.

Parameters
  • mat[in] the pointer to the CSC sparse matrix.

  • base[out] aoclsparse_index_base_zero or aoclsparse_index_base_one.

  • m[out] number of rows of the sparse CSC matrix.

  • n[out] number of columns of the sparse CSC matrix.

  • nnz[out] number of non-zero entries of the sparse CSC matrix.

  • col_ptr[out] array of n+1 elements that point to the start of every col of the sparse CSC matrix.

  • row_ind[out] array of nnz elements containing the row indices of the sparse CSC matrix.

  • val[out] array of nnz elements of the sparse CSC matrix.

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointermat or any of the output arguments are invalid.

  • aoclsparse_status_invalid_valuemat is not in CSC format.

  • aoclsparse_status_wrong_type – data type of mat does not match the function data type.

aoclsparse_export_?coo()#

aoclsparse_status aoclsparse_export_scoo(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ptr, float **val)#
aoclsparse_status aoclsparse_export_dcoo(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ptr, double **val)#
aoclsparse_status aoclsparse_export_ccoo(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ptr, aoclsparse_float_complex **val)#
aoclsparse_status aoclsparse_export_zcoo(const aoclsparse_matrix mat, aoclsparse_index_base *base, aoclsparse_int *m, aoclsparse_int *n, aoclsparse_int *nnz, aoclsparse_int **row_ptr, aoclsparse_int **col_ptr, aoclsparse_double_complex **val)#

Export a COO matrix.

aoclsparse_export_?coo exposes the components defining the COO matrix in mat structure by copying out the data pointers. No additional memory is allocated. User should not modify the arrays and once aoclsparse_destroy() is called to free mat, these arrays will become inaccessible. If the matrix is not in COO format, an error is obtained.

Parameters
  • mat[in] the pointer to the COO sparse matrix.

  • base[out] aoclsparse_index_base_zero or aoclsparse_index_base_one.

  • m[out] number of rows of the sparse COO matrix.

  • n[out] number of columns of the sparse COO matrix.

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

  • row_ptr[out] array of nnz elements containing the row indices of the sparse COO matrix.

  • col_ptr[out] array of nnz elements containing the column indices of the sparse COO matrix.

  • val[out] array of nnz elements of the sparse COO matrix.

Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointermat or any of the output arguments are NULL.

  • aoclsparse_status_invalid_valuemat is not in COO format.

  • aoclsparse_status_wrong_type – data type of mat does not match the function.

aoclsparse_get_mat_diag_type()#

aoclsparse_diag_type aoclsparse_get_mat_diag_type(const aoclsparse_mat_descr descr)#

Get the matrix diagonal type of a matrix descriptor.

aoclsparse_get_mat_diag_type returns the matrix diagonal type of a matrix descriptor.

Parameters

descr[in] the matrix descriptor.

Returns

aoclsparse_diag_type_unit or aoclsparse_diag_type_non_unit or aoclsparse_diag_type_zero.

aoclsparse_get_mat_fill_mode()#

aoclsparse_fill_mode aoclsparse_get_mat_fill_mode(const aoclsparse_mat_descr descr)#

Get the matrix fill mode of a matrix descriptor.

aoclsparse_get_mat_fill_mode returns the matrix fill mode of a matrix descriptor.

Parameters

descr[in] the matrix descriptor.

Returns

aoclsparse_fill_mode_lower or aoclsparse_fill_mode_upper.

aoclsparse_get_mat_index_base()#

aoclsparse_index_base aoclsparse_get_mat_index_base(const aoclsparse_mat_descr descr)#

Get the index base of a matrix descriptor.

aoclsparse_get_mat_index_base returns the index base of a matrix descriptor.

Parameters

descr[in] the matrix descriptor.

Returns

aoclsparse_index_base_zero or aoclsparse_index_base_one.

aoclsparse_get_mat_type()#

aoclsparse_matrix_type aoclsparse_get_mat_type(const aoclsparse_mat_descr descr)#

Get the matrix type of a matrix descriptor.

aoclsparse_get_mat_type returns the matrix type of a matrix descriptor.

Parameters

descr[in] the matrix descriptor.

Returns

aoclsparse_matrix_type_general, aoclsparse_matrix_type_symmetric, aoclsparse_matrix_type_hermitian or aoclsparse_matrix_type_triangular.

aoclsparse_get_version()#

const char *aoclsparse_get_version()#

Get AOCL-Sparse Library version.

Returns

AOCL-Sparse Library version number in the format “AOCL-Sparse <major>.<minor>.<patch>”

aoclsparse_set_mat_diag_type()#

aoclsparse_status aoclsparse_set_mat_diag_type(aoclsparse_mat_descr descr, aoclsparse_diag_type diag_type)#

Specify the matrix diagonal type of a matrix descriptor.

aoclsparse_set_mat_diag_type sets the matrix diagonal type of a matrix descriptor. Valid diagonal types are aoclsparse_diag_type_unit, aoclsparse_diag_type_non_unit or aoclsparse_diag_type_zero.

Parameters
Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointerdescr pointer is invalid.

  • aoclsparse_status_invalid_valuediag_type is invalid.

aoclsparse_set_mat_fill_mode()#

aoclsparse_status aoclsparse_set_mat_fill_mode(aoclsparse_mat_descr descr, aoclsparse_fill_mode fill_mode)#

Specify the matrix fill mode of a matrix descriptor.

aoclsparse_set_mat_fill_mode sets the matrix fill mode of a matrix descriptor. Valid fill modes are aoclsparse_fill_mode_lower or aoclsparse_fill_mode_upper.

Parameters
Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointerdescr pointer is invalid.

  • aoclsparse_status_invalid_valuefill_mode is invalid.

aoclsparse_set_mat_index_base()#

aoclsparse_status aoclsparse_set_mat_index_base(aoclsparse_mat_descr descr, aoclsparse_index_base base)#

Specify the index base of a matrix descriptor.

aoclsparse_set_mat_index_base sets the index base of a matrix descriptor. Valid options are aoclsparse_index_base_zero or aoclsparse_index_base_one.

Parameters
Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointerdescr pointer is invalid.

  • aoclsparse_status_invalid_valuebase is invalid.

aoclsparse_set_mat_type()#

aoclsparse_status aoclsparse_set_mat_type(aoclsparse_mat_descr descr, aoclsparse_matrix_type type)#

Specify the matrix type of a matrix descriptor.

aoclsparse_set_mat_type sets the matrix type of a matrix descriptor. Valid matrix types are aoclsparse_matrix_type_general, aoclsparse_matrix_type_symmetric, aoclsparse_matrix_type_hermitian or aoclsparse_matrix_type_triangular.

Parameters
Return values
  • aoclsparse_status_success – the operation completed successfully.

  • aoclsparse_status_invalid_pointerdescr pointer is invalid.

  • aoclsparse_status_invalid_valuetype is invalid.