devices/asrc, rewrite #8/10, cleanup and reorder
This commit is contained in:
parent
3a1c094682
commit
704e50b62a
|
|
@ -10,6 +10,13 @@ Author: 1987 Kanwar Jit Singh
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define TSTALLOC(ptr, first, second) \
|
||||||
|
do { \
|
||||||
|
if ((here->ptr = SMPmakeElt(matrix, first, second)) == NULL) \
|
||||||
|
return(E_NOMEM); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
/* load the voltage source structure with those
|
/* load the voltage source structure with those
|
||||||
* pointers needed later for fast matrix loading
|
* pointers needed later for fast matrix loading
|
||||||
*/
|
*/
|
||||||
|
|
@ -43,25 +50,6 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
if (!here->ASRCreciproctcGiven)
|
if (!here->ASRCreciproctcGiven)
|
||||||
here->ASRCreciproctc = 0;
|
here->ASRCreciproctc = 0;
|
||||||
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE)
|
|
||||||
if (here->ASRCbranch == 0) {
|
|
||||||
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch");
|
|
||||||
if (error)
|
|
||||||
return(error);
|
|
||||||
here->ASRCbranch = tmp->number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* macro to make elements with built in test for out of memory */
|
|
||||||
#define TSTALLOC(ptr, first, second) \
|
|
||||||
do { if ((here->ptr = SMPmakeElt(matrix, first, second)) == NULL) { \
|
|
||||||
return(E_NOMEM); \
|
|
||||||
} } while(0)
|
|
||||||
|
|
||||||
#define MY_TSTALLOC(ptr, first, second) \
|
|
||||||
do { if ((here->ptr = SMPmakeElt(matrix, here->first, (second)->number)) == NULL) { \
|
|
||||||
return(E_NOMEM); \
|
|
||||||
} } while(0)
|
|
||||||
|
|
||||||
switch (here->ASRCtype) {
|
switch (here->ASRCtype) {
|
||||||
case ASRC_VOLTAGE:
|
case ASRC_VOLTAGE:
|
||||||
j = 4 + here->ASRCtree->numVars;
|
j = 4 + here->ASRCtree->numVars;
|
||||||
|
|
@ -77,9 +65,18 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
|
|
||||||
/* For each controlling variable set the entries
|
/* For each controlling variable set the entries
|
||||||
in the vector of the positions of the SMP */
|
in the vector of the positions of the SMP */
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
|
|
||||||
|
if (here->ASRCbranch == 0) {
|
||||||
|
error = CKTmkCur(ckt, &tmp, here->ASRCname, "branch");
|
||||||
|
if (error)
|
||||||
|
return(error);
|
||||||
|
here->ASRCbranch = tmp->number;
|
||||||
|
}
|
||||||
|
|
||||||
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch);
|
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch);
|
||||||
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCbranch);
|
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCbranch);
|
||||||
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCnegNode);
|
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCnegNode);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue