search algorithm on Matrix object.