# 12 Factorisation QR # Norm 2 Norm <- function(x) { stopifnot(is.numeric(x)) sqrt(sum(x^2)) } # Modified Gram-Schmidt mgs <- function(A, tol = .Machine$double.eps^0.5) { stopifnot(is.numeric(A), is.matrix(A)) M <- nrow(A); N <- ncol(A) if(M