Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving AM = MB
Date: Wed, 15 Oct 2008 00:45:03 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 37
Message-ID: <gd3eef$gs$1@fred.mathworks.com>
References: <gd34pk$csc$1@fred.mathworks.com> <gd36qn$sl9$1@fred.mathworks.com> <gd38sd$eb9$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1224031503 540 172.30.248.38 (15 Oct 2008 00:45:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 15 Oct 2008 00:45:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:495205


"David Doria" <daviddoria@gmail.com> wrote in message <gd38sd$eb9$1@fred.mathworks.com>...
> So I was looking to solve
> AM = MB 
> 
> And abba.m solves
> AB = BA
> 
> which is slightly different, because there are only 2 matrices A and B, instead of A,B, and M.
> 
> I was a victim of your comment "% have fun with this next line...". I read the

Oh, heck. Victim? Thats a bit extreme. 8-)
Think of it as mathematical character building.


> help for kron() but I have no background with tensors.  Could you give a couple line explanation of what that is doing? I can't modify your code to fit this problem because I don't know what that line does, and it seems to be about the whole thing!!


Yes, I'll admit that kron line is a bit crucial
to do it efficiently. It is slick though, you
gotta admit. The null call is also important.

If a solution exists, then it should take no
more than a small change. If the call to
null produces an empty matrix, then no
solution exists. Assuming that n = size(A,1),
it can be compressed into only one line.

M = reshape(mean(null(kron(eye(n),A) - ...
     kron(B',eye(n))),2),n,n);

I just have to add, "have fun with that line."
Don't ask me why, the devil on my shoulder
made me sat that. ;-)

John