Sparse functions

Modules
Sparse functions
ArrayFire Functions by Category » Linear Algebra

Functions to create and handle sparse arrays and matrix operations. More...

## Modules
| dense
| Returns a dense array from a sparse input.
| sparse
| Create a sparse array.
| sparseConvertTo
| Convert an existing sparse array into a different storage format.
| sparseGetColdx
| Returns reference to the column indices component of the sparse array.
| sparseGetInfo
| Returns reference to components of the input sparse array.
| sparseGetNNZ
| Returns the number of non zero elements in the sparse array.
| sparseGetRowIdx
| Returns reference to the row indices component of the sparse array.
| sparseGetStorage
| Returns the storage type of a sparse array.
| sparseGetValues
| Returns reference to the values component of the sparse array.

## Detailed Description

Functions to create and handle sparse arrays and matrix operations.

Sparse array in ArrayFire use the same af::array (or af_array) handle as normal. Internally, this handle is used to maintain a structure of the sparse array (components listed below).

Description | Data Type
--- | ---
Values | T (one of f32, f64, c32, c64)
Row Indices | Int (s32)
Column Indices | Int (s32)
Storage | af::storage

The value array contains the non-zero elements of the matrix. The af::dtype of the value array is the same as that of the matrix. The size of this array is the same as the number of non-zero elements of the matrix.

The row indices and column indices contain the indices based on af::storage type. These af::array are always of type s32.

The af::storage is used to determin the type of storage to use. Currently AF_STORAGE_CSR and AF_STORAGE_COO are available.

A sparse array can be identied using the af::array::issparse() function. This function will return true for a sparse array and false for a regular af::array.

The valid operations on sparse arrays are af::matmul (sparse-dense). When calling matmul for sparse matrices, the sparse array is required to be the left hand side matrix and can be used with transposing options. The dense matrix on the right hand side cannot be used with any transpose options.

Most functions cannot use sparse arrays and will throw an error with AF_ERR_ARG if a sparse array is given as input.

Note
  Sparse functionality support was added to ArrayFire in v3.4.0.