Skip to content

Instantly share code, notes, and snippets.

@mp4096
Created May 29, 2016 21:04
Show Gist options
  • Select an option

  • Save mp4096/d0894d55e69132b84b2304891c23b93e to your computer and use it in GitHub Desktop.

Select an option

Save mp4096/d0894d55e69132b84b2304891c23b93e to your computer and use it in GitHub Desktop.
Generate Householder transformation
function P = GenerateHouseholder(a, pad)
alpha = -sign(a(2))*norm(a(2 : end), 2);
r = sqrt(0.5*alpha*(alpha - a(2)));
v = zeros(length(a), 1);
v(2) = 0.5*(a(2) - alpha)/r;
v(3 : end) = 0.5*a(3 : end)/r;
v = [zeros(pad, 1); v];
P = eye(pad + length(a)) - 2*(v*v');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment