Jspice3
spbuild.c File Reference
#include "spconfig.h"
#include "spmatrix.h"
#include "spdefs.h"
Include dependency graph for spbuild.c:

Go to the source code of this file.

Macros

#define spINSIDE_SPARSE
 
#define M_LN2   0.69314718055994530942
 
#define M_LN10   2.30258509299404568402
 

Functions

static void Translate ()
 
static void EnlargeMatrix ()
 
static void ExpandTranslationArrays ()
 
void spItoR (char *eMatrix)
 
void spRtoI (char *eMatrix)
 
void spLoadGmin (char *Matrixp, double Gmin)
 
void spGetStat (char *Matrixp, int *Size, int *NonZero, int *FillIns)
 
int spAddCol (char *Matrixp, int Accum_Col, int Addend_Col)
 
int spZeroCol (char *Matrixp, int Col)
 
static double my_logb (double x)
 
static double my_scalb (double x, int n)
 
int spDProd (char *Matrix, double *pMantissaR, double *pMantissaI, int *pExponent)
 
void spClear (char *eMatrix)
 
RealNumberspGetElement (char *eMatrix, int Row, int Col)
 
ElementPtr spcFindElementInCol (MatrixPtr Matrix, ElementPtr *LastAddr, int Row, int Col, BOOLEAN CreateIfMissing)
 
ElementPtr spcCreateElement (MatrixPtr Matrix, int Row, int Col, ElementPtr *LastAddr, BOOLEAN Fillin)
 
void spcLinkRows (MatrixPtr Matrix)
 
static void EnlargeMatrix (MatrixPtr Matrix, int NewSize)
 

Macro Definition Documentation

#define M_LN10   2.30258509299404568402

Definition at line 330 of file spbuild.c.

#define M_LN2   0.69314718055994530942

Definition at line 327 of file spbuild.c.

#define spINSIDE_SPARSE

Definition at line 69 of file spbuild.c.

Function Documentation

static void EnlargeMatrix ( )
static
static void EnlargeMatrix ( MatrixPtr  Matrix,
int  NewSize 
)
static

Definition at line 1313 of file spbuild.c.

