Algorithm for nearest point iteration