saiunit.sparse.coo_todense

Contents

saiunit.sparse.coo_todense#

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

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

Parameters:

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

Returns:

Dense 2-D array equivalent to mat.

Return type:

Array | saiunit.Quantity

Examples

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