1317 {
1318 register int I, OldAllocatedSize = Matrix->AllocatedSize;
1319 
1320 /* Begin `EnlargeMatrix'. */
1321  Matrix->Size = NewSize;
1322 
1323  if (NewSize <= OldAllocatedSize)
1324  return;
1325 
1326 /* Expand the matrix frame. */
1327  NewSize = MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
1328  Matrix->AllocatedSize = NewSize;
1329 
1330  if (( REALLOC(Matrix->IntToExtColMap, int, NewSize+1)) == NULL)
1331  { Matrix->Error = spNO_MEMORY;
1332  return;
1333  }
1334  if (( REALLOC(Matrix->IntToExtRowMap, int, NewSize+1)) == NULL)
1335  { Matrix->Error = spNO_MEMORY;
1336  return;
1337  }
1338  if (( REALLOC(Matrix->Diag, ElementPtr, NewSize+1)) == NULL)
1339  { Matrix->Error = spNO_MEMORY;
1340  return;
1341  }
1342  if (( REALLOC(Matrix->FirstInCol, ElementPtr, NewSize+1)) == NULL)
1343  { Matrix->Error = spNO_MEMORY;
1344  return;
1345  }
1346  if (( REALLOC(Matrix->FirstInRow, ElementPtr, NewSize+1)) == NULL)
1347  { Matrix->Error = spNO_MEMORY;
1348  return;
1349  }
1350 
1351 /*
1352  * Destroy the Markowitz and Intermediate vectors, they will be recreated
1353  * in spOrderAndFactor().
1354  */
1355  FREE( Matrix->MarkowitzRow );
1356  FREE( Matrix->MarkowitzCol );
1357  FREE( Matrix->MarkowitzProd );
1358  FREE( Matrix->DoRealDirect );
1359  FREE( Matrix->DoCmplxDirect );
1360  FREE( Matrix->Intermediate );
1361  Matrix->InternalVectorsAllocated = NO;
1362 
1363 /* Initialize the new portion of the vectors. */
1364  for (I = OldAllocatedSize+1; I <= NewSize; I++)
1365  { Matrix->IntToExtColMap[I] = I;
1366  Matrix->IntToExtRowMap[I] = I;
1367  Matrix->Diag[I] = NULL;
1368  Matrix->FirstInRow[I] = NULL;
1369  Matrix->FirstInCol[I] = NULL;
1370  }
1371 
1372  return;
1373 }
int * MarkowitzRow
Definition: spdefs.h:842
int * MarkowitzCol
Definition: spdefs.h:843
ArrayOfElementPtrs FirstInRow
Definition: spdefs.h:836
#define MAX(a, b)
Definition: spdefs.h:135
#define NO
Definition: spdefs.h:113
int Size
Definition: spdefs.h:859
BOOLEAN * DoRealDirect
Definition: spdefs.h:827
long * MarkowitzProd
Definition: spdefs.h:844
#define FREE(ptr)
Definition: spdefs.h:436
#define NULL
Definition: spdefs.h:121
int * IntToExtColMap
Definition: spdefs.h:840
int * IntToExtRowMap
Definition: spdefs.h:841
int Error
Definition: spdefs.h:829
RealVector Intermediate
Definition: spdefs.h:838
BOOLEAN InternalVectorsAllocated
Definition: spdefs.h:839
#define REALLOC(ptr, type, number)
Definition: spdefs.h:434
ArrayOfElementPtrs Diag
Definition: spdefs.h:825
register int I
Definition: spsolve.c:163
#define spNO_MEMORY
Definition: spmatrix.h:105
BOOLEAN * DoCmplxDirect
Definition: spdefs.h:826
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
int AllocatedSize
Definition: spdefs.h:821
static void ExpandTranslationArrays ( )
static
static double my_logb ( double  x)
static

Definition at line 337 of file spbuild.c.

340 {
341  double y = 0.0;
342 
343  if (x != 0.0) {
344  if (x < 0.0)
345  x = - x;
346  while (x > 2.0) {
347  y += 1.0;
348  x /= 2.0;
349  }
350  while (x < 1.0) {
351  y -= 1.0;
352  x *= 2.0;
353  }
354  }
355  else
356  y = 0.0;
357 
358  return (y);
359 }
static double my_scalb ( double  x,
int  n 
)
static

Definition at line 363 of file spbuild.c.

367 {
368  double y, z = 1.0, k = 2.0;
369 
370  if (n < 0) {
371  n = -n;
372  k = 0.5;
373  }
374 
375  if (x != 0.0)
376  for (y = 1.0; n; n >>= 1) {
377  y *= k;
378  if (n & 1)
379  z *= y;
380  }
381 
382  return (x * z);
383 }
int spAddCol ( char *  Matrixp,
int  Accum_Col,
int  Addend_Col 
)

Definition at line 270 of file spbuild.c.

274 {
275  MatrixPtr Matrix = (MatrixPtr)Matrixp;
276  ElementPtr Accum, Addend, Prev;
277 
278  Accum_Col = Matrix->ExtToIntColMap[Accum_Col];
279  Addend_Col = Matrix->ExtToIntColMap[Accum_Col];
280 
281  Accum = Matrix->FirstInCol[Accum_Col];
282  Addend = Matrix->FirstInCol[Addend_Col];
283  Prev = NULL;
284  while (Addend != NULL) {
285  while (Accum && Accum->Row < Addend->Row) {
286  Prev = Accum;
287  Accum = Accum->NextInCol;
288  }
289  if (!Accum || Accum->Row > Addend->Row) {
290  Accum =
291  spcCreateElement(Matrix, Addend->Row, Accum_Col, &Prev, 0);
292  }
293  Accum->Real += Addend->Real;
294  Accum->Imag += Addend->Imag;
295  Addend = Addend->NextInCol;
296  }
297 
298  return spError( (char *)Matrix );
299 }
int spError()
RealNumber Real
Definition: spdefs.h:539
struct MatrixElement * NextInCol
Definition: spdefs.h:547
#define NULL
Definition: spdefs.h:121
ElementPtr spcCreateElement(MatrixPtr Matrix, int Row, int Col, ElementPtr *LastAddr, BOOLEAN Fillin)
Definition: spbuild.c:1115
int * ExtToIntColMap
Definition: spdefs.h:831
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
ElementPtr spcCreateElement ( MatrixPtr  Matrix,
int  Row,
int  Col,
ElementPtr LastAddr,
BOOLEAN  Fillin 
)

