Use sparse matrices instead of numpy arrays