Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: RQ decomposition
Date: Sat, 4 Oct 2008 19:57:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 26
Message-ID: <gc8hqd$9ja$1@fred.mathworks.com>
References: <gc82pk$e87$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1223150222 9834 172.30.248.35 (4 Oct 2008 19:57:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 4 Oct 2008 19:57:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:493632


"David Doria" <daviddoria@gmail.com> wrote in message <gc82pk$e87$1@fred.mathworks.com>...
> Is there an easy way to get an RQ decomposition from the included qr() function?


function [R Q]=rq(A)
% function [R Q]=rq(A)
% A [m x n] with m<=n
% return R [m x n] triangular and
% Q [n x n] unitary (i.e., Q'*Q=I)
% such that A=R*Q
% Author: Bruno Luong
% Last Update: 04/Oct/2008

[m n]=size(A);
if m>n
    error('RQ: Number of rows must be smaller than column');
end

[Q R]=qr(flipud(A).');
R=flipud(R.');
R(:,1:m)=R(:,m:-1:1);
Q=Q.';
Q(1:m,:)=Q(m:-1:1,:);

end
% Bruno