function x = QRback(Q,R,bb)

  m=columns(Q); x = zeros(m,1); b = Q'*bb;

  for j=m:-1:1
    s = b(j);
    for k=j+1:m
      s = s - R(j,k)*x(k);
    end
    x(j) = s/R(j,j);
  end
endfunction
