Algorithms for the polar decomposition