Definition at line 1115 of file spbuild.c.

1122 {
1123 register ElementPtr pElement, pLastElement;
1124 ElementPtr pCreatedElement, spcGetElement(), spcGetFillin();
1125 
1126 /* Begin `spcCreateElement'. */
1127 
1128  if (Matrix->RowsLinked)
1129  {
1130 /* Row pointers cannot be ignored. */
1131  if (Fillin)
1132  { pElement = spcGetFillin( Matrix );
1133  Matrix->Fillins++;
1134  }
1135  else
1136  { pElement = spcGetElement( Matrix );
1137  Matrix->NeedsOrdering = YES;
1138  }
1139  if (pElement == NULL) return NULL;
1140 
1141 /* If element is on diagonal, store pointer in Diag. */
1142  if (Row == Col) Matrix->Diag[Row] = pElement;
1143 
1144 /* Initialize Element. */
1145  pCreatedElement = pElement;
1146  pElement->Row = Row;
1147  pElement->Col = Col;
1148  pElement->Real = 0.0;
1149 #if spCOMPLEX
1150  pElement->Imag = 0.0;
1151 #endif
1152 #if INITIALIZE
1153  pElement->pInitInfo = NULL;
1154 #endif
1155 
1156 /* Splice element into column. */
1157  pElement->NextInCol = *LastAddr;
1158  *LastAddr = pElement;
1159 
1160  /* Search row for proper element position. */
1161  pElement = Matrix->FirstInRow[Row];
1162  pLastElement = NULL;
1163  while (pElement != NULL)
1164  {
1165 /* Search for element row position. */
1166  if (pElement->Col < Col)
1167  {
1168 /* Have not reached desired element. */
1169  pLastElement = pElement;
1170  pElement = pElement->NextInRow;
1171  }
1172  else pElement = NULL;
1173  }
1174 
1175 /* Splice element into row. */
1176  pElement = pCreatedElement;
1177  if (pLastElement == NULL)
1178  {
1179 /* Element is first in row. */
1180  pElement->NextInRow = Matrix->FirstInRow[Row];
1181  Matrix->FirstInRow[Row] = pElement;
1182  }
1183  else
1184 /* Element is not first in row. */
1185  {
1186  pElement->NextInRow = pLastElement->NextInRow;
1187  pLastElement->NextInRow = pElement;
1188  }
1189 
1190  }
1191  else
1192  {
1193 /*
1194  * Matrix has not been factored yet. Thus get element rather than fill-in.
1195  * Also, row pointers can be ignored.
1196  */
1197 
1198 /* Allocate memory for Element. */
1199  pElement = spcGetElement( Matrix );
1200  if (pElement == NULL) return NULL;
1201 
1202 /* If element is on diagonal, store pointer in Diag. */
1203  if (Row == Col) Matrix->Diag[Row] = pElement;
1204 
1205 /* Initialize Element. */
1206  pCreatedElement = pElement;
1207  pElement->Row = Row;
1208 #if DEBUG
1209  pElement->Col = Col;
1210 #endif
1211  pElement->Real = 0.0;
1212 #if spCOMPLEX
1213  pElement->Imag = 0.0;
1214 #endif
1215 #if INITIALIZE
1216  pElement->pInitInfo = NULL;
1217 #endif
1218 
1219 /* Splice element into column. */
1220  pElement->NextInCol = *LastAddr;
1221  *LastAddr = pElement;
1222  }
1223 
1224  Matrix->Elements++;
1225  return pCreatedElement;
1226 }
ElementPtr spcGetElement()
ArrayOfElementPtrs FirstInRow
Definition: spdefs.h:836
RealNumber Real
Definition: spdefs.h:539
struct MatrixElement * NextInCol
Definition: spdefs.h:547
BOOLEAN NeedsOrdering
Definition: spdefs.h:846
#define NULL
Definition: spdefs.h:121
register ElementPtr pElement
Definition: spsolve.c:158
ElementPtr spcGetFillin()
int Fillins
Definition: spdefs.h:834
BOOLEAN RowsLinked
Definition: spdefs.h:855
#define YES
Definition: spdefs.h:114
int Elements
Definition: spdefs.h:828
struct MatrixElement * NextInRow
Definition: spdefs.h:546
ArrayOfElementPtrs Diag
Definition: spdefs.h:825
ElementPtr spcFindElementInCol ( MatrixPtr  Matrix,
ElementPtr LastAddr,
int  Row,
int  Col,
BOOLEAN  CreateIfMissing 
)

