octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: diagonal & permutation matrices


From: David Bateman
Subject: Re: diagonal & permutation matrices
Date: Sun, 16 Nov 2008 23:34:58 +0100
User-agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018)

Jaroslav Hajek wrote:
On Sun, Nov 16, 2008 at 3:53 PM, David Bateman <address@hidden> wrote:
Isn't this why Matlab added the 'vector' option to functions like QR?

Yes, apparently. That was the "quick and lazy" solution.

Then
you replace the matrix multiplication with a matrix index operation. If you
prefer to keep the matrix multiply syntax, then why not just make P a sparse
matrix, whose matrix multiplication should be relatively fast.

Well, it will be still slower than indexing, though at least O(N^2)
and not O(N^3).
The inconvenience is that instead of the natural syntax `[l,u,p] =
lu(a)', you need to do [l,u,p] = lu(a,"vector"); p = speye(n)(p,:)`,
i.e. the default, well readable syntax is useless if you don't ignore
performance.
IMHO, functions like diag, eye, and the 3rd output args of lu and qr
should have always returned sparse matrices (because diagonal and
permutation matrices *are* quite sparse). It's another place where
Matlab compatibility is a pain in the ass.
I always disliked the fact that expressions like diag(x)*y are, in
fact, to be avoided in library functions. Using spdiag(x)*y is almost
always much better.

Sigh.... Well, its another argument of where we draw the line with matlab compatibility.. We need to take care that any changes you make don't have unexpected consequences for compatibility.

Cheers
David

--
David Bateman                                address@hidden
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]