diff --git a/src/maths/KLU/klusmp.c b/src/maths/KLU/klusmp.c index 8d42591a0..3df9bd13f 100644 --- a/src/maths/KLU/klusmp.c +++ b/src/maths/KLU/klusmp.c @@ -568,6 +568,7 @@ SMPcReorder (SMPmatrix *Matrix, double PivTol, double PivRel, int *NumSwaps) } else { if (Matrix->CKTkluCommon->status == KLU_SINGULAR) { fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ; + return E_SINGULAR ; } return 0 ; } @@ -614,6 +615,7 @@ SMPreorder (SMPmatrix *Matrix, double PivTol, double PivRel, double Gmin) } else { if (Matrix->CKTkluCommon->status == KLU_SINGULAR) { fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ; + return E_SINGULAR ; } return 0 ; } @@ -673,6 +675,7 @@ SMPreorderKLUforCIDER (SMPmatrix *Matrix) } else { if (Matrix->CKTkluCommon->status == KLU_SINGULAR) { fprintf (stderr, "Warning (CIDER): KLU Matrix is SINGULAR\n") ; + return E_SINGULAR ; } return 0 ; } diff --git a/src/maths/ni/niiter.c b/src/maths/ni/niiter.c index 4979f0901..54181bb00 100644 --- a/src/maths/ni/niiter.c +++ b/src/maths/ni/niiter.c @@ -145,9 +145,20 @@ NIiter(CKTcircuit *ckt, int maxIter) SPfrontEnd->IFseconds() - startTime; if (error) { if (error == E_SINGULAR) { + +#ifdef KLU + error = SMPreorder(ckt->CKTmatrix, ckt->CKTpivotAbsTol, ckt->CKTpivotRelTol, ckt->CKTdiagGmin); + ckt->CKTstat->STATreorderTime += SPfrontEnd->IFseconds() - startTime; + if (error) { + SMPgetError(ckt->CKTmatrix, &i, &j); + SPfrontEnd->IFerrorf (ERR_WARNING, "singular matrix: check nodes %s and %s\n", NODENAME(ckt, i), NODENAME(ckt, j)); + } +#else ckt->CKTniState |= NISHOULDREORDER; DEBUGMSG(" forced reordering....\n"); continue; +#endif + } /* CKTload(ckt); */ /* SMPprint(ckt->CKTmatrix, stdout); */