Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <brunoluong@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving Equation
Date: Fri, 23 Nov 2007 08:29:57 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 19
Message-ID: <fi6325$qr6$1@fred.mathworks.com>
References: <d2ea35f2-b295-4b24-a58f-4aa7bf3359ae@s8g2000prg.googlegroups.com> <fi6181$8dm$1@fred.mathworks.com> <fi62a9$jat$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <brunoluong@yahoo.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1195806597 27494 172.30.248.37 (23 Nov 2007 08:29:57 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 23 Nov 2007 08:29:57 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1184112
Xref: news.mathworks.com comp.soft-sys.matlab:438985


Why I bother to symmetrize input Q? Here is the program for
general Q:

n=5; % dimension

% Input
M=rand(n);
Q=rand(n)

% Solve
Mnlist=cell(1,n);
Mnlist(:)={M};
BIGM1=blkdiag(Mnlist{:});
BIGM2=reshape(permute(reshape(BIGM1,n,n,n,n),[2 1 4
3]),n*n,n*n);
X=reshape((eye(n*n)-BIGM1*BIGM2)\Q(:),n,n)

% Check
X - M*X*M'