added function CG_vel(), cleaned up QR_Decomp()