From: "Tim Davis" <davis@cise.ufl.edu>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webcrossing
Newsgroups: comp.soft-sys.matlab
Subject: Re: Wishlist for R2007b
Message-ID: <ef57195.8@webcrossing.raydaftYaTP>
Date: Thu, 17 May 2007 14:35:58 -0400
References: <ef57195.-1@webcrossing.raydaftYaTP> <MPG.20b52ece5ac3d2e798973b@news.mathworks.com> <1179378005.215820.316490@u30g2000hsc.googlegroups.com>
Lines: 42
NNTP-Posting-Host: 70.171.50.145
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:409676



spasmous wrote:
...
> update all the legacy 'double only' functions and fully
> optimize the math operations: mixed real-complex multiplication,
> sparse complex...

MATLAB relies on the BLAS for its performance for dense matrix
operations (and it uses the BLAS for the x=A\b in the sparse case as
well). The BLAS are far faster than what mere mortals writing in
C/C++ can get, so using them is an imperative (i.e, the Intel MKL on
the Intel cpu's, the AMD has their own etc). Each BLAS is optimized
for that particular architecture.

However, the BLAS doesn't support mixed real/complex. It's either
all real or all complex. To do C=A*B when A is real and B is
complex, my guess is that MATLAB does (and this is purely a guess):

C = A*real(B) + 1i*A*imag(B)

since MATLAB stores its matrices with the real and imaginary parts in
different arrays (thus the "+" above doesn't really occur, neither
does the "1i*"). Then this would become two calls to DGEMM.

If The MathWorks does that, my guess is that that's as best it will
get. If they instead do C=A*B by coercing A into complex (appending
a complex part) then it would be slower than the above, I would
predict.

The BLAS stores complex matrices with real/imaginary values
interleaved. So in memory, the BLAS sees real(A(1,1)), imag(A(1,1)),
real(A(2,1)), imag(A(2,1)), etc. But MATLAB stores the real part of
A and the imaginary part of A in 2 different real arrays. So there
will often be a copy made when passing complex matrices to the BLAS,
and I doubt that will ever change.

I could say lots about how sparse complex should be done, but that's
another story and quite a long one at that ...

And, if I were The MathWorks (and I'm not so I know nothing), it's
unlikely I'd be adding new features to a release just a few months
away. So this thread should be entitled "wish list for R2008x"
instead.