octave-maintainers
[Top][All Lists]
Advanced

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

Re: diagonal & permutation matrices


From: Jaroslav Hajek
Subject: Re: diagonal & permutation matrices
Date: Mon, 17 Nov 2008 12:18:16 +0100

On Sun, Nov 16, 2008 at 11:34 PM, David Bateman <address@hidden> wrote:
> 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
>

Oh, no no. Though I think my arguments are good, I'm going to put this
off unless more people vote for it. After all, it's just a
performance/cosmetic feature.
I guess I can just get used to writing "spdiag(D) * A" instead of
"diag(D) * A" and to always use lu and qr with the "vector" argument,
although it's ugly.


> --
> 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)
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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