Fix to use sparse matrices

We are receiving ValueError: array is too big, so we need to use an
sparse array.