Re: failed matrix inversion returns input-- interesting [message #49302] |
Fri, 14 July 2006 05:23 |
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  |
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  |
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  |
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
|
|
|