PSS Fix: thanks to Marcel Hendrix, a possible bug has been found for division by 0

This commit is contained in:
Francesco Lannutti
2016-02-13 19:33:29 +01:00
parent 72d7bb9c8a
commit 02b7fc950e
+5 -1
View File
@@ -744,7 +744,11 @@ DCpss(CKTcircuit *ckt,
{ {
/* Pitagora ha sempre ragione!!! :))) */ /* Pitagora ha sempre ragione!!! :))) */
/* pred is treated as FREQUENCY to avoid numerical overflow when derivative is close to ZERO */ /* pred is treated as FREQUENCY to avoid numerical overflow when derivative is close to ZERO */
pred [i] = RHS_derivative [i] / err_conv [i] ; if ((RHS_derivative [i] != 0) && (err_conv [i] == 0)) {
pred [i] = DBL_MAX ;
} else {
pred [i] = RHS_derivative [i] / err_conv [i] ;
}
#ifdef STEPDEBUG #ifdef STEPDEBUG
fprintf (stderr, "Pred is so high or so low! Diff is: %g\n", err_conv [i]) ; fprintf (stderr, "Pred is so high or so low! Diff is: %g\n", err_conv [i]) ;