Definition at line 692 of file spbuild.c.

699 {
700 register ElementPtr pElement;
702 
703 /* Begin `spcFindElementInCol'. */
704  pElement = *LastAddr;
705 
706 /* Search for element. */
707  while (pElement != NULL)
708  { if (pElement->Row < Row)
709  {
710 /* Have not reached element yet. */
711  LastAddr = &(pElement->NextInCol);
712  pElement = pElement->NextInCol;
713  }
714  else if (pElement->Row == Row)
715  {
716 /* Reached element. */
717  return pElement;
718  }
719  else break; /* while loop */
720  }
721 
722 /* Element does not exist and must be created. */
723  if (CreateIfMissing)
724  return spcCreateElement( Matrix, Row, Col, LastAddr, NO );
725  else return NULL;
726 }
#define NO
Definition: spdefs.h:113
struct MatrixElement * NextInCol
Definition: spdefs.h:547
#define NULL
Definition: spdefs.h:121
register ElementPtr pElement
Definition: spsolve.c:158
ElementPtr spcCreateElement(MatrixPtr Matrix, int Row, int Col, ElementPtr *LastAddr, BOOLEAN Fillin)
Definition: spbuild.c:1115
void spClear ( char *  eMatrix)

Definition at line 492 of file spbuild.c.

