devices/asrc, rewrite #8/10, cleanup and reorder

This commit is contained in:
rlar 2015-04-12 18:18:20 +02:00
parent 3a1c094682
commit 704e50b62a
1 changed files with 16 additions and 19 deletions

View File

@ -10,6 +10,13 @@ Author: 1987 Kanwar Jit Singh
#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
* pointers needed later for fast matrix loading
*/
@ -43,25 +50,6 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
if (!here->ASRCreciproctcGiven)
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) {
case ASRC_VOLTAGE:
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
in the vector of the positions of the SMP */
j = 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;
}
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch);
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCbranch);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCnegNode);