1function M=ApplyHouseholder(M,u,b,side)
2% M=ApplyHouseholder(M,u,b,side)
3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5% Apply an elementary Householder transformation Q from the RIGHT or from
6% the LEFT, according to side, to a set of vectors packed as a matrix M
7% u and b are previously computed by CHouseholder
10% M : the input matrix, size mxn, considered as n columns (
'Left') or m rows ('Right')
11% u : such that Q = I - 2*u*u'/(u'*u), mx1 ('Left') or size nx1 ('Right')
12% b : a pre computed value used to speed up Q*w(:) product
13% side : specifies the side upon which Q
is applied, recognised values :
14% 'L' stands for 'Left' multiplication, default value
15% 'R' stands for 'Right' multiplication
18% M : the transformed matrix Q*M ('Left') or M*Q ('Right')
20% Author : Alain Barraud, copyright abc.consultant@wanadoo.fr 2003-2015
22%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24if nargin==3, side='L';else, side=upper(side(1));end
26if b==0||isempty(I); return;end
27v=u(I);%only non trivial part of u
is used
31 tau=M(:,I)*tau;%intermediate row vector
32 M(:,I) =M(:,I) + tau*v';%transformed M
34 tau=v'*b;tau=tau*M(I,:);%intermediate row vector
35 M(I,:) =M(I,:) + v*tau;%transformed M
37%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%