PDA

View Full Version : detect singular matrix?



hcrisp
01-09-2012, 01:42 PM
Is there a way to detect if a square matrix is singular without causing an error or printing any message? I have tried using ON_ERROR to no avail. DET is no help either. Any help would be appreciated.

hcrisp
01-09-2012, 02:09 PM
I found a workaround, so nevermind unless there is a more elegant way.


!QUIET = 2
st = EXECUTE('rs = INV(A)')
; Now check the value of st

hcrisp
01-13-2012, 11:43 AM
Here's a better way:


a = [[1., 2], [1,2]]
a_inv = INVERT(a, st)
; Now check the value of st. You can't do this with INV()!

omega
05-23-2012, 08:10 AM
a = [[1., 2],[1,2]]
cmast_err_print, 0
cmast_err_stop, 0
ai = inv(a)
err = cmast_err_trans(!cmast_err)
print, err