Raise an exception for sparse inputs