Svd op

Updated qr function to fit numpy update.
use a loop to make this code much shorter (and remove duplicate code).