Created
July 2, 2016 00:51
-
-
Save jxnl/7ff4cf1d5e743d739c3aebdb34430974 to your computer and use it in GitHub Desktop.
a3
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 [Q,R]=BandQR(A, p) | |
| [n,n]=size(A); | |
| R=A; %Start with R=A | |
| Q=eye(n); %Set Q as the identity matrix | |
| for k=1:n-1 | |
| x = zeros(p+1,1); | |
| j=min(n, k+p-1); | |
| x = R(k:j, k); | |
| x(1)=x(1)+norm(x); | |
| w=x/norm(x); | |
| u=2*R(k:j, 1:end)'*w; | |
| R(k:j, 1:end)=R(k:j, 1:end)-w*u'; | |
| wwt = zeros(n,n); | |
| wwt(k:j, k:j) = w * w'; | |
| Q=Q-2*Q*wwt; | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment