[Fwd: Singular Matrix Invert]


Sender: do_not_reply_to_this_address@t-online.de (hunniger)
Subject: Singular Matrix Invert


I receive a RuntimeException, whenever a Matrix is Singular, carrying a 
text message, that say. "Matrix si singular.". This is Ok. It is very 
good that it is a runtime exception and not a checked exception, but it 
would be better if it was a SingularMatrixException, that is derived 
from RuntimeException
, because I can catch this exception in a specific way, that is without 
catching anything else.

So currently I got

       try {
           step();
       }
       catch (RuntimeException r) {
           System.out.println(error());
           if (r.getMessage().equals("Matrix is singular.")) {
               for (Variable v:variables) {
                   v.value+=0.001*Math.random();
               }
           }
           else {
               throw r;
           }
       }


but I would like to have


       try {
           step();
       }
       catch (SingularMatrixException r) {
           System.out.println(error());
           for (Variable v:variables) {
                v.value+=0.001*Math.random();
           }
       }


because not you can change the string "Matrix is singular." to anything 
you like and I don't need to change my code.

Yours Dirk






Date Index | Thread Index | Problems or questions? Contact list-master@nist.gov