Browse Source

devices/asrc, rewrite #5/10, combine common code

pre-master-46
rlar 11 years ago
parent
commit
1c53a425f0
  1. 38
      src/spicelib/devices/asrc/asrcset.c

38
src/spicelib/devices/asrc/asrcset.c

@ -87,33 +87,23 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->ASRCname, here->ASRCtree->vars[i].uValue);
return(E_BADPARM);
}
if (here->ASRCtype == ASRC_VOLTAGE) {
/* CCVS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, column);
} else if (here->ASRCtype == ASRC_CURRENT) {
/* CCCS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, column);
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, column);
} else {
return (E_BADPARM);
}
break;
case IF_NODE:
column = here->ASRCtree->vars[i].nValue->number;
if (here->ASRCtype == ASRC_VOLTAGE) {
/* VCVS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, column);
} else if (here->ASRCtype == ASRC_CURRENT) {
/* VCCS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, column);
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, column);
} else {
return (E_BADPARM);
}
break;
default:
return (E_BADPARM);
}
switch (here->ASRCtype) {
case ASRC_VOLTAGE:
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, column);
break;
case ASRC_CURRENT:
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, column);
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, column);
break;
default:
return (E_BADPARM);

Loading…
Cancel
Save