Merge branch 'pre-master-45' into bt_dev
This commit is contained in:
commit
e7a7e8c64c
|
|
@ -5156,10 +5156,10 @@ static int inp_get_param_level(
|
|||
the first letter of its instance line. Returns 0 upon error. */
|
||||
int get_number_terminals(char *c)
|
||||
{
|
||||
int i, j, k;
|
||||
int i, j, k;
|
||||
char *inst;
|
||||
char *name[12];
|
||||
char nam_buf[128];
|
||||
bool area_found = FALSE;
|
||||
bool area_found = FALSE;
|
||||
|
||||
if (!c)
|
||||
return 0;
|
||||
|
|
@ -5181,28 +5181,31 @@ int get_number_terminals(char *c)
|
|||
but still allow self heating diode with ngspice syntax. */
|
||||
if (newcompat.ps && !search_plain_identifier(c, "thermal"))
|
||||
return 2;
|
||||
i = 0;
|
||||
|
||||
/* find the first token with "off" or "=" in the line*/
|
||||
while ((i < 10) && (*c != '\0')) {
|
||||
char *inst = gettok_instance(&c);
|
||||
strncpy(nam_buf, inst, sizeof(nam_buf) - 1);
|
||||
txfree(inst);
|
||||
if ( i > 3 && (search_plain_identifier(nam_buf, "off") || search_plain_identifier(nam_buf, "thermal") || strchr(nam_buf, '=')))
|
||||
for (i = 0; (i < 10) && (*c != '\0'); ++i) {
|
||||
inst = gettok_instance(&c);
|
||||
if (i > 3 && (search_plain_identifier(inst, "off") ||
|
||||
search_plain_identifier(inst, "thermal") ||
|
||||
strchr(inst, '='))) {
|
||||
txfree(inst);
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
txfree(inst);
|
||||
}
|
||||
return i - 2;
|
||||
break;
|
||||
case 'x':
|
||||
i = 0;
|
||||
/* find the first token with "params:" or "=" in the line*/
|
||||
while ((i < 100) && (*c != '\0')) {
|
||||
char *inst = gettok_instance(&c);
|
||||
strncpy(nam_buf, inst, sizeof(nam_buf) - 1);
|
||||
txfree(inst);
|
||||
if (search_plain_identifier(nam_buf, "params:") || strchr(nam_buf, '='))
|
||||
|
||||
for (i = 0; (i < 100) && (*c != '\0'); ++i) {
|
||||
inst = gettok_instance(&c);
|
||||
if (search_plain_identifier(inst, "params:") ||
|
||||
strchr(inst, '=')) {
|
||||
txfree(inst);
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
txfree(inst);
|
||||
}
|
||||
return i - 2;
|
||||
break;
|
||||
|
|
@ -5223,34 +5226,34 @@ int get_number_terminals(char *c)
|
|||
case 'm': /* recognition of 4, 5, 6, or 7 nodes for SOI devices needed
|
||||
*/
|
||||
{
|
||||
i = 0;
|
||||
char* cc, * ccfree;
|
||||
|
||||
cc = copy(c);
|
||||
/* required to make m= 1 a single token m=1 */
|
||||
ccfree = cc = inp_remove_ws(cc);
|
||||
/* find the first token with "off", "tnodeout", "thermal" or "=" in the line*/
|
||||
while ((i < 20) && (*cc != '\0')) {
|
||||
char* inst = gettok_instance(&cc);
|
||||
strncpy(nam_buf, inst, sizeof(nam_buf) - 1);
|
||||
txfree(inst);
|
||||
if ( i > 4 && (search_plain_identifier(nam_buf, "off") || strchr(nam_buf, '=') ||
|
||||
search_plain_identifier(nam_buf, "tnodeout") || search_plain_identifier(nam_buf, "thermal")))
|
||||
for (i = 0; (i < 20) && (*cc != '\0'); ++i) {
|
||||
inst = gettok_instance(&cc);
|
||||
if ( i > 4 &&
|
||||
(search_plain_identifier(inst, "off") ||
|
||||
strchr(inst, '=') ||
|
||||
search_plain_identifier(inst, "tnodeout") ||
|
||||
search_plain_identifier(inst, "thermal"))) {
|
||||
txfree(inst);
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
txfree(inst);
|
||||
}
|
||||
tfree(ccfree);
|
||||
return i - 2;
|
||||
break;
|
||||
}
|
||||
case 'p': /* recognition of up to 100 cpl nodes */
|
||||
i = j = 0;
|
||||
/* find the last token in the line*/
|
||||
while ((i < 100) && (*c != '\0')) {
|
||||
char *tmp_inst = gettok_instance(&c);
|
||||
strncpy(nam_buf, tmp_inst, 32);
|
||||
tfree(tmp_inst);
|
||||
if (strchr(nam_buf, '='))
|
||||
case 'p': /* Recognition of up to 100 cpl nodes */
|
||||
for (i = j = 0; (i < 100) && (*c != '\0'); ++i) {
|
||||
inst = gettok_instance(&c);
|
||||
if (strchr(inst, '='))
|
||||
j++;
|
||||
tfree(inst);
|
||||
i++;
|
||||
}
|
||||
if (i == 100)
|
||||
|
|
@ -5263,21 +5266,27 @@ int get_number_terminals(char *c)
|
|||
/* 12 tokens maximum */
|
||||
{
|
||||
char* cc, * ccfree;
|
||||
i = j = 0;
|
||||
|
||||
cc = copy(c);
|
||||
/* required to make m= 1 a single token m=1 */
|
||||
ccfree = cc = inp_remove_ws(cc);
|
||||
while ((i < 12) && (*cc != '\0')) {
|
||||
for (i = j = 0; (i < 12) && (*cc != '\0'); ++i) {
|
||||
char* comma;
|
||||
|
||||
name[i] = gettok_instance(&cc);
|
||||
if (search_plain_identifier(name[i], "off") || strchr(name[i], '='))
|
||||
if (search_plain_identifier(name[i], "off") ||
|
||||
strchr(name[i], '=')) {
|
||||
j++;
|
||||
}
|
||||
#ifdef CIDER
|
||||
if (search_plain_identifier(name[i], "save") || search_plain_identifier(name[i], "print"))
|
||||
if (search_plain_identifier(name[i], "save") ||
|
||||
search_plain_identifier(name[i], "print")) {
|
||||
j++;
|
||||
}
|
||||
#endif
|
||||
/* If we have IC=VBE, VCE instead of IC=VBE,VCE we need to inc
|
||||
* j */
|
||||
/* If we have IC=VBE, VCE instead of IC=VBE,VCE
|
||||
* we need to increment j.
|
||||
*/
|
||||
if ((comma = strchr(name[i], ',')) != NULL &&
|
||||
(*(++comma) == '\0'))
|
||||
j++;
|
||||
|
|
@ -5285,14 +5294,14 @@ int get_number_terminals(char *c)
|
|||
*/
|
||||
if (eq(name[i], ","))
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
tfree(ccfree);
|
||||
i--;
|
||||
tfree(ccfree);
|
||||
area_found = FALSE;
|
||||
for (k = i; k > i - j - 1; k--) {
|
||||
bool only_digits = TRUE;
|
||||
char* nametmp = name[k];
|
||||
|
||||
/* MNAME has to contain at least one alpha character. AREA may
|
||||
be assumed if we have a token with only digits, and where
|
||||
the previous token does not end with a ',' */
|
||||
|
|
@ -5315,26 +5324,21 @@ int get_number_terminals(char *c)
|
|||
break;
|
||||
}
|
||||
#ifdef OSDI
|
||||
case 'n': /* Recognize an unknown number of nodes by stopping at tokens with '=' */
|
||||
{
|
||||
i = 0;
|
||||
char* cc, * ccfree;
|
||||
cc = copy(c);
|
||||
/* required to make m= 1 a single token m=1 */
|
||||
ccfree = cc = inp_remove_ws(cc);
|
||||
/* find the first token with "off", "tnodeout", "thermal" or "=" in the line*/
|
||||
while ((i < 20) && (*cc != '\0')) {
|
||||
char* inst = gettok_instance(&cc);
|
||||
strncpy(nam_buf, inst, sizeof(nam_buf) - 1);
|
||||
txfree(inst);
|
||||
if (i > 2 && (strchr(nam_buf, '=')))
|
||||
case 'n':
|
||||
/* Find the last non-parameter token in the line. */
|
||||
|
||||
for (i = 0; *c != '\0' && *c != '='; ++i) {
|
||||
inst = gettok_instance(&c);
|
||||
if (strchr(inst, '=')) {
|
||||
tfree(inst);
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
tfree(inst);
|
||||
}
|
||||
tfree(ccfree);
|
||||
if (*c == '=')
|
||||
--i; // Counted a parameter name.
|
||||
return i - 2;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -868,7 +868,6 @@ static int iplot(struct plot *pl, struct dbcomm *db)
|
|||
bool changed = FALSE;
|
||||
int id, yt;
|
||||
double xlims[2], ylims[2];
|
||||
static REQUEST reqst = { checkup_option, NULL };
|
||||
int inited = 0;
|
||||
int n_vec_plot = 0;
|
||||
|
||||
|
|
@ -958,16 +957,12 @@ static int iplot(struct plot *pl, struct dbcomm *db)
|
|||
inited = 1;
|
||||
|
||||
} else {
|
||||
/* plot the last points and resize if needed */
|
||||
|
||||
Input(&reqst, NULL);
|
||||
|
||||
/* Window was closed? */
|
||||
|
||||
if (!currentgraph)
|
||||
if (!currentgraph) /* Window was closed? */
|
||||
return 0;
|
||||
|
||||
/* First see if we have to make the screen bigger */
|
||||
/* Plot the latest points and resize if needed.
|
||||
* First see if we have to make the screen bigger.
|
||||
*/
|
||||
|
||||
dy = (isreal(xs) ? xs->v_realdata[len - 1] :
|
||||
realpart(xs->v_compdata[len - 1]));
|
||||
|
|
@ -1194,9 +1189,16 @@ void reset_trace(void)
|
|||
|
||||
void gr_iplot(struct plot *plot)
|
||||
{
|
||||
struct dbcomm *db;
|
||||
int dontpop; /* So we don't pop w/o push. */
|
||||
char buf[30];
|
||||
static REQUEST reqst = { checkup_option, NULL };
|
||||
struct dbcomm *db, *dc;
|
||||
int dontpop; /* So we don't pop w/o push. */
|
||||
char buf[30];
|
||||
|
||||
if (Have_graph) {
|
||||
/* There is at least one graph. Process input on graph windows. */
|
||||
|
||||
Input(&reqst, NULL);
|
||||
}
|
||||
|
||||
hit = 0;
|
||||
for (db = dbs; db; db = db->db_next) {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ typedef struct gbucket {
|
|||
|
||||
static GBUCKET GBucket[NUMGBUCKETS];
|
||||
|
||||
/* Global variable to indicate that at least one graph exits. Ugly but fast. */
|
||||
|
||||
bool Have_graph;
|
||||
|
||||
/* note: Zero is not a valid id. This is used in plot() in graf.c. */
|
||||
static int RunningId = 1;
|
||||
|
||||
|
|
@ -81,7 +85,7 @@ GRAPH *NewGraph(void)
|
|||
}
|
||||
|
||||
RunningId++;
|
||||
|
||||
Have_graph = TRUE;
|
||||
return pgraph;
|
||||
} /* end of function NewGraph */
|
||||
|
||||
|
|
@ -108,7 +112,6 @@ GRAPH *FindGraph(int id)
|
|||
} /* end of function FindGraph */
|
||||
|
||||
|
||||
|
||||
GRAPH *CopyGraph(GRAPH *graph)
|
||||
{
|
||||
GRAPH *ret;
|
||||
|
|
@ -235,7 +238,15 @@ int DestroyGraph(int id)
|
|||
lastlist->next = list->next;
|
||||
}
|
||||
else { /* at front */
|
||||
int i;
|
||||
|
||||
GBucket[index].list = list->next;
|
||||
for (i = 0; i < NUMGBUCKETS; ++i) {
|
||||
if (GBucket[i].list)
|
||||
break;
|
||||
}
|
||||
if (i >= NUMGBUCKETS)
|
||||
Have_graph = FALSE;
|
||||
}
|
||||
|
||||
/* Run through and de-allocate dynamically allocated keyed list */
|
||||
|
|
@ -307,6 +318,7 @@ void FreeGraphs(void)
|
|||
txfree(deadl);
|
||||
}
|
||||
}
|
||||
Have_graph = FALSE;
|
||||
} /* end of functdion FreeGraphs */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,7 @@ void SetGraphContext(int graphid);
|
|||
void PushGraphContext(GRAPH *graph);
|
||||
void PopGraphContext(void);
|
||||
|
||||
/* Global variable to indicate that at least one graph exits. Ugly but fast. */
|
||||
|
||||
extern bool Have_graph;
|
||||
#endif
|
||||
|
|
|
|||
27
src/main.c
27
src/main.c
|
|
@ -1252,11 +1252,30 @@ int main(int argc, char **argv)
|
|||
else {
|
||||
if (readinit) {
|
||||
/* load user's initialisation file
|
||||
try accessing the initialisation file .spiceinit in a user provided
|
||||
path read from environmental variable SPICE_USERINIT_DIR,
|
||||
if that fails try the alternate name spice.rc, then look into
|
||||
the current directory, then the HOME directory, then into USERPROFILE */
|
||||
try accessing the initialisation file .spiceinit
|
||||
(If it fails, try the alternate name spice.rc):
|
||||
- in the directory from where the netlist has been loaded
|
||||
- in a user provided path read from environmental variable SPICE_USERINIT_DIR,
|
||||
- in the current directory,
|
||||
- in the the HOME directory,
|
||||
- in the USERPROFILE directory. */
|
||||
do {
|
||||
{
|
||||
if (optind <= argc) {
|
||||
char* inpath = ngdirname(argv[optind]);
|
||||
if (inpath) {
|
||||
if (read_initialisation_file(inpath, INITSTR) != FALSE) {
|
||||
FREE(inpath);
|
||||
break;
|
||||
}
|
||||
if (read_initialisation_file(inpath, ALT_INITSTR) != FALSE) {
|
||||
FREE(inpath);
|
||||
break;
|
||||
}
|
||||
FREE(inpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
const char* const userinit = getenv("SPICE_USERINIT_DIR");
|
||||
if (userinit) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Function declarations
|
||||
*/
|
||||
|
|
@ -78,7 +77,6 @@ static void ExpandTranslationArrays( MatrixPtr, int );
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CLEAR MATRIX
|
||||
*
|
||||
|
|
@ -105,28 +103,28 @@ spClear(MatrixPtr Matrix)
|
|||
/* Clear matrix. */
|
||||
if (Matrix->PreviousMatrixWasComplex || Matrix->Complex)
|
||||
{
|
||||
for (I = Matrix->Size; I > 0; I--)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
pElement->Real = 0.0;
|
||||
pElement->Imag = 0.0;
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
}
|
||||
for (I = Matrix->Size; I > 0; I--)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
pElement->Real = 0.0;
|
||||
pElement->Imag = 0.0;
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (I = Matrix->Size; I > 0; I--)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
pElement->Real = 0.0;
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
}
|
||||
for (I = Matrix->Size; I > 0; I--)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
pElement->Real = 0.0;
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Empty the trash. */
|
||||
|
|
@ -225,7 +223,6 @@ ElementPtr pElement;
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* SINGLE ELEMENT ADDITION TO MATRIX BY INDEX
|
||||
*
|
||||
|
|
@ -270,7 +267,7 @@ spGetElement(MatrixPtr Matrix, int Row, int Col)
|
|||
assert( IS_SPARSE( Matrix ) && Row >= 0 && Col >= 0 );
|
||||
|
||||
if ((Row == 0) || (Col == 0))
|
||||
return &Matrix->TrashCan.Real;
|
||||
return &Matrix->TrashCan.Real;
|
||||
|
||||
#if !TRANSLATE
|
||||
assert(Matrix->NeedsOrdering);
|
||||
|
|
@ -289,8 +286,9 @@ spGetElement(MatrixPtr Matrix, int Row, int Col)
|
|||
#if EXPANDABLE
|
||||
/* Re-size Matrix if necessary. */
|
||||
if ((Row > Matrix->Size) || (Col > Matrix->Size))
|
||||
EnlargeMatrix( Matrix, MAX(Row, Col) );
|
||||
if (Matrix->Error == spNO_MEMORY) return NULL;
|
||||
EnlargeMatrix( Matrix, MAX(Row, Col) );
|
||||
if (Matrix->Error == spNO_MEMORY)
|
||||
return NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -305,12 +303,12 @@ spGetElement(MatrixPtr Matrix, int Row, int Col)
|
|||
|
||||
if ((Row != Col) || ((pElement = Matrix->Diag[Row]) == NULL))
|
||||
{
|
||||
/* Element does not exist or does not reside along diagonal.
|
||||
* Search column for element. As in the if statement above,
|
||||
* the pointer to the element which is returned by
|
||||
* spcFindElementInCol is cast into a pointer to Real, a
|
||||
* RealNumber. */
|
||||
pElement = spcFindElementInCol( Matrix,
|
||||
/* Element does not exist or does not reside along diagonal.
|
||||
* Search column for element. As in the if statement above,
|
||||
* the pointer to the element which is returned by
|
||||
* spcFindElementInCol is cast into a pointer to Real, a
|
||||
* RealNumber. */
|
||||
pElement = spcFindElementInCol( Matrix,
|
||||
&(Matrix->FirstInCol[Col]),
|
||||
Row, Col, YES );
|
||||
}
|
||||
|
|
@ -321,12 +319,6 @@ spGetElement(MatrixPtr Matrix, int Row, int Col)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* FIND ELEMENT BY SEARCHING COLUMN
|
||||
*
|
||||
|
|
@ -371,36 +363,33 @@ spcFindElementInCol(MatrixPtr Matrix, ElementPtr *LastAddr,
|
|||
/* Search for element. */
|
||||
while (pElement != NULL)
|
||||
{
|
||||
if (pElement->Row < Row)
|
||||
if (pElement->Row < Row)
|
||||
{
|
||||
/* Have not reached element yet. */
|
||||
LastAddr = &(pElement->NextInCol);
|
||||
pElement = pElement->NextInCol;
|
||||
/* Have not reached element yet. */
|
||||
LastAddr = &(pElement->NextInCol);
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
else if (pElement->Row == Row)
|
||||
else if (pElement->Row == Row)
|
||||
{
|
||||
/* Reached element. */
|
||||
return pElement;
|
||||
/* Reached element. */
|
||||
return pElement;
|
||||
}
|
||||
else break; /* while loop */
|
||||
else break; /* while loop */
|
||||
}
|
||||
|
||||
/* Element does not exist and must be created. */
|
||||
if (CreateIfMissing)
|
||||
return spcCreateElement( Matrix, Row, Col, LastAddr, NO );
|
||||
return spcCreateElement( Matrix, Row, Col, LastAddr, NO );
|
||||
else
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if TRANSLATE
|
||||
|
||||
|
||||
/*
|
||||
* TRANSLATE EXTERNAL INDICES TO INTERNAL
|
||||
*
|
||||
|
|
@ -457,7 +446,7 @@ Translate(MatrixPtr Matrix, int *Row, int *Col)
|
|||
/* Translate external row or node number to internal row or node number. */
|
||||
if ((IntRow = Matrix->ExtToIntRowMap[ExtRow]) == -1)
|
||||
{
|
||||
Matrix->ExtToIntRowMap[ExtRow] = ++Matrix->CurrentSize;
|
||||
Matrix->ExtToIntRowMap[ExtRow] = ++Matrix->CurrentSize;
|
||||
Matrix->ExtToIntColMap[ExtRow] = Matrix->CurrentSize;
|
||||
IntRow = Matrix->CurrentSize;
|
||||
|
||||
|
|
@ -466,7 +455,7 @@ Translate(MatrixPtr Matrix, int *Row, int *Col)
|
|||
#endif
|
||||
|
||||
#if EXPANDABLE
|
||||
/* Re-size Matrix if necessary. */
|
||||
/* Re-size Matrix if necessary. */
|
||||
if (IntRow > Matrix->Size)
|
||||
EnlargeMatrix( Matrix, IntRow );
|
||||
if (Matrix->Error == spNO_MEMORY) return;
|
||||
|
|
@ -479,7 +468,7 @@ Translate(MatrixPtr Matrix, int *Row, int *Col)
|
|||
/* Translate external column or node number to internal column or node number.*/
|
||||
if ((IntCol = Matrix->ExtToIntColMap[ExtCol]) == -1)
|
||||
{
|
||||
Matrix->ExtToIntRowMap[ExtCol] = ++Matrix->CurrentSize;
|
||||
Matrix->ExtToIntRowMap[ExtCol] = ++Matrix->CurrentSize;
|
||||
Matrix->ExtToIntColMap[ExtCol] = Matrix->CurrentSize;
|
||||
IntCol = Matrix->CurrentSize;
|
||||
|
||||
|
|
@ -488,7 +477,7 @@ Translate(MatrixPtr Matrix, int *Row, int *Col)
|
|||
#endif
|
||||
|
||||
#if EXPANDABLE
|
||||
/* Re-size Matrix if necessary. */
|
||||
/* Re-size Matrix if necessary. */
|
||||
if (IntCol > Matrix->Size)
|
||||
EnlargeMatrix( Matrix, IntCol );
|
||||
if (Matrix->Error == spNO_MEMORY) return;
|
||||
|
|
@ -508,7 +497,6 @@ Translate(MatrixPtr Matrix, int *Row, int *Col)
|
|||
|
||||
|
||||
|
||||
|
||||
#if QUAD_ELEMENT
|
||||
/*
|
||||
* ADDITION OF ADMITTANCE TO MATRIX BY INDEX
|
||||
|
|
@ -573,7 +561,6 @@ spGetAdmittance(MatrixPtr Matrix, int Node1, int Node2,
|
|||
|
||||
|
||||
|
||||
|
||||
#if QUAD_ELEMENT
|
||||
/*
|
||||
* ADDITION OF FOUR ELEMENTS TO MATRIX BY INDEX
|
||||
|
|
@ -656,7 +643,6 @@ spGetQuad(MatrixPtr Matrix, int Row1, int Row2, int Col1, int Col2,
|
|||
|
||||
|
||||
|
||||
|
||||
#if QUAD_ELEMENT
|
||||
/*
|
||||
* ADDITION OF FOUR STRUCTURAL ONES TO MATRIX BY INDEX
|
||||
|
|
@ -723,7 +709,6 @@ spGetOnes(MatrixPtr Matrix, int Pos, int Neg, int Eqn,
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* CREATE AND SPLICE ELEMENT INTO MATRIX
|
||||
|
|
@ -778,21 +763,22 @@ spcCreateElement(MatrixPtr Matrix, int Row, int Col,
|
|||
/* Row pointers cannot be ignored. */
|
||||
if (Fillin)
|
||||
{
|
||||
pElement = spcGetFillin( Matrix );
|
||||
pElement = spcGetFillin( Matrix );
|
||||
Matrix->Fillins++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pElement = spcGetElement( Matrix );
|
||||
Matrix->Originals++;
|
||||
pElement = spcGetElement( Matrix );
|
||||
Matrix->Originals++;
|
||||
Matrix->NeedsOrdering = YES;
|
||||
}
|
||||
if (pElement == NULL) return NULL;
|
||||
|
||||
/* If element is on diagonal, store pointer in Diag. */
|
||||
if (Row == Col) Matrix->Diag[Row] = pElement;
|
||||
/* If element is on diagonal, store pointer in Diag. */
|
||||
if (Row == Col)
|
||||
Matrix->Diag[Row] = pElement;
|
||||
|
||||
/* Initialize Element. */
|
||||
/* Initialize Element. */
|
||||
pCreatedElement = pElement;
|
||||
pElement->Row = Row;
|
||||
pElement->Col = Col;
|
||||
|
|
@ -802,55 +788,54 @@ spcCreateElement(MatrixPtr Matrix, int Row, int Col,
|
|||
pElement->pInitInfo = NULL;
|
||||
#endif
|
||||
|
||||
/* Splice element into column. */
|
||||
/* Splice element into column. */
|
||||
pElement->NextInCol = *LastAddr;
|
||||
*LastAddr = pElement;
|
||||
|
||||
/* Search row for proper element position. */
|
||||
/* Search row for proper element position. */
|
||||
pElement = Matrix->FirstInRow[Row];
|
||||
pLastElement = NULL;
|
||||
while (pElement != NULL)
|
||||
{
|
||||
/* Search for element row position. */
|
||||
/* Search for element row position. */
|
||||
if (pElement->Col < Col)
|
||||
{
|
||||
/* Have not reached desired element. */
|
||||
/* Have not reached desired element. */
|
||||
pLastElement = pElement;
|
||||
pElement = pElement->NextInRow;
|
||||
}
|
||||
else pElement = NULL;
|
||||
}
|
||||
|
||||
/* Splice element into row. */
|
||||
/* Splice element into row. */
|
||||
pElement = pCreatedElement;
|
||||
if (pLastElement == NULL)
|
||||
{
|
||||
/* Element is first in row. */
|
||||
/* Element is first in row. */
|
||||
pElement->NextInRow = Matrix->FirstInRow[Row];
|
||||
Matrix->FirstInRow[Row] = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Element is not first in row. */
|
||||
/* Element is not first in row. */
|
||||
pElement->NextInRow = pLastElement->NextInRow;
|
||||
pLastElement->NextInRow = pElement;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Matrix has not been factored yet. Thus get element rather
|
||||
* than fill-in. Also, row pointers can be ignored. */
|
||||
/* Matrix has not been factored yet. Thus get element rather
|
||||
* than fill-in. Also, row pointers can be ignored. */
|
||||
|
||||
/* Allocate memory for Element. */
|
||||
/* Allocate memory for Element. */
|
||||
pElement = spcGetElement( Matrix );
|
||||
Matrix->Originals++;
|
||||
Matrix->Originals++;
|
||||
if (pElement == NULL) return NULL;
|
||||
|
||||
/* If element is on diagonal, store pointer in Diag. */
|
||||
/* If element is on diagonal, store pointer in Diag. */
|
||||
if (Row == Col) Matrix->Diag[Row] = pElement;
|
||||
|
||||
/* Initialize Element. */
|
||||
/* Initialize Element. */
|
||||
pCreatedElement = pElement;
|
||||
pElement->Row = Row;
|
||||
#if DEBUG
|
||||
|
|
@ -862,7 +847,7 @@ spcCreateElement(MatrixPtr Matrix, int Row, int Col,
|
|||
pElement->pInitInfo = NULL;
|
||||
#endif
|
||||
|
||||
/* Splice element into column. */
|
||||
/* Splice element into column. */
|
||||
pElement->NextInCol = *LastAddr;
|
||||
*LastAddr = pElement;
|
||||
}
|
||||
|
|
@ -876,8 +861,6 @@ spcCreateElement(MatrixPtr Matrix, int Row, int Col,
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* LINK ROWS
|
||||
|
|
@ -915,12 +898,12 @@ spcLinkRows(MatrixPtr Matrix)
|
|||
FirstInRowArray = Matrix->FirstInRow;
|
||||
for (Col = Matrix->Size; Col >= 1; Col--)
|
||||
{
|
||||
/* Generate row links for the elements in the Col'th column. */
|
||||
/* Generate row links for the elements in the Col'th column. */
|
||||
pElement = Matrix->FirstInCol[Col];
|
||||
|
||||
while (pElement != NULL)
|
||||
{
|
||||
pElement->Col = Col;
|
||||
pElement->Col = Col;
|
||||
FirstInRowEntry = &FirstInRowArray[pElement->Row];
|
||||
pElement->NextInRow = *FirstInRowEntry;
|
||||
*FirstInRowEntry = pElement;
|
||||
|
|
@ -937,7 +920,6 @@ spcLinkRows(MatrixPtr Matrix)
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ENLARGE MATRIX
|
||||
*
|
||||
|
|
@ -971,27 +953,27 @@ EnlargeMatrix(MatrixPtr Matrix, int NewSize)
|
|||
|
||||
if (( SP_REALLOC(Matrix->IntToExtColMap, int, NewSize+1)) == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
return;
|
||||
}
|
||||
if (( SP_REALLOC(Matrix->IntToExtRowMap, int, NewSize+1)) == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
return;
|
||||
}
|
||||
if (( SP_REALLOC(Matrix->Diag, ElementPtr, NewSize+1)) == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
return;
|
||||
}
|
||||
if (( SP_REALLOC(Matrix->FirstInCol, ElementPtr, NewSize+1)) == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
return;
|
||||
}
|
||||
if (( SP_REALLOC(Matrix->FirstInRow, ElementPtr, NewSize+1)) == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1008,7 +990,7 @@ EnlargeMatrix(MatrixPtr Matrix, int NewSize)
|
|||
/* Initialize the new portion of the vectors. */
|
||||
for (I = OldAllocatedSize+1; I <= NewSize; I++)
|
||||
{
|
||||
Matrix->IntToExtColMap[I] = I;
|
||||
Matrix->IntToExtColMap[I] = I;
|
||||
Matrix->IntToExtRowMap[I] = I;
|
||||
Matrix->Diag[I] = NULL;
|
||||
Matrix->FirstInRow[I] = NULL;
|
||||
|
|
@ -1026,7 +1008,6 @@ EnlargeMatrix(MatrixPtr Matrix, int NewSize)
|
|||
|
||||
|
||||
#if TRANSLATE
|
||||
|
||||
/*
|
||||
* EXPAND TRANSLATION ARRAYS
|
||||
*
|
||||
|
|
@ -1061,19 +1042,19 @@ ExpandTranslationArrays(MatrixPtr Matrix, int NewSize)
|
|||
|
||||
if (( SP_REALLOC(Matrix->ExtToIntRowMap, int, NewSize+1)) == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
return;
|
||||
}
|
||||
if (( SP_REALLOC(Matrix->ExtToIntColMap, int, NewSize+1)) == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the new portion of the vectors. */
|
||||
for (I = OldAllocatedSize+1; I <= NewSize; I++)
|
||||
{
|
||||
Matrix->ExtToIntRowMap[I] = -1;
|
||||
Matrix->ExtToIntRowMap[I] = -1;
|
||||
Matrix->ExtToIntColMap[I] = -1;
|
||||
}
|
||||
|
||||
|
|
@ -1087,8 +1068,6 @@ ExpandTranslationArrays(MatrixPtr Matrix, int NewSize)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
#if INITIALIZE
|
||||
/*
|
||||
* INITIALIZE MATRIX
|
||||
|
|
@ -1154,12 +1133,12 @@ spInitialize(MatrixPtr Matrix, int (*pInit)(RealNumber*, void *InitInfo, int , i
|
|||
/* Clear imaginary part of matrix if matrix is real but was complex. */
|
||||
if (Matrix->PreviousMatrixWasComplex && !Matrix->Complex)
|
||||
{
|
||||
for (J = Matrix->Size; J > 0; J--)
|
||||
for (J = Matrix->Size; J > 0; J--)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[J];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
pElement->Imag = 0.0;
|
||||
pElement->Imag = 0.0;
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
}
|
||||
|
|
@ -1168,22 +1147,22 @@ spInitialize(MatrixPtr Matrix, int (*pInit)(RealNumber*, void *InitInfo, int , i
|
|||
/* Initialize the matrix. */
|
||||
for (J = Matrix->Size; J > 0; J--)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[J];
|
||||
pElement = Matrix->FirstInCol[J];
|
||||
Col = Matrix->IntToExtColMap[J];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
if (pElement->pInitInfo == NULL)
|
||||
if (pElement->pInitInfo == NULL)
|
||||
{
|
||||
pElement->Real = 0.0;
|
||||
pElement->Imag = 0.0;
|
||||
pElement->Real = 0.0;
|
||||
pElement->Imag = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = pInit (& pElement->Real, pElement->pInitInfo,
|
||||
Error = pInit (& pElement->Real, pElement->pInitInfo,
|
||||
Matrix->IntToExtRowMap[pElement->Row], Col);
|
||||
if (Error)
|
||||
{
|
||||
Matrix->Error = spFATAL;
|
||||
Matrix->Error = spFATAL;
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,33 +18,33 @@
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Revision and copyright information.
|
||||
*
|
||||
* Copyright (c) 1985,86,87,88,89,90
|
||||
* by Kenneth S. Kundert and the University of California.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the copyright notices appear in all copies and
|
||||
* supporting documentation and that the authors and the University of
|
||||
* California are properly credited. The authors and the University of
|
||||
* California make no representations as to the suitability of this
|
||||
* software for any purpose. It is provided `as is', without express
|
||||
* or implied warranty.
|
||||
*/
|
||||
/*
|
||||
* Revision and copyright information.
|
||||
*
|
||||
* Copyright (c) 1985,86,87,88,89,90
|
||||
* by Kenneth S. Kundert and the University of California.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the copyright notices appear in all copies and
|
||||
* supporting documentation and that the authors and the University of
|
||||
* California are properly credited. The authors and the University of
|
||||
* California make no representations as to the suitability of this
|
||||
* software for any purpose. It is provided `as is', without express
|
||||
* or implied warranty.
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTS
|
||||
*
|
||||
* >>> Import descriptions:
|
||||
* spConfig.h
|
||||
* Macros that customize the sparse matrix routines.
|
||||
* spMatrix.h
|
||||
* Macros and declarations to be imported by the user.
|
||||
* spDefs.h
|
||||
* Matrix type and macro definitions for the sparse matrix routines.
|
||||
*/
|
||||
/*
|
||||
* IMPORTS
|
||||
*
|
||||
* >>> Import descriptions:
|
||||
* spConfig.h
|
||||
* Macros that customize the sparse matrix routines.
|
||||
* spMatrix.h
|
||||
* Macros and declarations to be imported by the user.
|
||||
* spDefs.h
|
||||
* Matrix type and macro definitions for the sparse matrix routines.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ int Printer_Width = PRINTER_WIDTH;
|
|||
|
||||
|
||||
#if DOCUMENTATION
|
||||
|
||||
|
||||
/*
|
||||
* PRINT MATRIX
|
||||
*
|
||||
|
|
@ -140,22 +140,22 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
int J = 0;
|
||||
int I, Row, Col, Size, Top;
|
||||
int StartCol = 1, StopCol, Columns, ElementCount = 0;
|
||||
double Magnitude;
|
||||
double SmallestDiag = 0;
|
||||
double Magnitude;
|
||||
double SmallestDiag = 0;
|
||||
double SmallestElement = 0;
|
||||
double LargestElement = 0.0, LargestDiag = 0.0;
|
||||
ElementPtr pElement, *pImagElements;
|
||||
int *PrintOrdToIntRowMap, *PrintOrdToIntColMap;
|
||||
ElementPtr pElement, * pImagElements;
|
||||
int* PrintOrdToIntRowMap, * PrintOrdToIntColMap;
|
||||
|
||||
/* Begin `spPrint'. */
|
||||
assert( IS_SPARSE( Matrix ) );
|
||||
assert(IS_SPARSE(Matrix));
|
||||
Size = Matrix->Size;
|
||||
SP_CALLOC(pImagElements, ElementPtr, Printer_Width / 10 + 1);
|
||||
if ( pImagElements == NULL)
|
||||
if (pImagElements == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
SP_FREE(pImagElements);
|
||||
return;
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
SP_FREE(pImagElements);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a packed external to internal row and column translation
|
||||
|
|
@ -165,49 +165,49 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
#else
|
||||
Top = Matrix->AllocatedSize;
|
||||
#endif
|
||||
SP_CALLOC( PrintOrdToIntRowMap, int, Top + 1 );
|
||||
if ( PrintOrdToIntRowMap == NULL)
|
||||
SP_CALLOC(PrintOrdToIntRowMap, int, Top + 1);
|
||||
if (PrintOrdToIntRowMap == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
SP_FREE(pImagElements);
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
SP_FREE(pImagElements);
|
||||
return;
|
||||
}
|
||||
SP_CALLOC( PrintOrdToIntColMap, int, Top + 1 );
|
||||
SP_CALLOC(PrintOrdToIntColMap, int, Top + 1);
|
||||
if (PrintOrdToIntColMap == NULL)
|
||||
{
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
SP_FREE(pImagElements);
|
||||
Matrix->Error = spNO_MEMORY;
|
||||
SP_FREE(pImagElements);
|
||||
SP_FREE(PrintOrdToIntRowMap);
|
||||
return;
|
||||
}
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
PrintOrdToIntRowMap[ Matrix->IntToExtRowMap[I] ] = I;
|
||||
PrintOrdToIntColMap[ Matrix->IntToExtColMap[I] ] = I;
|
||||
PrintOrdToIntRowMap[Matrix->IntToExtRowMap[I]] = I;
|
||||
PrintOrdToIntColMap[Matrix->IntToExtColMap[I]] = I;
|
||||
}
|
||||
|
||||
/* Pack the arrays. */
|
||||
for (J = 1, I = 1; I <= Top; I++)
|
||||
{
|
||||
if (PrintOrdToIntRowMap[I] != 0)
|
||||
PrintOrdToIntRowMap[ J++ ] = PrintOrdToIntRowMap[ I ];
|
||||
if (PrintOrdToIntRowMap[I] != 0)
|
||||
PrintOrdToIntRowMap[J++] = PrintOrdToIntRowMap[I];
|
||||
}
|
||||
for (J = 1, I = 1; I <= Top; I++)
|
||||
{
|
||||
if (PrintOrdToIntColMap[I] != 0)
|
||||
PrintOrdToIntColMap[ J++ ] = PrintOrdToIntColMap[ I ];
|
||||
if (PrintOrdToIntColMap[I] != 0)
|
||||
PrintOrdToIntColMap[J++] = PrintOrdToIntColMap[I];
|
||||
}
|
||||
|
||||
/* Print header. */
|
||||
if (Header)
|
||||
{
|
||||
printf("MATRIX SUMMARY\n\n");
|
||||
printf("MATRIX SUMMARY\n\n");
|
||||
printf("Size of matrix = %1d x %1d.\n", Size, Size);
|
||||
if ( Matrix->Reordered && PrintReordered )
|
||||
if (Matrix->Reordered && PrintReordered)
|
||||
printf("Matrix has been reordered.\n");
|
||||
putchar('\n');
|
||||
|
||||
if ( Matrix->Factored )
|
||||
if (Matrix->Factored)
|
||||
printf("Matrix after factorization:\n");
|
||||
else
|
||||
printf("Matrix before factorization:\n");
|
||||
|
|
@ -219,74 +219,74 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
/* Determine how many columns to use. */
|
||||
Columns = Printer_Width;
|
||||
if (Header) Columns -= 5;
|
||||
if (Data) Columns = (Columns+1) / 10;
|
||||
if (Data) Columns = (Columns + 1) / 10;
|
||||
|
||||
/* Print matrix by printing groups of complete columns until all
|
||||
* the columns are printed. */
|
||||
J = 0;
|
||||
while ( J <= Size )
|
||||
while (J <= Size)
|
||||
{
|
||||
/* Calculatestrchr of last column to printed in this group. */
|
||||
StopCol = StartCol + Columns - 1;
|
||||
/* Calculatestrchr of last column to printed in this group. */
|
||||
StopCol = StartCol + Columns - 1;
|
||||
if (StopCol > Size)
|
||||
StopCol = Size;
|
||||
|
||||
/* Label the columns. */
|
||||
/* Label the columns. */
|
||||
if (Header)
|
||||
{
|
||||
if (Data)
|
||||
if (Data)
|
||||
{
|
||||
printf(" ");
|
||||
printf(" ");
|
||||
for (I = StartCol; I <= StopCol; I++)
|
||||
{
|
||||
if (PrintReordered)
|
||||
if (PrintReordered)
|
||||
Col = I;
|
||||
else
|
||||
Col = PrintOrdToIntColMap[I];
|
||||
printf(" %9d", Matrix->IntToExtColMap[ Col ]);
|
||||
printf(" %9d", Matrix->IntToExtColMap[Col]);
|
||||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PrintReordered)
|
||||
printf("Columns %1d to %1d.\n",StartCol,StopCol);
|
||||
if (PrintReordered)
|
||||
printf("Columns %1d to %1d.\n", StartCol, StopCol);
|
||||
else
|
||||
{
|
||||
printf("Columns %1d to %1d.\n",
|
||||
Matrix->IntToExtColMap[ PrintOrdToIntColMap[StartCol] ],
|
||||
Matrix->IntToExtColMap[ PrintOrdToIntColMap[StopCol] ]);
|
||||
printf("Columns %1d to %1d.\n",
|
||||
Matrix->IntToExtColMap[PrintOrdToIntColMap[StartCol]],
|
||||
Matrix->IntToExtColMap[PrintOrdToIntColMap[StopCol]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Print every row ... */
|
||||
/* Print every row ... */
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
if (PrintReordered)
|
||||
if (PrintReordered)
|
||||
Row = I;
|
||||
else
|
||||
Row = PrintOrdToIntRowMap[I];
|
||||
|
||||
if (Header)
|
||||
{
|
||||
if (PrintReordered && !Data)
|
||||
if (PrintReordered && !Data)
|
||||
printf("%4d", I);
|
||||
else
|
||||
printf("%4d", Matrix->IntToExtRowMap[ Row ]);
|
||||
printf("%4d", Matrix->IntToExtRowMap[Row]);
|
||||
if (!Data) putchar(' ');
|
||||
}
|
||||
|
||||
/* ... in each column of the group. */
|
||||
/* ... in each column of the group. */
|
||||
for (J = StartCol; J <= StopCol; J++)
|
||||
{
|
||||
if (PrintReordered)
|
||||
if (PrintReordered)
|
||||
Col = J;
|
||||
else
|
||||
Col = PrintOrdToIntColMap[J];
|
||||
|
||||
pElement = Matrix->FirstInCol[Col];
|
||||
while(pElement != NULL && pElement->Row != Row)
|
||||
while (pElement != NULL && pElement->Row != Row)
|
||||
pElement = pElement->NextInCol;
|
||||
|
||||
if (Data)
|
||||
|
|
@ -294,24 +294,24 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
|
||||
if (pElement != NULL)
|
||||
{
|
||||
/* Case where element exists */
|
||||
if (Data)
|
||||
/* Case where element exists */
|
||||
if (Data)
|
||||
printf(" %9.3g", pElement->Real);
|
||||
else
|
||||
putchar('x');
|
||||
|
||||
/* Update status variables */
|
||||
if ( (Magnitude = ELEMENT_MAG(pElement)) > LargestElement )
|
||||
/* Update status variables */
|
||||
if ((Magnitude = ELEMENT_MAG(pElement)) > LargestElement)
|
||||
LargestElement = Magnitude;
|
||||
if ((Magnitude < SmallestElement) && (Magnitude != 0.0))
|
||||
SmallestElement = Magnitude;
|
||||
ElementCount++;
|
||||
}
|
||||
|
||||
/* Case where element is structurally zero */
|
||||
/* Case where element is structurally zero */
|
||||
else
|
||||
{
|
||||
if (Data)
|
||||
if (Data)
|
||||
printf(" ...");
|
||||
else
|
||||
putchar('.');
|
||||
|
|
@ -321,13 +321,13 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
|
||||
if (Matrix->Complex && Data)
|
||||
{
|
||||
printf(" ");
|
||||
printf(" ");
|
||||
for (J = StartCol; J <= StopCol; J++)
|
||||
{
|
||||
if (pImagElements[J - StartCol] != NULL)
|
||||
if (pImagElements[J - StartCol] != NULL)
|
||||
{
|
||||
printf(" %8.2gj",
|
||||
pImagElements[J-StartCol]->Imag);
|
||||
printf(" %8.2gj",
|
||||
pImagElements[J - StartCol]->Imag);
|
||||
}
|
||||
else printf(" ");
|
||||
}
|
||||
|
|
@ -335,44 +335,44 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
}
|
||||
}
|
||||
|
||||
/* Calculatestrchr of first column in next group. */
|
||||
/* Calculatestrchr of first column in next group. */
|
||||
StartCol = StopCol;
|
||||
StartCol++;
|
||||
putchar('\n');
|
||||
}
|
||||
if (Header)
|
||||
{
|
||||
printf("\nLargest element in matrix = %-1.4g.\n", LargestElement);
|
||||
printf("\nLargest element in matrix = %-1.4g.\n", LargestElement);
|
||||
printf("Smallest element in matrix = %-1.4g.\n", SmallestElement);
|
||||
|
||||
/* Search for largest and smallest diagonal values */
|
||||
/* Search for largest and smallest diagonal values */
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
if (Matrix->Diag[I] != NULL)
|
||||
if (Matrix->Diag[I] != NULL)
|
||||
{
|
||||
Magnitude = ELEMENT_MAG( Matrix->Diag[I] );
|
||||
if ( Magnitude > LargestDiag ) LargestDiag = Magnitude;
|
||||
if ( Magnitude < SmallestDiag ) SmallestDiag = Magnitude;
|
||||
Magnitude = ELEMENT_MAG(Matrix->Diag[I]);
|
||||
if (Magnitude > LargestDiag) LargestDiag = Magnitude;
|
||||
if (Magnitude < SmallestDiag) SmallestDiag = Magnitude;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print the largest and smallest diagonal values */
|
||||
if ( Matrix->Factored )
|
||||
/* Print the largest and smallest diagonal values */
|
||||
if (Matrix->Factored)
|
||||
{
|
||||
printf("\nLargest diagonal element = %-1.4g.\n", LargestDiag);
|
||||
printf("\nLargest diagonal element = %-1.4g.\n", LargestDiag);
|
||||
printf("Smallest diagonal element = %-1.4g.\n", SmallestDiag);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nLargest pivot element = %-1.4g.\n", LargestDiag);
|
||||
printf("\nLargest pivot element = %-1.4g.\n", LargestDiag);
|
||||
printf("Smallest pivot element = %-1.4g.\n", SmallestDiag);
|
||||
}
|
||||
|
||||
/* Calculate and print sparsity and number of fill-ins created. */
|
||||
/* Calculate and print sparsity and number of fill-ins created. */
|
||||
printf("\nDensity = %2.2f%%.\n", ((double)(ElementCount * 100)) /
|
||||
((double)(Size * Size)));
|
||||
((double)(Size * Size)));
|
||||
|
||||
printf("Number of originals = %1d.\n", Matrix->Originals);
|
||||
printf("Number of originals = %1d.\n", Matrix->Originals);
|
||||
if (!Matrix->NeedsOrdering)
|
||||
printf("Number of fill-ins = %1d.\n", Matrix->Fillins);
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* OUTPUT MATRIX TO FILE
|
||||
*
|
||||
|
|
@ -437,16 +437,16 @@ spPrint(MatrixPtr Matrix, int PrintReordered, int Data, int Header)
|
|||
*/
|
||||
|
||||
int
|
||||
spFileMatrix(MatrixPtr Matrix, char *File, char *Label, int Reordered,
|
||||
int Data, int Header)
|
||||
spFileMatrix(MatrixPtr Matrix, char* File, char* Label, int Reordered,
|
||||
int Data, int Header)
|
||||
{
|
||||
int I, Size;
|
||||
ElementPtr pElement;
|
||||
int Row, Col, Err;
|
||||
FILE *pMatrixFile;
|
||||
FILE* pMatrixFile;
|
||||
|
||||
/* Begin `spFileMatrix'. */
|
||||
assert( IS_SPARSE( Matrix ) );
|
||||
assert(IS_SPARSE(Matrix));
|
||||
|
||||
/* Open file matrix file in write mode. */
|
||||
if ((pMatrixFile = fopen(File, "w")) == NULL)
|
||||
|
|
@ -456,100 +456,100 @@ spFileMatrix(MatrixPtr Matrix, char *File, char *Label, int Reordered,
|
|||
Size = Matrix->Size;
|
||||
if (Header)
|
||||
{
|
||||
if (Matrix->Factored && Data)
|
||||
if (Matrix->Factored && Data)
|
||||
{
|
||||
Err = fprintf(pMatrixFile,
|
||||
"Warning : The following matrix is "
|
||||
"factored in to LU form.\n");
|
||||
if (Err < 0)
|
||||
return 0;
|
||||
Err = fprintf(pMatrixFile,
|
||||
"Warning : The following matrix is "
|
||||
"factored in to LU form.\n");
|
||||
if (Err < 0)
|
||||
return 0;
|
||||
}
|
||||
if (fprintf(pMatrixFile, "%s\n", Label) < 0)
|
||||
return 0;
|
||||
Err = fprintf( pMatrixFile, "%d\t%s\n", Size,
|
||||
(Matrix->Complex ? "complex" : "real"));
|
||||
return 0;
|
||||
Err = fprintf(pMatrixFile, "%d\t%s\n", Size,
|
||||
(Matrix->Complex ? "complex" : "real"));
|
||||
if (Err < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Output matrix. */
|
||||
if (!Data)
|
||||
{
|
||||
for (I = 1; I <= Size; I++)
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
if (Reordered)
|
||||
if (Reordered)
|
||||
{
|
||||
Row = pElement->Row;
|
||||
Row = pElement->Row;
|
||||
Col = I;
|
||||
}
|
||||
else
|
||||
{
|
||||
Row = Matrix->IntToExtRowMap[pElement->Row];
|
||||
Row = Matrix->IntToExtRowMap[pElement->Row];
|
||||
Col = Matrix->IntToExtColMap[I];
|
||||
}
|
||||
pElement = pElement->NextInCol;
|
||||
if (fprintf(pMatrixFile, "%d\t%d\n", Row, Col) < 0) return 0;
|
||||
}
|
||||
}
|
||||
/* Output terminator, a line of zeros. */
|
||||
/* Output terminator, a line of zeros. */
|
||||
if (Header)
|
||||
if (fprintf(pMatrixFile, "0\t0\n") < 0) return 0;
|
||||
}
|
||||
|
||||
if (Data && Matrix->Complex)
|
||||
{
|
||||
for (I = 1; I <= Size; I++)
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
if (Reordered)
|
||||
if (Reordered)
|
||||
{
|
||||
Row = pElement->Row;
|
||||
Row = pElement->Row;
|
||||
Col = I;
|
||||
}
|
||||
else
|
||||
{
|
||||
Row = Matrix->IntToExtRowMap[pElement->Row];
|
||||
Row = Matrix->IntToExtRowMap[pElement->Row];
|
||||
Col = Matrix->IntToExtColMap[I];
|
||||
}
|
||||
Err = fprintf
|
||||
( pMatrixFile,"%d\t%d\t%-.15g\t%-.15g\n",
|
||||
Row, Col, pElement->Real, pElement->Imag
|
||||
);
|
||||
(pMatrixFile, "%d\t%d\t%-.15g\t%-.15g\n",
|
||||
Row, Col, pElement->Real, pElement->Imag
|
||||
);
|
||||
if (Err < 0) return 0;
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
}
|
||||
/* Output terminator, a line of zeros. */
|
||||
/* Output terminator, a line of zeros. */
|
||||
if (Header)
|
||||
if (fprintf(pMatrixFile,"0\t0\t0.0\t0.0\n") < 0) return 0;
|
||||
if (fprintf(pMatrixFile, "0\t0\t0.0\t0.0\n") < 0) return 0;
|
||||
|
||||
}
|
||||
|
||||
if (Data && !Matrix->Complex)
|
||||
{
|
||||
for (I = 1; I <= Size; I++)
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
Row = Matrix->IntToExtRowMap[pElement->Row];
|
||||
Row = Matrix->IntToExtRowMap[pElement->Row];
|
||||
Col = Matrix->IntToExtColMap[I];
|
||||
Err = fprintf
|
||||
( pMatrixFile,"%d\t%d\t%-.15g\n",
|
||||
Row, Col, pElement->Real
|
||||
);
|
||||
(pMatrixFile, "%d\t%d\t%-.15g\n",
|
||||
Row, Col, pElement->Real
|
||||
);
|
||||
if (Err < 0) return 0;
|
||||
pElement = pElement->NextInCol;
|
||||
}
|
||||
}
|
||||
/* Output terminator, a line of zeros. */
|
||||
/* Output terminator, a line of zeros. */
|
||||
if (Header)
|
||||
if (fprintf(pMatrixFile,"0\t0\t0.0\n") < 0) return 0;
|
||||
if (fprintf(pMatrixFile, "0\t0\t0.0\n") < 0) return 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -563,7 +563,7 @@ spFileMatrix(MatrixPtr Matrix, char *File, char *Label, int Reordered,
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* OUTPUT SOURCE VECTOR TO FILE
|
||||
*
|
||||
|
|
@ -595,22 +595,22 @@ spFileMatrix(MatrixPtr Matrix, char *File, char *Label, int Reordered,
|
|||
*/
|
||||
|
||||
int
|
||||
spFileVector(MatrixPtr Matrix, char *File, RealVector RHS, RealVector iRHS)
|
||||
spFileVector(MatrixPtr Matrix, char* File, RealVector RHS, RealVector iRHS)
|
||||
{
|
||||
int I, Size, Err;
|
||||
FILE *pMatrixFile;
|
||||
FILE* pMatrixFile;
|
||||
|
||||
/* Begin `spFileVector'. */
|
||||
assert( IS_SPARSE( Matrix ) && RHS != NULL);
|
||||
assert(IS_SPARSE(Matrix) && RHS != NULL);
|
||||
|
||||
if (File) {
|
||||
/* Open File in write mode. */
|
||||
pMatrixFile = fopen(File,"w");
|
||||
pMatrixFile = fopen(File, "w");
|
||||
if (pMatrixFile == NULL)
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
pMatrixFile=stdout;
|
||||
else
|
||||
pMatrixFile = stdout;
|
||||
|
||||
/* Output vector. */
|
||||
Size = Matrix->Size;
|
||||
|
|
@ -618,18 +618,18 @@ spFileVector(MatrixPtr Matrix, char *File, RealVector RHS, RealVector iRHS)
|
|||
{
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
Err = fprintf
|
||||
( pMatrixFile, "%-.15g\t%-.15g\n",
|
||||
RHS[I], iRHS[I]
|
||||
);
|
||||
Err = fprintf
|
||||
(pMatrixFile, "%-.15g\t%-.15g\n",
|
||||
RHS[I], iRHS[I]
|
||||
);
|
||||
if (Err < 0) return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (I = 1; I <= Size; I++)
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
if (fprintf(pMatrixFile, "%-.15g\n", RHS[I]) < 0)
|
||||
if (fprintf(pMatrixFile, "%-.15g\n", RHS[I]) < 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -647,13 +647,13 @@ spFileVector(MatrixPtr Matrix, char *File, RealVector RHS, RealVector iRHS)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* OUTPUT STATISTICS TO FILE
|
||||
*
|
||||
* Writes useful information concerning the matrix to a file. Should be
|
||||
* executed after the matrix is factored.
|
||||
*
|
||||
*
|
||||
* >>> Returns:
|
||||
* One is returned if routine was successful, otherwise zero is returned.
|
||||
* The calling function can query errno (the system global error variable)
|
||||
|
|
@ -685,16 +685,16 @@ spFileVector(MatrixPtr Matrix, char *File, RealVector RHS, RealVector iRHS)
|
|||
*/
|
||||
|
||||
int
|
||||
spFileStats(MatrixPtr Matrix, char *File, char *Label)
|
||||
spFileStats(MatrixPtr Matrix, char* File, char* Label)
|
||||
{
|
||||
int Size, I;
|
||||
ElementPtr pElement;
|
||||
int NumberOfElements;
|
||||
RealNumber Data, LargestElement, SmallestElement;
|
||||
FILE *pStatsFile;
|
||||
FILE* pStatsFile;
|
||||
|
||||
/* Begin `spFileStats'. */
|
||||
assert( IS_SPARSE( Matrix ) );
|
||||
assert(IS_SPARSE(Matrix));
|
||||
|
||||
/* Open File in append mode. */
|
||||
if ((pStatsFile = fopen(File, "a")) == NULL)
|
||||
|
|
@ -710,7 +710,7 @@ spFileStats(MatrixPtr Matrix, char *File, char *Label)
|
|||
fprintf(pStatsFile, "Matrix is complex.\n");
|
||||
else
|
||||
fprintf(pStatsFile, "Matrix is real.\n");
|
||||
fprintf(pStatsFile," Size = %d\n",Size);
|
||||
fprintf(pStatsFile, " Size = %d\n", Size);
|
||||
|
||||
/* Search matrix. */
|
||||
NumberOfElements = 0;
|
||||
|
|
@ -719,10 +719,10 @@ spFileStats(MatrixPtr Matrix, char *File, char *Label)
|
|||
|
||||
for (I = 1; I <= Size; I++)
|
||||
{
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
pElement = Matrix->FirstInCol[I];
|
||||
while (pElement != NULL)
|
||||
{
|
||||
NumberOfElements++;
|
||||
NumberOfElements++;
|
||||
Data = ELEMENT_MAG(pElement);
|
||||
if (Data > LargestElement)
|
||||
LargestElement = Data;
|
||||
|
|
@ -732,27 +732,27 @@ spFileStats(MatrixPtr Matrix, char *File, char *Label)
|
|||
}
|
||||
}
|
||||
|
||||
SmallestElement = MIN( SmallestElement, LargestElement );
|
||||
SmallestElement = MIN(SmallestElement, LargestElement);
|
||||
|
||||
/* Output remaining statistics. */
|
||||
fprintf(pStatsFile, " Initial number of elements = %d\n",
|
||||
NumberOfElements - Matrix->Fillins);
|
||||
NumberOfElements - Matrix->Fillins);
|
||||
fprintf(pStatsFile,
|
||||
" Initial average number of elements per row = %f\n",
|
||||
(double)(NumberOfElements - Matrix->Fillins) / (double)Size);
|
||||
fprintf(pStatsFile, " Fill-ins = %d\n",Matrix->Fillins);
|
||||
" Initial average number of elements per row = %f\n",
|
||||
(double)(NumberOfElements - Matrix->Fillins) / (double)Size);
|
||||
fprintf(pStatsFile, " Fill-ins = %d\n", Matrix->Fillins);
|
||||
fprintf(pStatsFile, " Average number of fill-ins per row = %f%%\n",
|
||||
(double)Matrix->Fillins / (double)Size);
|
||||
(double)Matrix->Fillins / (double)Size);
|
||||
fprintf(pStatsFile, " Total number of elements = %d\n",
|
||||
NumberOfElements);
|
||||
NumberOfElements);
|
||||
fprintf(pStatsFile, " Average number of elements per row = %f\n",
|
||||
(double)NumberOfElements / (double)Size);
|
||||
fprintf(pStatsFile," Density = %f%%\n",
|
||||
(double)(100.0*NumberOfElements)/(double)(Size*Size));
|
||||
fprintf(pStatsFile," Relative Threshold = %e\n", Matrix->RelThreshold);
|
||||
fprintf(pStatsFile," Absolute Threshold = %e\n", Matrix->AbsThreshold);
|
||||
fprintf(pStatsFile," Largest Element = %e\n", LargestElement);
|
||||
fprintf(pStatsFile," Smallest Element = %e\n\n\n", SmallestElement);
|
||||
(double)NumberOfElements / (double)Size);
|
||||
fprintf(pStatsFile, " Density = %f%%\n",
|
||||
(double)(100.0 * NumberOfElements) / (double)(Size * Size));
|
||||
fprintf(pStatsFile, " Relative Threshold = %e\n", Matrix->RelThreshold);
|
||||
fprintf(pStatsFile, " Absolute Threshold = %e\n", Matrix->AbsThreshold);
|
||||
fprintf(pStatsFile, " Largest Element = %e\n", LargestElement);
|
||||
fprintf(pStatsFile, " Smallest Element = %e\n\n\n", SmallestElement);
|
||||
|
||||
/* Close file. */
|
||||
(void)fclose(pStatsFile);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ inchar(FILE *fp)
|
|||
}
|
||||
|
||||
return (int) c;
|
||||
#elif
|
||||
#else
|
||||
|
||||
return getc(fp);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -975,13 +975,26 @@ ngSpice_Init(SendChar* printfcn, SendStat* statusfcn, ControlledExit* ngspiceexi
|
|||
}
|
||||
#else /* ~ HAVE_PWD_H */
|
||||
/* load user's initialisation file
|
||||
try accessing the initialisation file .spiceinit in a user provided
|
||||
path read from environmental variable SPICE_USERINIT_DIR,
|
||||
if that fails try the alternate name spice.rc, then look into
|
||||
the current directory, then the HOME directory, then into USERPROFILE.
|
||||
Don't read .spiceinit, if ngSpice_nospiceinit() has been called. */
|
||||
try accessing the initialisation file .spiceinit
|
||||
(If it fails, try the alternate name spice.rc):
|
||||
- in the directory Infile_Path received from the caller (sent before initialization)
|
||||
- in a user provided path read from environmental variable SPICE_USERINIT_DIR,
|
||||
- in the current directory,
|
||||
- in the the HOME directory,
|
||||
- in the USERPROFILE directory.
|
||||
Don't read .spiceinit, if ngSpice_nospiceinit() has been called. */
|
||||
if (!cp_getvar("no_spiceinit", CP_BOOL, NULL, 0)) {
|
||||
do {
|
||||
{
|
||||
if (Infile_Path) {
|
||||
if (read_initialisation_file(Infile_Path, INITSTR) != FALSE) {
|
||||
break;
|
||||
}
|
||||
if (read_initialisation_file(Infile_Path, ALT_INITSTR) != FALSE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
const char* const userinit = getenv("SPICE_USERINIT_DIR");
|
||||
if (userinit) {
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ VDMOSacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
*(here->VDMOSDPgpPtr +1) -= xgd;
|
||||
*(here->VDMOSSPgpPtr +1) -= xgs;
|
||||
|
||||
*(here->VDMOSDdPtr) += here->VDMOSdrainConductance;
|
||||
*(here->VDMOSSsPtr) += here->VDMOSsourceConductance;
|
||||
*(here->VDMOSDdPtr) += here->VDMOSdrainConductance + here->VDMOSdsConductance;
|
||||
*(here->VDMOSSsPtr) += here->VDMOSsourceConductance + here->VDMOSdsConductance;
|
||||
*(here->VDMOSDPdpPtr) += here->VDMOSdrainConductance+
|
||||
here->VDMOSgds+xrev*(here->VDMOSgm);
|
||||
*(here->VDMOSSPspPtr) += here->VDMOSsourceConductance+
|
||||
|
|
@ -110,6 +110,8 @@ VDMOSacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
*(here->VDMOSSPgpPtr) -= (xnrm-xrev)*here->VDMOSgm;
|
||||
*(here->VDMOSSPsPtr) -= here->VDMOSsourceConductance;
|
||||
*(here->VDMOSSPdpPtr) -= here->VDMOSgds+xrev*(here->VDMOSgm);
|
||||
*(here->VDMOSDsPtr) += (-here->VDMOSdsConductance);
|
||||
*(here->VDMOSSdPtr) += (-here->VDMOSdsConductance);
|
||||
/* gate resistor */
|
||||
*(here->VDMOSGgPtr) += (here->VDMOSgateConductance);
|
||||
*(here->VDMOSGPgpPtr) += (here->VDMOSgateConductance);
|
||||
|
|
|
|||
|
|
@ -171,10 +171,6 @@ typedef struct sVDMOSinstance {
|
|||
(source prime node,source prime node) */
|
||||
double *VDMOSDdpPtr; /* pointer to sparse matrix element at
|
||||
(drain node,drain prime node) */
|
||||
double *VDMOSGdpPtr; /* pointer to sparse matrix element at
|
||||
(gate node,drain prime node) */
|
||||
double *VDMOSGspPtr; /* pointer to sparse matrix element at
|
||||
(gate node,source prime node) */
|
||||
double *VDMOSSspPtr; /* pointer to sparse matrix element at
|
||||
(source node,source prime node) */
|
||||
double *VDMOSDPspPtr; /* pointer to sparse matrix element at
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ VDMOSdSetup(GENmodel *inModel, CKTcircuit *ckt)
|
|||
/* scale vds with mtr (except with lambda) */
|
||||
double vdss = vds*mtr*here->VDMOSmode;
|
||||
double t0 = 1 + lambda*vds;
|
||||
double t1 = 1 + theta*vgst;
|
||||
double t1 = 1 + theta*vdsat;
|
||||
double betap = Beta*t0/t1;
|
||||
double dbetapdvgs = -Beta*theta*t0/(t1*t1);
|
||||
double dbetapdvds = Beta*lambda/t1;
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ VDMOSload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
/* scale vds with mtr (except with lambda) */
|
||||
double vdss = vds*mtr*here->VDMOSmode;
|
||||
double t0 = 1 + lambda*vds;
|
||||
double t1 = 1 + theta*vgst;
|
||||
double t1 = 1 + theta*vdsat;
|
||||
double betap = Beta*t0/t1;
|
||||
double dbetapdvgs = -Beta*theta*t0/(t1*t1);
|
||||
double dbetapdvds = Beta*lambda/t1;
|
||||
|
|
|
|||
|
|
@ -55,22 +55,23 @@ VDMOSpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
* load matrix
|
||||
*/
|
||||
|
||||
*(here->VDMOSGgPtr ) += (xgd+xgs)*s->real;
|
||||
*(here->VDMOSGgPtr +1) += (xgd+xgs)*s->imag;
|
||||
*(here->VDMOSGPgpPtr ) += (xgd+xgs)*s->real;
|
||||
*(here->VDMOSGPgpPtr +1) += (xgd+xgs)*s->imag;
|
||||
*(here->VDMOSDPdpPtr ) += (xgd)*s->real;
|
||||
*(here->VDMOSDPdpPtr +1) += (xgd)*s->imag;
|
||||
*(here->VDMOSSPspPtr ) += (xgs)*s->real;
|
||||
*(here->VDMOSSPspPtr +1) += (xgs)*s->imag;
|
||||
*(here->VDMOSGdpPtr ) -= xgd*s->real;
|
||||
*(here->VDMOSGdpPtr +1) -= xgd*s->imag;
|
||||
*(here->VDMOSGspPtr ) -= xgs*s->real;
|
||||
*(here->VDMOSGspPtr +1) -= xgs*s->imag;
|
||||
*(here->VDMOSDPgPtr ) -= xgd*s->real;
|
||||
*(here->VDMOSDPgPtr +1) -= xgd*s->imag;
|
||||
*(here->VDMOSSPgPtr ) -= xgs*s->real;
|
||||
*(here->VDMOSSPgPtr +1) -= xgs*s->imag;
|
||||
*(here->VDMOSDdPtr) += here->VDMOSdrainConductance;
|
||||
*(here->VDMOSSsPtr) += here->VDMOSsourceConductance;
|
||||
*(here->VDMOSGPdpPtr ) -= xgd*s->real;
|
||||
*(here->VDMOSGPdpPtr +1) -= xgd*s->imag;
|
||||
*(here->VDMOSGPspPtr ) -= xgs*s->real;
|
||||
*(here->VDMOSGPspPtr +1) -= xgs*s->imag;
|
||||
*(here->VDMOSDPgpPtr ) -= xgd*s->real;
|
||||
*(here->VDMOSDPgpPtr +1) -= xgd*s->imag;
|
||||
*(here->VDMOSSPgpPtr ) -= xgs*s->real;
|
||||
*(here->VDMOSSPgpPtr +1) -= xgs*s->imag;
|
||||
|
||||
*(here->VDMOSDdPtr) += here->VDMOSdrainConductance + here->VDMOSdsConductance;
|
||||
*(here->VDMOSSsPtr) += here->VDMOSsourceConductance + here->VDMOSdsConductance;
|
||||
*(here->VDMOSDPdpPtr) += here->VDMOSdrainConductance+
|
||||
here->VDMOSgds+xrev*(here->VDMOSgm);
|
||||
*(here->VDMOSSPspPtr) += here->VDMOSsourceConductance+
|
||||
|
|
@ -83,6 +84,8 @@ VDMOSpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
*(here->VDMOSSPgpPtr) -= (xnrm-xrev)*here->VDMOSgm;
|
||||
*(here->VDMOSSPsPtr) -= here->VDMOSsourceConductance;
|
||||
*(here->VDMOSSPdpPtr) -= here->VDMOSgds+xrev*(here->VDMOSgm);
|
||||
*(here->VDMOSDsPtr) += (-here->VDMOSdsConductance);
|
||||
*(here->VDMOSSdPtr) += (-here->VDMOSdsConductance);
|
||||
/* gate resistor */
|
||||
*(here->VDMOSGgPtr) += (here->VDMOSgateConductance);
|
||||
*(here->VDMOSGPgpPtr) += (here->VDMOSgateConductance);
|
||||
|
|
|
|||
|
|
@ -22,79 +22,96 @@ void INP2N(CKTcircuit *ckt, INPtables *tab, struct card *current) {
|
|||
* [IC=<val>,<val>,<val>]
|
||||
*/
|
||||
|
||||
int type; /* the type the model says it is */
|
||||
char *line; /* the part of the current line left to parse */
|
||||
char *name; /* the resistor's name */
|
||||
// limit to at most 20 nodes
|
||||
const int max_i = 20;
|
||||
CKTnode *node[20];
|
||||
int error; /* error code temporary */
|
||||
int numnodes; /* flag indicating 4 or 5 (or 6 or 7) nodes */
|
||||
GENinstance *fast; /* pointer to the actual instance */
|
||||
int waslead; /* flag to indicate that funny unlabeled number was found */
|
||||
double leadval; /* actual value of unlabeled number */
|
||||
INPmodel *thismodel; /* pointer to model description for user's model */
|
||||
GENmodel *mdfast; /* pointer to the actual model */
|
||||
int i;
|
||||
int type; /* Model type. */
|
||||
char *line; /* Unparsed part of the current line. */
|
||||
char *name; /* Device instance name. */
|
||||
int error; /* Temporary error code. */
|
||||
int numnodes; /* Flag indicating 4 or 5 (or 6 or 7) nodes. */
|
||||
GENinstance *fast; /* Pointer to the actual instance. */
|
||||
int waslead; /* Funny unlabeled number was found. */
|
||||
double leadval; /* Value of unlabeled number. */
|
||||
INPmodel *thismodel; /* Pointer to model description for user's model. */
|
||||
GENmodel *mdfast; /* Pointer to the actual model. */
|
||||
IFdevice *dev;
|
||||
CKTnode *node;
|
||||
char *c, *token = NULL, *prev = NULL, *pprev = NULL;
|
||||
int i;
|
||||
|
||||
line = current->line;
|
||||
|
||||
INPgetNetTok(&line, &name, 1);
|
||||
INPinsert(&name, tab);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
char *token;
|
||||
INPgetNetTok(&line, &token, 1);
|
||||
/* Find the last non-parameter token in the line. */
|
||||
|
||||
/* We have single terminal Verilog-A modules */
|
||||
if (i >= 1) {
|
||||
txfree(INPgetMod(ckt, token, &thismodel, tab));
|
||||
c = line;
|
||||
for (i = 0; *c != '\0'; ++i) {
|
||||
tfree(pprev);
|
||||
pprev = prev;
|
||||
prev = token;
|
||||
token = gettok_instance(&c);
|
||||
if (strchr(token, '='))
|
||||
break;
|
||||
}
|
||||
if (*c) {
|
||||
tfree(token); // A parameter or starts with '='.
|
||||
if (*c == '=') {
|
||||
/* Now prev points to a parameter pprev is the model. */
|
||||
|
||||
/* /1* check if using model binning -- pass in line since need 'l' and 'w' *1/ */
|
||||
/* if (!thismodel) */
|
||||
/* txfree(INPgetModBin(ckt, token, &thismodel, tab, line)); */
|
||||
|
||||
if (thismodel) {
|
||||
INPinsert(&token, tab);
|
||||
break;
|
||||
--i;
|
||||
token = pprev;
|
||||
tfree(prev);
|
||||
} else {
|
||||
token = prev;
|
||||
tfree(pprev);
|
||||
}
|
||||
}
|
||||
if (i >= max_i) {
|
||||
LITERR("could not find a valid modelname");
|
||||
return;
|
||||
}
|
||||
INPtermInsert(ckt, &token, tab, &node[i]);
|
||||
}
|
||||
|
||||
/* We have single terminal Verilog-A modules */
|
||||
|
||||
if (i >= 2) {
|
||||
c = INPgetMod(ckt, token, &thismodel, tab);
|
||||
if (c) {
|
||||
LITERR(c);
|
||||
tfree(c);
|
||||
tfree(token);
|
||||
return;
|
||||
}
|
||||
}
|
||||
tfree(token);
|
||||
if (i < 2 || !thismodel) {
|
||||
LITERR("could not find a valid modelname");
|
||||
return;
|
||||
}
|
||||
type = thismodel->INPmodType;
|
||||
mdfast = thismodel->INPmodfast;
|
||||
IFdevice *dev = ft_sim->devices[type];
|
||||
dev = ft_sim->devices[type];
|
||||
|
||||
if (!dev->registry_entry) {
|
||||
LITERR("incorrect model type! Expected OSDI device");
|
||||
return;
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
LITERR("not enough nodes");
|
||||
return;
|
||||
}
|
||||
|
||||
if (i > *dev->terms) {
|
||||
numnodes = i - 1;
|
||||
if (numnodes > *dev->terms) {
|
||||
LITERR("too many nodes connected to instance");
|
||||
return;
|
||||
}
|
||||
|
||||
numnodes = i;
|
||||
|
||||
IFC(newInstance, (ckt, mdfast, &fast, name));
|
||||
|
||||
for (i = 0; i < *dev->terms; i++)
|
||||
if (i < numnodes)
|
||||
IFC(bindNode, (ckt, fast, i + 1, node[i]));
|
||||
else
|
||||
GENnode(fast)[i] = -1;
|
||||
/* Rescan to process nodes. */
|
||||
|
||||
for (i = 0; i < *dev->terms; i++) {
|
||||
if (i < numnodes) {
|
||||
token = gettok_instance(&line);
|
||||
INPtermInsert(ckt, &token, tab, &node); // Consumes token
|
||||
IFC(bindNode, (ckt, fast, i + 1, node));
|
||||
} else {
|
||||
GENnode(fast)[i] = -1;
|
||||
}
|
||||
}
|
||||
token = gettok_instance(&line); // Eat model name.
|
||||
tfree(token);
|
||||
PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab));
|
||||
if (waslead)
|
||||
LITERR(" error: no unlabeled parameter permitted on osdi devices\n");
|
||||
|
|
|
|||
|
|
@ -673,7 +673,7 @@ lib /machine:x64 /def:..\..\fftw-3.3-dll64\libfftw3-3.def /out:$(IntDir)libfftw3
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<AdditionalIncludeDirectories>..\src\maths\poly;..\src\frontend;..\src\spicelib\devices;tmp-bison;src\include;..\src\spicelib\parser;..\src\include;..\src\include\cppduals;.;..\..\fftw-3.3-dll32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\src\maths\poly;..\src\frontend;..\src\spicelib\devices;tmp-bison;src\include;..\src\spicelib\parser;..\src\include;..\src\include\cppduals;.;..\..\fftw-3.3-dll64;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;SIMULATOR;XSPICE;USE_OMP;CONFIG64;HAVE_LIBFFTW3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ExceptionHandling>
|
||||
|
|
|
|||
Loading…
Reference in New Issue