refactor SVD and Qr decompositions