LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
CHouseholder.m
1function [v,u,b]=CHouseholder(v,Lz,piv)
2% [v,u,b]=CHouseholder(v,Lz,piv)
3% compute an elementary Householder transformation Q
4% such that the Lz list of components of the new v are zeros, piv is the pivot index
5% component of v. The other components of v are unchanged.
6%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7%
8% INPUT
9% v : v the input vector
10% Lz : the indices list of v components which must be zeroed
11% piv : the v pivot index
12%
13% OUTPUT
14% v : the transformed vector, with v(Lz)=0
15% u : such that Q = I - 2*u*u'/(u'*u)
16% b : a pre computed value used to speed up Q*w or w*Q products
17% where w is a column or row vector
18%
19% The Linpack algorithm is used, v is real or complex
20%
21% Author : Alain Barraud, copyright abc.consultant@wanadoo.fr 2003-2015
22%
23%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24u=zeros(size(v));%initialization and memory allocation
25vp=v(piv);rv1=real(vp);%the real pivot part
26if isrow(v), s=norm([v(piv),v(Lz)]);else, s=norm([v(piv);v(Lz)]);end%s computation
27if rv1~= 0, s = s*sign(rv1);end
28u(Lz) = v(Lz);%zeroed part of v
29up = vp + s;b=s*up;%compute u(piv)
30u(piv)=up;%now u is updated
31if b~=0%Non trivial case Q~=I
32 v(piv) = -s;v(Lz)=0;b = -1/b;%update new v
33end
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%