1function X = cs_qright (V, Beta, p, Y) 2%CS_QRIGHT apply Householder vectors on the right. 3% X = cs_qright(V,Beta,p,Y) computes X = Y*P'*H1*H2*...*Hn = Y*Q where Q is 4% represented by the Householder vectors V, coefficients Beta, and 5% permutation p. p can be [], which denotes the identity permutation. 6% To obtain Q itself, use Q = cs_qright(V,Beta,p,speye(size(V,1))). 7% 8% Example: 9% load west0479 ; q = colamd (west0479) ; A = west0479 (:,q) ; 10% [Q,R] = qr (A) ; norm (Q*R-A, 1) 11% [V,beta,p,R2] = cs_qr (A) ; 12% Q2 = cs_qright (V, beta, p, speye(size(V,1))) ; norm (Q2*R2-A, 1) 13% 14% See also CS_QR, CS_QLEFT. 15 16% Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com 17 18[m n] = size (V) ; 19X = Y ; 20if (~isempty (p)) 21 X = X (:,p) ; 22end 23for k = 1:n 24 X = X - (X * (Beta (k) * V (:,k))) * V (:,k)' ; 25end 26