495 {
496 MatrixPtr Matrix = (MatrixPtr)eMatrix;
497 register ElementPtr pElement;
498 register int I;
499 
500 /* Begin `spClear'. */
501  ASSERT( IS_SPARSE( Matrix ) );
502 
503 /* Clear matrix. */
504 #if spCOMPLEX
505  if (Matrix->PreviousMatrixWasComplex OR Matrix->Complex)
506  { for (I = Matrix->Size; I > 0; I--)
507  { pElement = Matrix->FirstInCol[I];
508  while (pElement != NULL)
509  { pElement->Real = 0.0;
510  pElement->Imag = 0.0;
511  pElement = pElement->NextInCol;
512  }
513  }
514  }
515  else
516 #endif
517  { for (I = Matrix->Size; I > 0; I--)
518  { pElement = Matrix->FirstInCol[I];
519  while (pElement != NULL)
520  { pElement->Real = 0.0;
521  pElement = pElement->NextInCol;
522  }
523  }
524  }
525 
526 /* Empty the trash. */
527  Matrix->TrashCan.Real = 0.0;
528 #if spCOMPLEX
529  Matrix->TrashCan.Imag = 0.0;
530 #endif
531 
532  Matrix->Error = spOKAY;
533  Matrix->Factored = NO;
534  Matrix->SingularCol = 0;
535  Matrix->SingularRow = 0;
536  Matrix->PreviousMatrixWasComplex = Matrix->Complex;
537  return;
538 }
#define NO
Definition: spdefs.h:113
int Size
Definition: spdefs.h:859
int SingularCol
Definition: spdefs.h:856
int SingularRow
Definition: spdefs.h:857
#define spOKAY
Definition: spmatrix.h:101
RealNumber Real
Definition: spdefs.h:539
#define IS_SPARSE(matrix)
Definition: spdefs.h:125
BOOLEAN PreviousMatrixWasComplex
Definition: spdefs.h:852
struct MatrixElement * NextInCol
Definition: spdefs.h:547
BOOLEAN Factored
Definition: spdefs.h:833
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
#define NULL
Definition: spdefs.h:121
#define OR
Definition: fteparse.h:93
register ElementPtr pElement
Definition: spsolve.c:158
int Error
Definition: spdefs.h:829
BOOLEAN Complex
Definition: spdefs.h:823
struct MatrixElement TrashCan
Definition: spdefs.h:860
register int I
Definition: spsolve.c:163
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
void spcLinkRows ( MatrixPtr  Matrix)

Definition at line 1262 of file spbuild.c.

1265 {
1266 register ElementPtr pElement, *FirstInRowEntry;
1267 register ArrayOfElementPtrs FirstInRowArray;
1268 register int Col;
1269 
1270 /* Begin `spcLinkRows'. */
1271  FirstInRowArray = Matrix->FirstInRow;
1272  for (Col = Matrix->Size; Col >= 1; Col--)
1273  {
1274 /* Generate row links for the elements in the Col'th column. */
1275  pElement = Matrix->FirstInCol[Col];
1276 
1277  while (pElement != NULL)
1278  { pElement->Col = Col;
1279  FirstInRowEntry = &FirstInRowArray[pElement->Row];
1280  pElement->NextInRow = *FirstInRowEntry;
1281  *FirstInRowEntry = pElement;
1282  pElement = pElement->NextInCol;
1283  }
1284  }
1285  Matrix->RowsLinked = YES;
1286  return;
1287 }
ArrayOfElementPtrs FirstInRow
Definition: spdefs.h:836
int Size
Definition: spdefs.h:859
struct MatrixElement * NextInCol
Definition: spdefs.h:547
#define NULL
Definition: spdefs.h:121
register ElementPtr pElement
Definition: spsolve.c:158
BOOLEAN RowsLinked
Definition: spdefs.h:855
#define YES
Definition: spdefs.h:114
struct MatrixElement * NextInRow
Definition: spdefs.h:546
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
int spDProd ( char *  Matrix,
double *  pMantissaR,
double *  pMantissaI,
int *  pExponent 
)

Definition at line 390 of file spbuild.c.

