# Getting Started¶

COO arrays can be constructed from numpy.ndarray objects and scipy.sparse.spmatrix objects. For example, to generate the identity matrix,

import numpy as np
import scipy.sparse
import sparse

sps_identity = scipy.sparse.eye(5)
identity = sparse.COO.from_scipy_sparse(sps_identity)


COO arrays can have operations performed on them just like numpy.ndarray objects. For example, to add two COO arrays:

z = x + y


You can also apply any numpy.ufunc to COO arrays.

sin_x = np.sin(x)


However, operations which convert the sparse array into a dense one aren’t currently supported. For example, the following raises a ValueError.

y = x + 5


However, if you’re sure you want to convert a sparse array to a dense one, you can do this (which will result in a numpy.ndarray):

y = x.todense() + 5


That’s it! You can move on to the user manual to see what part of this library interests you, or you can jump straight in with the API reference.