hw3s - Q 10.2 function[Q R = p10_2(A[W,R = house(A Q =...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Q 10.2 function [Q, R] = p10_2(A) [W,R] = house(A); Q = formQ(W); function [W,R] = house(A) [m,n] = size(A); R = A; W = zeros(m,n); for k = 1:n x = R(k:m,k); xnorm = norm(x); if xnorm>0, % Compute the normal vector of the reflector W(k:m,k) = x; W(k,k) = W(k,k) + sign(x(1))*xnorm; W(k:m,k) = W(k:m,k)/norm(W(k:m,k)); % Update R for j = k:n, R(k:m,j) = R(k:m,j) - 2*(W(k:m,k)'*R(k:m,j))*W(k:m,k); end else W(k:m,k) = zeros(m-k+1,1); end end function Q = formQ(W) [m,n] = size(W); Q = eye(m); for i = 1:n Q = Q*[eye(i-1) zeros(i-1, m-i+1); zeros(m-i+1,i-1) eye(m-i+1) - 2*W(i:end,i)*W(i:end,i)']; end A = [0.8147 + 0.9572i 0.6324 + 0.4218i 0.9575 + 0.6557i; 0.9058 + 0.4854i 0.0975 + 0.9157i 0.9649 + 0.0357i; 0.1270 + 0.8003i 0.2785 + 0.7922i 0.1576 + 0.8491i; 0.9134 + 0.1419i 0.5469 + 0.9595i 0.9706 + 0.9340i] Q =[-0.6172 0.5360 - 0.0054i 0.0170 - 0.0964i 0.5582 + 0.1024i; -0.4698 + 0.1842i -0.4507 - 0.0626i 0.6510 - 0.2577i -0.1757 + 0.1314i; -0.3397 - 0.2072i 0.0926 + 0.4337i -0.1064 - 0.1708i -0.3603 - 0.6890i;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

hw3s - Q 10.2 function[Q R = p10_2(A[W,R = house(A Q =...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online