396 {
397  double re, im, x, y, z;
398  int p;
399 
400  spDeterminant( (char *)Matrix, &p, &re, &im);
401 
402 #ifdef debug_print
403  printf("Determinant 10: (%20g,%20g)^%d\n", re, im, p);
404 #endif
405 
406  /* Convert base 10 numbers to base 2 numbers, for comparison */
407  y = p * M_LN10 / M_LN2;
408  x = (int) y;
409  y -= x;
410 
411  /* ASSERT
412  * x = integral part of exponent, y = fraction part of exponent
413  */
414 
415  /* Fold in the fractional part */
416 #ifdef debug_print
417  printf(" ** base10 -> base2 int = %g, frac = %20g\n", x, y);
418 #endif
419  z = pow(2.0, y);
420  re *= z;
421  im *= z;
422 #ifdef debug_print
423  printf(" ** multiplier = %20g\n", z);
424 #endif
425 
426  /* Re-normalize (re or im may be > 2.0 or both < 1.0 */
427  if (re != 0.0) {
428  y = my_logb(re);
429  if (im != 0.0)
430  z = my_logb(im);
431  else
432  z = 0;
433  }
434  else if (im != 0.0) {
435  z = my_logb(im);
436  y = 0;
437  }
438  else {
439  /* Singular */
440  /*printf("10 -> singular\n");*/
441  y = 0;
442  z = 0;
443  }
444 
445 #ifdef debug_print
446  printf(" ** renormalize changes = %g,%g\n", y, z);
447 #endif
448  if (y < z)
449  y = z;
450 
451  *pExponent = x + y;
452  x = my_scalb(re, (int) -y);
453  z = my_scalb(im, (int) -y);
454 #ifdef debug_print
455  printf(" ** values are: re %g, im %g, y %g, re' %g, im' %g\n",
456  re, im, y, x, z);
457 #endif
458  *pMantissaR = my_scalb(re, (int) -y);
459  *pMantissaI = my_scalb(im, (int) -y);
460 
461 #ifdef debug_print
462  printf("Determinant 10->2: (%20g,%20g)^%d\n", *pMantissaR,
463  *pMantissaI, *pExponent);
464 #endif
465  return spError( (char *)Matrix );
466 }
#define M_LN10
Definition: spbuild.c:330
int spError()
FILE * p
Definition: proc2mod.c:48
#define M_LN2
Definition: spbuild.c:327
void spDeterminant()
static double my_logb(double x)
Definition: spbuild.c:337
static double my_scalb(double x, int n)
Definition: spbuild.c:363
RealNumber* spGetElement ( char *  eMatrix,
int  Row,
int  Col 
)

Definition at line 586 of file spbuild.c.

590 {
591 MatrixPtr Matrix = (MatrixPtr)eMatrix;
594 void Translate();
595 
596 /* Begin `spGetElement'. */
597  ASSERT( IS_SPARSE( Matrix ) AND Row >= 0 AND Col >= 0 );
598 
599  if ((Row == 0) OR (Col == 0))
600  return &Matrix->TrashCan.Real;
601 
602 #if NOT TRANSLATE
603  ASSERT(Matrix->NeedsOrdering);
604 #endif
605 
606 #if TRANSLATE
607  Translate( Matrix, &Row, &Col );
608  if (Matrix->Error == spNO_MEMORY) return NULL;
609 #endif
610 
611 #if NOT TRANSLATE
612 #if NOT EXPANDABLE
613  ASSERT(Row <= Matrix->Size AND Col <= Matrix->Size);
614 #endif
615 
616 #if EXPANDABLE
617 /* Re-size Matrix if necessary. */
618  if ((Row > Matrix->Size) OR (Col > Matrix->Size))
619  EnlargeMatrix( Matrix, MAX(Row, Col) );
620  if (Matrix->Error == spNO_MEMORY) return NULL;
621 #endif
622 #endif
623 
624 /*
625  * The condition part of the following if statement tests to see if the
626  * element resides along the diagonal, if it does then it tests to see
627  * if the element has been created yet (Diag pointer not NULL). The
628  * pointer to the element is then assigned to Element after it is cast
629  * into a pointer to a RealNumber. This casting makes the pointer into
630  * a pointer to Real. This statement depends on the fact that Real
631  * is the first record in the MatrixElement structure.
632  */
633 
634  if ((Row != Col) OR ((pElement = (RealNumber *)Matrix->Diag[Row]) == NULL))
635  {
636 /*
637  * Element does not exist or does not reside along diagonal. Search
638  * column for element. As in the if statement above, the pointer to the
639  * element which is returned by spcFindElementInCol is cast into a
640  * pointer to Real, a RealNumber.
641  */
642  pElement = (RealNumber*)spcFindElementInCol( Matrix,
643  &(Matrix->FirstInCol[Col]),
644  Row, Col, YES );
645  }
646  return pElement;
647 }
#define MAX(a, b)
Definition: spdefs.h:135
int Size
Definition: spdefs.h:859
RealNumber Real
Definition: spdefs.h:539
#define IS_SPARSE(matrix)
Definition: spdefs.h:125
BOOLEAN NeedsOrdering
Definition: spdefs.h:846
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
#define NULL
Definition: spdefs.h:121
#define OR
Definition: fteparse.h:93
register ElementPtr pElement
Definition: spsolve.c:158
register int Size
Definition: spsolve.c:163
static void Translate()
int Error
Definition: spdefs.h:829
spREAL RealNumber
Definition: spdefs.h:458
struct MatrixElement TrashCan
Definition: spdefs.h:860
#define YES
Definition: spdefs.h:114
ElementPtr spcFindElementInCol(MatrixPtr Matrix, ElementPtr *LastAddr, int Row, int Col, BOOLEAN CreateIfMissing)
Definition: spbuild.c:692
ArrayOfElementPtrs Diag
Definition: spdefs.h:825
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
static void EnlargeMatrix()
#define spNO_MEMORY
Definition: spmatrix.h:105
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
#define AND
Definition: fteparse.h:92
void spGetStat ( char *  Matrixp,
int *  Size,
int *  NonZero,
int *  FillIns 
)

