saiunit.sparse.csr_todense

Contents

saiunit.sparse.csr_todense#

saiunit.sparse.csr_todense(mat)[source]#

Convert a CSR-format sparse matrix to a dense matrix.

Parameters:

mat (CSR) – The CSR sparse matrix to convert.

Returns:

Dense 2-D array equivalent to mat.

Return type:

Array | saiunit.Quantity

Raises:

TypeError – If mat is not an instance of CSR.

Examples

>>> import jax.numpy as jnp
>>> import saiunit as u
>>> import saiunit.sparse as susparse
>>> dense = jnp.array([[5., 0.], [0., 6.]])
>>> csr = susparse.csr_fromdense(dense)
>>> susparse.csr_todense(csr)
Array([[5., 0.],
       [0., 6.]], dtype=float32)