Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QR decomposition

0 views
Skip to first unread message

varun

unread,
Feb 13, 2012, 9:28:59 AM2/13/12
to
I am trying to implement QR decomposition for Hermitian Matrix
But the conventional Gram Schmidt Process Fails please help!!

My code:
clc
clear all
close all

%A = [1 1 1; 1 1 0 ; 1 1 2];
A = [1+6j 1-4j 3-2j; 1+4j 8-1j 2+4j ; 3+2j 2-4j 2];
[qq rr] = qr(A);

MM=A;
[m n] = size(A);

r = zeros(n,n);mm=0;
QT = zeros(n,m);
Q = A;

for k=1:n
QT(k,:) = A(:,k)';
end
for k = 1:n
r(k,k) = sqrt(QT(k,:)*QT(k,:)');
QT(k,:) = QT(k,:)/r(k,k);
if(k<n)
for j=k+1:n
r(k,j)= (A(:,j)'*QT(k,:)')';
QT(j,:)= (QT(j,:)'-(r(k,j)*QT(k,:)'))';
end
end
end

Matt J

unread,
Feb 13, 2012, 9:34:12 AM2/13/12
to
"varun" wrote in message <jhb6na$7sf$1...@newscl01ah.mathworks.com>...
> I am trying to implement QR decomposition for Hermitian Matrix
> But the conventional Gram Schmidt Process Fails please help!!

Why do you even need to do Gram Schmidt when the QR command gives you the decomposition straight away? Gram Schmidt is a numerically unstable algorithm, which is why people always use QR instead.

Steven_Lord

unread,
Feb 13, 2012, 9:37:29 AM2/13/12
to


"varun " <signal...@gmail.com> wrote in message
news:jhb6na$7sf$1...@newscl01ah.mathworks.com...
> I am trying to implement QR decomposition for Hermitian Matrix
> But the conventional Gram Schmidt Process Fails please help!!

Define "fails" -- does your code throw an error? Does it return results
different from what you expect?

The more specific information you provide, the more likely it is that
someone will be able to help you.

*snip code*

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Matt J

unread,
Feb 13, 2012, 9:39:12 AM2/13/12
to
"varun" wrote in message <jhb6na$7sf$1...@newscl01ah.mathworks.com>...
> I am trying to implement QR decomposition for Hermitian Matrix
> But the conventional Gram Schmidt Process Fails please help!!

In any case, it doesn't look like the process failed. When I run your code, I get
QT'=qq
r=rr
up to inconsequential sign differences.
0 new messages