Definition at line 252 of file spbuild.c.

256 {
257  MatrixPtr Matrix = (MatrixPtr)Matrixp;
258 
259  if (Matrix == (MatrixPtr)0) return;
260  *Size = Matrix->Size;
261  *NonZero = Matrix->Elements;
262  *FillIns = Matrix->Fillins;
263 }
int Size
Definition: spdefs.h:859
register int Size
Definition: spsolve.c:163
int Fillins
Definition: spdefs.h:834
int Elements
Definition: spdefs.h:828
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
void spItoR ( char *  eMatrix)

Definition at line 120 of file spbuild.c.

123 {
124 MatrixPtr Matrix = (MatrixPtr)eMatrix;
125 register ElementPtr pElement;
126 register int I;
127 
128 /* Begin `spClear'. */
129  ASSERT( IS_SPARSE( Matrix ) );
130 
131 #if spCOMPLEX
132  { for (I = Matrix->Size; I > 0; I--)
133  { pElement = Matrix->FirstInCol[I];
134  while (pElement != NULL)
135  { pElement->Real = pElement->Init;
136  pElement = pElement->NextInCol;
137  }
138  }
139  }
140 #endif
141 
142 /* Empty the trash. */
143  Matrix->TrashCan.Real = 0.0;
144 #if spCOMPLEX
145  Matrix->TrashCan.Imag = 0.0;
146 #endif
147 
148  Matrix->Error = spOKAY;
149  Matrix->Factored = NO;
150  Matrix->SingularCol = 0;
151  Matrix->SingularRow = 0;
152  Matrix->PreviousMatrixWasComplex = Matrix->Complex;
153  return;
154 }
RealNumber Init
Definition: spdefs.h:543
#define NO
Definition: spdefs.h:113
int Size
Definition: spdefs.h:859
int SingularCol
Definition: spdefs.h:856
int SingularRow
Definition: spdefs.h:857
#define spOKAY
Definition: spmatrix.h:101
RealNumber Real
Definition: spdefs.h:539
#define IS_SPARSE(matrix)
Definition: spdefs.h:125
BOOLEAN PreviousMatrixWasComplex
Definition: spdefs.h:852
struct MatrixElement * NextInCol
Definition: spdefs.h:547
BOOLEAN Factored
Definition: spdefs.h:833
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
#define NULL
Definition: spdefs.h:121
register ElementPtr pElement
Definition: spsolve.c:158
int Error
Definition: spdefs.h:829
BOOLEAN Complex
Definition: spdefs.h:823
struct MatrixElement TrashCan
Definition: spdefs.h:860
register int I
Definition: spsolve.c:163
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
void spLoadGmin ( char *  Matrixp,
double  Gmin 
)

