function Qb = formqb(W,b) % FUNCTION Q = formqb(W,b) % takes the matrix W produced by house.m as input, % and implicitly calculates Q'b % % INPUT: W -- an m x n lower triangular matrix % containing the vectors of successive % Householder reflections % b -- m x 1 vector % OUTPUT: Qb -- n x 1 vector satisfying Qb = Q'b [m,n] = size(W); for k = 1:n b(k:m) = b(k:m) - 2*W(k:m,k)*(W(k:m,k)'*b(k:m)); end Qb = b;