legate_sparse.mmread#

legate_sparse.mmread(source: str) csr_array#

Read a sparse matrix from a Matrix Market (.mtx) file.

Parameters:

source (str) – The filename or path to the Matrix Market file to read.

Returns:

A sparse matrix in CSR format loaded from the file.

Return type:

csr_array

Notes

This function reads Matrix Market format files and converts them to CSR format. The Matrix Market format is a standard format for storing sparse matrices. For more information on the format, see https://math.nist.gov/MatrixMarket/formats.html.

The function assumes that all nodes in the system can access the file, so no special file distribution is needed.

The implementation reads the file in COO format and then converts to CSR format for efficient storage and operations.

Examples

>>> from legate_sparse import mmread
>>> A = mmread("matrix.mtx")
>>> print(A.shape)
(1000, 1000)