arkouda.sparsematrix

Functions

create_sparse_matrix(→ arkouda.sparrayclass.sparray)

Create a sparse matrix from three pdarrays representing the row indices,

random_sparse_matrix(→ arkouda.sparrayclass.sparray)

Create a random sparse matrix with the specified number of rows and columns

sparse_matrix_matrix_mult(→ arkouda.sparrayclass.sparray)

Multiply two sparse matrices.

Module Contents

arkouda.sparsematrix.create_sparse_matrix(size: int, rows: arkouda.pdarrayclass.pdarray, cols: arkouda.pdarrayclass.pdarray, vals: arkouda.pdarrayclass.pdarray, layout: str) arkouda.sparrayclass.sparray[source]

Create a sparse matrix from three pdarrays representing the row indices, column indices, and values of the non-zero elements of the matrix.

Parameters:
  • rows (pdarray) – The row indices of the non-zero elements

  • cols (pdarray) – The column indices of the non-zero elements

  • vals (pdarray) – The values of the non-zero elements

Returns:

A sparse matrix with the specified row and column indices and values

Return type:

sparray

arkouda.sparsematrix.random_sparse_matrix(size: int, density: float, layout: str, dtype: type | str = int64) arkouda.sparrayclass.sparray[source]

Create a random sparse matrix with the specified number of rows and columns and the specified density. The density is the fraction of non-zero elements in the matrix. The non-zero elements are uniformly distributed random numbers in the range [0,1).

Parameters:
  • size (int) – The number of rows in the matrix, columns are equal to rows right now

  • density (float) – The fraction of non-zero elements in the matrix

  • dtype (Union[DTypes, str]) – The dtype of the elements in the matrix (default is int64)

Returns:

A sparse matrix with the specified number of rows and columns and the specified density

Return type:

sparray

Raises:

ValueError – Raised if density is not in the range [0,1]

arkouda.sparsematrix.sparse_matrix_matrix_mult(A, B: arkouda.sparrayclass.sparray) arkouda.sparrayclass.sparray[source]

Multiply two sparse matrices.

Parameters:
  • A (sparray) – The left-hand sparse matrix

  • B (sparray) – The right-hand sparse matrix

Returns:

The product of the two sparse matrices

Return type:

sparray