Definition at line 224 of file spbuild.c.

228 {
229  MatrixPtr Matrix = (MatrixPtr)Matrixp;
230  int I;
231  ArrayOfElementPtrs Diag;
232  ElementPtr diag;
233 
234 /* Begin `LoadGmin'. */
235  ASSERT( IS_SPARSE( Matrix ) );
236 
237  if (Gmin != 0.0) {
238  Diag = Matrix->Diag;
239  for (I = Matrix->Size; I > 0; I--) {
240  if (diag = Diag[I])
241  diag->Real += Gmin;
242  }
243  }
244  return;
245 }
int Size
Definition: spdefs.h:859
RealNumber Real
Definition: spdefs.h:539
#define IS_SPARSE(matrix)
Definition: spdefs.h:125
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
ArrayOfElementPtrs Diag
Definition: spdefs.h:825
register int I
Definition: spsolve.c:163
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
void spRtoI ( char *  eMatrix)

Definition at line 176 of file spbuild.c.

179 {
180 MatrixPtr Matrix = (MatrixPtr)eMatrix;
181 register ElementPtr pElement;
182 register int I;
183 
184 /* Begin `spClear'. */
185  ASSERT( IS_SPARSE( Matrix ) );
186 
187 #if spCOMPLEX
188  { for (I = Matrix->Size; I > 0; I--)
189  { pElement = Matrix->FirstInCol[I];
190  while (pElement != NULL)
191  { pElement->Init = pElement->Real;
192  pElement = pElement->NextInCol;
193  }
194  }
195  }
196 #endif
197 
198 /* Empty the trash. */
199  Matrix->TrashCan.Real = 0.0;
200 #if spCOMPLEX
201  Matrix->TrashCan.Imag = 0.0;
202 #endif
203 
204  Matrix->Error = spOKAY;
205  Matrix->Factored = NO;
206  Matrix->SingularCol = 0;
207  Matrix->SingularRow = 0;
208  Matrix->PreviousMatrixWasComplex = Matrix->Complex;
209  return;
210 }
RealNumber Init
Definition: spdefs.h:543
#define NO
Definition: spdefs.h:113
int Size
Definition: spdefs.h:859
int SingularCol
Definition: spdefs.h:856
int SingularRow
Definition: spdefs.h:857
#define spOKAY
Definition: spmatrix.h:101
RealNumber Real
Definition: spdefs.h:539
#define IS_SPARSE(matrix)
Definition: spdefs.h:125
BOOLEAN PreviousMatrixWasComplex
Definition: spdefs.h:852
struct MatrixElement * NextInCol
Definition: spdefs.h:547
BOOLEAN Factored
Definition: spdefs.h:833
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
#define NULL
Definition: spdefs.h:121
register ElementPtr pElement
Definition: spsolve.c:158
int Error
Definition: spdefs.h:829
BOOLEAN Complex
Definition: spdefs.h:823
struct MatrixElement TrashCan
Definition: spdefs.h:860
register int I
Definition: spsolve.c:163
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
int spZeroCol ( char *  Matrixp,
int  Col 
)

Definition at line 306 of file spbuild.c.

310 {
311  MatrixPtr Matrix = (MatrixPtr)Matrixp;
312  ElementPtr Element;
313 
314  Col = Matrix->ExtToIntColMap[Col];
315 
316  for (Element = Matrix->FirstInCol[Col]; Element != NULL;
317  Element = Element->NextInCol) {
318  Element->Real = 0.0;
319  Element->Imag = 0.0;
320  }
321 
322  return spError( (char *)Matrix );
323 }
int spError()
RealNumber Real
Definition: spdefs.h:539
struct MatrixElement * NextInCol
Definition: spdefs.h:547
#define NULL
Definition: spdefs.h:121
int * ExtToIntColMap
Definition: spdefs.h:831
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
static void Translate ( )
static