sparse matrix version of the Anderson Moore Algorithm