diff --git a/src/maths/KLU/klusmp.c b/src/maths/KLU/klusmp.c index 1725fc8da..8cb5cf0d9 100644 --- a/src/maths/KLU/klusmp.c +++ b/src/maths/KLU/klusmp.c @@ -996,6 +996,40 @@ LoadGmin (SMPmatrix *eMatrix, double Gmin) SMPelement * SMPfindElt (SMPmatrix *eMatrix, int Row, int Col, int CreateIfMissing) { + +#ifdef KLU + if (eMatrix->CKTkluMODE) { + int *Ai, *Ap, i ; + double *Ax ; + + Ai = eMatrix->CKTkluAi ; + Ap = eMatrix->CKTkluAp ; + Ax = eMatrix->CKTkluAx ; + + Row = eMatrix->SPmatrix->ExtToIntRowMap [Row] ; + Col = eMatrix->SPmatrix->ExtToIntColMap [Col] ; + + if ((Row > 0) && (Col > 0)) { + for (i = Ap [Col - 1] ; i < Ap [Col] ; i++) { + if (Ai [i] == Row - 1) { + return (SMPelement *)&(Ax [i]) ; + } + } + } + return NULL ; + } else { + MatrixPtr Matrix = eMatrix->SPmatrix ; + ElementPtr Element ; + + /* Begin `SMPfindElt'. */ + assert (IS_SPARSE (Matrix)) ; + Row = Matrix->ExtToIntRowMap [Row] ; + Col = Matrix->ExtToIntColMap [Col] ; + Element = Matrix->FirstInCol [Col] ; + Element = spcFindElementInCol (Matrix, &Element, Row, Col, CreateIfMissing) ; + return (SMPelement *)Element ; + } +#else MatrixPtr Matrix = eMatrix->SPmatrix ; ElementPtr Element ; @@ -1006,6 +1040,8 @@ SMPfindElt (SMPmatrix *eMatrix, int Row, int Col, int CreateIfMissing) Element = Matrix->FirstInCol [Col] ; Element = spcFindElementInCol (Matrix, &Element, Row, Col, CreateIfMissing) ; return (SMPelement *)Element ; +#endif + } /* XXX The following should probably be implemented in spUtils */ diff --git a/src/spicelib/analysis/cktic.c b/src/spicelib/analysis/cktic.c index ebf909568..611693297 100644 --- a/src/spicelib/analysis/cktic.c +++ b/src/spicelib/analysis/cktic.c @@ -25,15 +25,52 @@ CKTic(CKTcircuit *ckt) for(node = ckt->CKTnodes;node != NULL; node = node->next) { if(node->nsGiven) { + +#ifdef KLU + if (ckt->CKTmatrix->CKTkluMODE) { + if (node->number > 0) { + int i ; + + for (i = node->number - 1 ; i < node->number ; i++) { + if (ckt->CKTmatrix->CKTkluAi [i] == node->number - 1) { + node->ptr = &(ckt->CKTmatrix->CKTkluAx [i]) ; + } + } + } + } else { + node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,node->number); + } +#else node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,node->number); +#endif + if(node->ptr == NULL) return(E_NOMEM); ckt->CKThadNodeset = 1; ckt->CKTrhs[node->number] = node->nodeset; } if(node->icGiven) { if(! ( node->ptr)) { + +#ifdef KLU + if (ckt->CKTmatrix->CKTkluMODE) { + if (node->number > 0) { + int i ; + + for (i = node->number - 1 ; i < node->number ; i++) { + if (ckt->CKTmatrix->CKTkluAi [i] == node->number - 1) { + node->ptr = &(ckt->CKTmatrix->CKTkluAx [i]) ; + } + } + } + } else { + node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number, + node->number); + } +#else node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number, node->number); +#endif + if(node->ptr == NULL) return(E_NOMEM); } ckt->CKTrhs[node->number] = node->ic;