> Hi guys:
> I am trying to use "try catch" to find a singular matrix and then take
> inverse of non-singular matrix!
Error-handling stuff like divide-by-zero signals, interrupts and
don't work very well as substitutes for control loops. I remember
to used the divide-by-zero signal to catch the x==0 case in a sin(x)/x
expression, to avoid the test 'if x==0' for every single element.
It turned out to be a very bad idea. First, it detected that *a*
computation had been a divide-by-zero, but no information about
*which*one* was kept at a useful place, as the OS got into
And even if you could get that, there was no way of knowing
where to resume computations afterwards. Keeping track of
how many computations had been done, how many remained,
and so on, turned out to be a nightmare. It was far easier to
use the familiar 'if x==0' test.
Basically, try-catch for numerical problems are ways to detect
(and handle) the numerical problems you did not foresee while
programming. If your program throws an exception, you have to
analyze what happened and see if there was some sort of
"anormal" feature somewhere that you as programmer forgot
to account for the first time around.