modified Gram-Schmidt algorithm for Reduced QR factorization