Created
May 29, 2016 21:04
-
-
Save mp4096/d0894d55e69132b84b2304891c23b93e to your computer and use it in GitHub Desktop.
Generate Householder transformation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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