comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: failed matrix inversion returns input-- interesting
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: failed matrix inversion returns input-- interesting [message #49302] Fri, 14 July 2006 05:23
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
> Is there any reason in creation why IDL simply copies the input into
> the output if it cannot do the inversion? That seems, well, malevolent,
> unless I'm missing something.

One reason you might want this behaviour is to preserve the original
array, in cases where the code overwrites the inverse

IDL> testm = invert(testm, status)
IDL> if status EQ 1 then print,'Singular Matrix ', testm

If INVERT returned, say, NaN values or an undefined variable (the only
reasonable alternatives I think), then you would have lost the original
array

Incidentally, the LAPACK (LU Decomposition) invert routine LA_INVERT in
IDL has the same behavior. ---Wayne
Re: failed matrix inversion returns input-- interesting [message #49305 is a reply to message #49302] Fri, 14 July 2006 00:30 Go to previous message
mmeron is currently offline  mmeron
Messages: 44
Registered: October 2003
Member
In article <1152860961.931059.317520@35g2000cwc.googlegroups.com>, "m_schellens@hotmail.com" <m_schellens@hotmail.com> writes:
>
> Ed Hyer wrote:
>> Can someone explain this behavior?
>> IDL> testm=[[0,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
>> IDL> testmi=invert(testm,status)
>> IDL> print,status; 0=success, 1=fail, 2=pivot used
>> 1
>> IDL> print,testmi
>> 0.00000 0.00000 0.00000 0.00000
>> 0.00000 1.00000 0.00000 0.00000
>> 0.00000 0.00000 1.00000 0.00000
>> 0.00000 0.00000 0.00000 1.00000
>>
>> Is there any reason in creation why IDL simply copies the input into
>> the output if it cannot do the inversion? That seems, well, malevolent,
>> unless I'm missing something.
>
> Well, what do you suggest is better?
>
Well, nearly anything would be better.

I've a routine, called SVD_INVERT, which returns a regular inverse
when one exists, else it returns and inverse in the "SVD sense".
Would the IDL routine have been doing this, that would be fine (though
it should've been documented). But, it is not doing this either.
So IMO, it would've been preferable to return an array of NANs in such
case.

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
Re: failed matrix inversion returns input-- interesting [message #49307 is a reply to message #49305] Fri, 14 July 2006 00:14 Go to previous message
Bringfried Stecklum is currently offline  Bringfried Stecklum
Messages: 75
Registered: January 1996
Member
Ed Hyer wrote:
> Can someone explain this behavior?
> IDL> testm=[[0,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
> IDL> testmi=invert(testm,status)
> IDL> print,status; 0=success, 1=fail, 2=pivot used
> 1
> IDL> print,testmi
> 0.00000 0.00000 0.00000 0.00000
> 0.00000 1.00000 0.00000 0.00000
> 0.00000 0.00000 1.00000 0.00000
> 0.00000 0.00000 0.00000 1.00000
>
> Is there any reason in creation why IDL simply copies the input into
> the output if it cannot do the inversion? That seems, well, malevolent,
> unless I'm missing something.
>
I would not call this behavior malevolent. For a singular matrix the
inversion is invalid. So the result is meaningless anyway and it does
not matter whether IDL returns a fictious array or the input matrix.
When solving linear equations it is always recommended to check the
condition number of the matrix using cond and use singular value
decomposition in case of an ill-behaved matrix.

regards,

B.St.
  • Attachment: stecklum.vcf
    (Size: 0.20KB, Downloaded 101 times)
Re: failed matrix inversion returns input-- interesting [message #49309 is a reply to message #49307] Fri, 14 July 2006 00:09 Go to previous message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
Ed Hyer wrote:
> Can someone explain this behavior?
> IDL> testm=[[0,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
> IDL> testmi=invert(testm,status)
> IDL> print,status; 0=success, 1=fail, 2=pivot used
> 1
> IDL> print,testmi
> 0.00000 0.00000 0.00000 0.00000
> 0.00000 1.00000 0.00000 0.00000
> 0.00000 0.00000 1.00000 0.00000
> 0.00000 0.00000 0.00000 1.00000
>
> Is there any reason in creation why IDL simply copies the input into
> the output if it cannot do the inversion? That seems, well, malevolent,
> unless I'm missing something.

Well, what do you suggest is better?

Marc
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 6.3 for Mac OS X on Intel Now Available
Next Topic: Re: IDL and Macs. Speed is not only about squared roots

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:46:35 PDT 2025

Total time taken to generate the page: 0.00640 seconds