diagonal & permutation matrices

David Bateman dbateman at dbateman.org
Sun Nov 16 16:34:58 CST 2008


Jaroslav Hajek wrote:
> On Sun, Nov 16, 2008 at 3:53 PM, David Bateman <dbateman at dbateman.org> 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                                dbateman at dbateman.org
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)


More information about the Octave-maintainers mailing list