function [V,R] = house(A) % usage: [V,R] = house(A) % description: this function calculates a full QR % factorizaton of full rank matrix A (this is % assumed!) by the modified Gram-Schmidt algorithm. % Q is returned implicitly via the Householder vectors % in V. % local variables: % ii,jj: index variables [m,n] = size(A); p = min([m,n]); V = zeros(m,p); R = A; for k = 1:p x = R(k:m,k); x(1) = (sign(x(1))+(x(1)==0))*norm(x)+x(1); V(k:m,k) = x/norm(x); R(k:m,k:n) = R(k:m,k:n) - 2*V(k:m,k)*V(k:m,k)'*R(k:m,k:n); end