NEURON
spdefs.h
Go to the documentation of this file.
1 /*
2  * DATA STRUCTURE AND MACRO DEFINITIONS for Sparse.
3  *
4  * Author: Advising professor:
5  * Kenneth S. Kundert Alberto Sangiovanni-Vincentelli
6  * UC Berkeley
7  *
8  * This file contains common type definitions and macros for the sparse
9  * matrix routines. These definitions are of no interest to the user.
10  */
11 
12 
13 /*
14  * Revision and copyright information.
15  *
16  * Copyright (c) 1985,86,87,88
17  * by Kenneth S. Kundert and the University of California.
18  *
19  * Permission to use, copy, modify, and distribute this software and
20  * its documentation for any purpose and without fee is hereby granted,
21  * provided that the copyright notices appear in all copies and
22  * supporting documentation and that the authors and the University of
23  * California are properly credited. The authors and the University of
24  * California make no representations as to the suitability of this
25  * software for any purpose. It is provided `as is', without express
26  * or implied warranty.
27  *
28  * $Date: 2004-04-24 23:28:33 +0200 (Sat, 24 Apr 2004) $
29  * $Revision: 616 $
30  */
31 
32 
33 /*
34  * IMPORTS
35  */
36 
37 #include <stdio.h>
38 
39 
40 /*
41  * If running lint, change some of the compiler options to get a more
42  * complete inspection.
43  */
44 
45 #ifdef lint
46 #undef REAL
47 #undef spCOMPLEX
48 #undef EXPANDABLE
49 #undef TRANSLATE
50 #undef INITIALIZE
51 #undef DELETE
52 #undef STRIP
53 #undef MODIFIED_NODAL
54 #undef QUAD_ELEMENT
55 #undef TRANSPOSE
56 #undef SCALING
57 #undef DOCUMENTATION
58 #undef MULTIPLICATION
59 #undef DETERMINANT
60 #undef CONDITION
61 #undef PSEUDOCONDITION
62 #undef FORTRAN
63 #undef DEBUG
64 
65 #define REAL YES
66 #define spCOMPLEX YES
67 #define EXPANDABLE YES
68 #define TRANSLATE YES
69 #define INITIALIZE YES
70 #define DELETE YES
71 #define STRIP YES
72 #define MODIFIED_NODAL YES
73 #define QUAD_ELEMENT YES
74 #define TRANSPOSE YES
75 #define SCALING YES
76 #define DOCUMENTATION YES
77 #define MULTIPLICATION YES
78 #define DETERMINANT YES
79 #define CONDITION YES
80 #define PSEUDOCONDITION YES
81 #define FORTRAN YES
82 #define DEBUG YES
83 
84 #define LINT YES
85 #else /* not lint */
86 #define LINT NO
87 #endif /* not lint */
88 
89 
90 
91 
92 
93 
94 
95 /*
96  * MACRO DEFINITIONS
97  *
98  * Macros are distinguished by using solely capital letters in their
99  * identifiers. This contrasts with C defined identifiers which are strictly
100  * lower case, and program variable and procedure names which use both upper
101  * and lower case.
102  */
103 
104 /* Begin macros. */
105 
106 /* Boolean data type */
107 #define BOOLEAN int
108 #define NO 0
109 #define YES 1
110 #define NOT !
111 #define AND &&
112 #define OR ||
113 
114 /* NULL pointer */
115 #ifndef NULL
116 #define NULL 0
117 #endif
118 
119 #define SPARSE_ID 0x772773 /* Arbitrary (is Sparse on phone). */
120 #define IS_SPARSE(matrix) ((matrix) != NULL && \
121  (matrix)->ID == SPARSE_ID)
122 #define IS_VALID(matrix) ((matrix) != NULL && \
123  (matrix)->ID == SPARSE_ID && \
124  (matrix)->Error >= spOKAY && \
125  (matrix)->Error < spFATAL)
126 #define IS_FACTORED(matrix) ((matrix)->Factored && !(matrix)->NeedsOrdering)
127 
128 /* Macro commands */
129 /* Macro functions that return the maximum or minimum independent of type. */
130 #define MAX(a,b) ((a) > (b) ? (a) : (b))
131 #define MIN(a,b) ((a) < (b) ? (a) : (b))
132 
133 /* Macro function that returns the absolute value of a floating point number. */
134 #define ABS(a) ((a) < 0.0 ? -(a) : (a))
135 
136 /* Macro function that returns the square of a number. */
137 #define SQR(a) ((a)*(a))
138 
139 /* Macro procedure that swaps two entities. */
140 #define SWAP(type, a, b) {type swapx; swapx = a; a = b; b = swapx;}
141 
142 /* Macro function that returns the approx absolute value of a complex number. */
143 #if spCOMPLEX
144 #define ELEMENT_MAG(ptr) (ABS((ptr)->Real) + ABS((ptr)->Imag))
145 #else
146 #define ELEMENT_MAG(ptr) ((ptr)->Real < 0.0 ? -(ptr)->Real : (ptr)->Real)
147 #endif
148 
149 /* Complex assignment statements. */
150 #define CMPLX_ASSIGN(to,from) \
151 { (to).Real = (from).Real; \
152  (to).Imag = (from).Imag; \
153 }
154 #define CMPLX_CONJ_ASSIGN(to,from) \
155 { (to).Real = (from).Real; \
156  (to).Imag = -(from).Imag; \
157 }
158 #define CMPLX_NEGATE_ASSIGN(to,from) \
159 { (to).Real = -(from).Real; \
160  (to).Imag = -(from).Imag; \
161 }
162 #define CMPLX_CONJ_NEGATE_ASSIGN(to,from) \
163 { (to).Real = -(from).Real; \
164  (to).Imag = (from).Imag; \
165 }
166 #define CMPLX_CONJ(a) (a).Imag = -(a).Imag
167 #define CMPLX_NEGATE(a) \
168 { (a).Real = -(a).Real; \
169  (a).Imag = -(a).Imag; \
170 }
171 
172 /* Macro that returns the approx magnitude (L-1 norm) of a complex number. */
173 #define CMPLX_1_NORM(a) (ABS((a).Real) + ABS((a).Imag))
174 
175 /* Macro that returns the approx magnitude (L-infinity norm) of a complex. */
176 #define CMPLX_INF_NORM(a) (MAX (ABS((a).Real),ABS((a).Imag)))
177 
178 /* Macro function that returns the magnitude (L-2 norm) of a complex number. */
179 #define CMPLX_2_NORM(a) (sqrt((a).Real*(a).Real + (a).Imag*(a).Imag))
180 
181 /* Macro function that performs complex addition. */
182 #define CMPLX_ADD(to,from_a,from_b) \
183 { (to).Real = (from_a).Real + (from_b).Real; \
184  (to).Imag = (from_a).Imag + (from_b).Imag; \
185 }
186 
187 /* Macro function that performs complex subtraction. */
188 #define CMPLX_SUBT(to,from_a,from_b) \
189 { (to).Real = (from_a).Real - (from_b).Real; \
190  (to).Imag = (from_a).Imag - (from_b).Imag; \
191 }
192 
193 /* Macro function that is equivalent to += operator for complex numbers. */
194 #define CMPLX_ADD_ASSIGN(to,from) \
195 { (to).Real += (from).Real; \
196  (to).Imag += (from).Imag; \
197 }
198 
199 /* Macro function that is equivalent to -= operator for complex numbers. */
200 #define CMPLX_SUBT_ASSIGN(to,from) \
201 { (to).Real -= (from).Real; \
202  (to).Imag -= (from).Imag; \
203 }
204 
205 /* Macro function that multiplies a complex number by a scalar. */
206 #define SCLR_MULT(to,sclr,cmplx) \
207 { (to).Real = (sclr) * (cmplx).Real; \
208  (to).Imag = (sclr) * (cmplx).Imag; \
209 }
210 
211 /* Macro function that multiply-assigns a complex number by a scalar. */
212 #define SCLR_MULT_ASSIGN(to,sclr) \
213 { (to).Real *= (sclr); \
214  (to).Imag *= (sclr); \
215 }
216 
217 /* Macro function that multiplies two complex numbers. */
218 #define CMPLX_MULT(to,from_a,from_b) \
219 { (to).Real = (from_a).Real * (from_b).Real - \
220  (from_a).Imag * (from_b).Imag; \
221  (to).Imag = (from_a).Real * (from_b).Imag + \
222  (from_a).Imag * (from_b).Real; \
223 }
224 
225 /* Macro function that implements to *= from for complex numbers. */
226 #define CMPLX_MULT_ASSIGN(to,from) \
227 { RealNumber to_real_ = (to).Real; \
228  (to).Real = to_real_ * (from).Real - \
229  (to).Imag * (from).Imag; \
230  (to).Imag = to_real_ * (from).Imag + \
231  (to).Imag * (from).Real; \
232 }
233 
234 /* Macro function that multiplies two complex numbers, the first of which is
235  * conjugated. */
236 #define CMPLX_CONJ_MULT(to,from_a,from_b) \
237 { (to).Real = (from_a).Real * (from_b).Real + \
238  (from_a).Imag * (from_b).Imag; \
239  (to).Imag = (from_a).Real * (from_b).Imag - \
240  (from_a).Imag * (from_b).Real; \
241 }
242 
243 /* Macro function that multiplies two complex numbers and then adds them
244  * to another. to = add + mult_a * mult_b */
245 #define CMPLX_MULT_ADD(to,mult_a,mult_b,add) \
246 { (to).Real = (mult_a).Real * (mult_b).Real - \
247  (mult_a).Imag * (mult_b).Imag + (add).Real; \
248  (to).Imag = (mult_a).Real * (mult_b).Imag + \
249  (mult_a).Imag * (mult_b).Real + (add).Imag; \
250 }
251 
252 /* Macro function that subtracts the product of two complex numbers from
253  * another. to = subt - mult_a * mult_b */
254 #define CMPLX_MULT_SUBT(to,mult_a,mult_b,subt) \
255 { (to).Real = (subt).Real - (mult_a).Real * (mult_b).Real + \
256  (mult_a).Imag * (mult_b).Imag; \
257  (to).Imag = (subt).Imag - (mult_a).Real * (mult_b).Imag - \
258  (mult_a).Imag * (mult_b).Real; \
259 }
260 
261 /* Macro function that multiplies two complex numbers and then adds them
262  * to another. to = add + mult_a* * mult_b where mult_a* represents mult_a
263  * conjugate. */
264 #define CMPLX_CONJ_MULT_ADD(to,mult_a,mult_b,add) \
265 { (to).Real = (mult_a).Real * (mult_b).Real + \
266  (mult_a).Imag * (mult_b).Imag + (add).Real; \
267  (to).Imag = (mult_a).Real * (mult_b).Imag - \
268  (mult_a).Imag * (mult_b).Real + (add).Imag; \
269 }
270 
271 /* Macro function that multiplies two complex numbers and then adds them
272  * to another. to += mult_a * mult_b */
273 #define CMPLX_MULT_ADD_ASSIGN(to,from_a,from_b) \
274 { (to).Real += (from_a).Real * (from_b).Real - \
275  (from_a).Imag * (from_b).Imag; \
276  (to).Imag += (from_a).Real * (from_b).Imag + \
277  (from_a).Imag * (from_b).Real; \
278 }
279 
280 /* Macro function that multiplies two complex numbers and then subtracts them
281  * from another. */
282 #define CMPLX_MULT_SUBT_ASSIGN(to,from_a,from_b) \
283 { (to).Real -= (from_a).Real * (from_b).Real - \
284  (from_a).Imag * (from_b).Imag; \
285  (to).Imag -= (from_a).Real * (from_b).Imag + \
286  (from_a).Imag * (from_b).Real; \
287 }
288 
289 /* Macro function that multiplies two complex numbers and then adds them
290  * to the destination. to += from_a* * from_b where from_a* represents from_a
291  * conjugate. */
292 #define CMPLX_CONJ_MULT_ADD_ASSIGN(to,from_a,from_b) \
293 { (to).Real += (from_a).Real * (from_b).Real + \
294  (from_a).Imag * (from_b).Imag; \
295  (to).Imag += (from_a).Real * (from_b).Imag - \
296  (from_a).Imag * (from_b).Real; \
297 }
298 
299 /* Macro function that multiplies two complex numbers and then subtracts them
300  * from the destination. to -= from_a* * from_b where from_a* represents from_a
301  * conjugate. */
302 #define CMPLX_CONJ_MULT_SUBT_ASSIGN(to,from_a,from_b) \
303 { (to).Real -= (from_a).Real * (from_b).Real + \
304  (from_a).Imag * (from_b).Imag; \
305  (to).Imag -= (from_a).Real * (from_b).Imag - \
306  (from_a).Imag * (from_b).Real; \
307 }
308 
309 /*
310  * Macro functions that provide complex division.
311  */
312 
313 /* Complex division: to = num / den */
314 #define CMPLX_DIV(to,num,den) \
315 { RealNumber r_, s_; \
316  if (((den).Real >= (den).Imag AND (den).Real > -(den).Imag) OR \
317  ((den).Real < (den).Imag AND (den).Real <= -(den).Imag)) \
318  { r_ = (den).Imag / (den).Real; \
319  s_ = (den).Real + r_*(den).Imag; \
320  (to).Real = ((num).Real + r_*(num).Imag)/s_; \
321  (to).Imag = ((num).Imag - r_*(num).Real)/s_; \
322  } \
323  else \
324  { r_ = (den).Real / (den).Imag; \
325  s_ = (den).Imag + r_*(den).Real; \
326  (to).Real = (r_*(num).Real + (num).Imag)/s_; \
327  (to).Imag = (r_*(num).Imag - (num).Real)/s_; \
328  } \
329 }
330 
331 /* Complex division and assignment: num /= den */
332 #define CMPLX_DIV_ASSIGN(num,den) \
333 { RealNumber r_, s_, t_; \
334  if (((den).Real >= (den).Imag AND (den).Real > -(den).Imag) OR \
335  ((den).Real < (den).Imag AND (den).Real <= -(den).Imag)) \
336  { r_ = (den).Imag / (den).Real; \
337  s_ = (den).Real + r_*(den).Imag; \
338  t_ = ((num).Real + r_*(num).Imag)/s_; \
339  (num).Imag = ((num).Imag - r_*(num).Real)/s_; \
340  (num).Real = t_; \
341  } \
342  else \
343  { r_ = (den).Real / (den).Imag; \
344  s_ = (den).Imag + r_*(den).Real; \
345  t_ = (r_*(num).Real + (num).Imag)/s_; \
346  (num).Imag = (r_*(num).Imag - (num).Real)/s_; \
347  (num).Real = t_; \
348  } \
349 }
350 
351 /* Complex reciprocation: to = 1.0 / den */
352 #define CMPLX_RECIPROCAL(to,den) \
353 { RealNumber r_; \
354  if (((den).Real >= (den).Imag AND (den).Real > -(den).Imag) OR \
355  ((den).Real < (den).Imag AND (den).Real <= -(den).Imag)) \
356  { r_ = (den).Imag / (den).Real; \
357  (to).Imag = -r_*((to).Real = 1.0/((den).Real + r_*(den).Imag)); \
358  } \
359  else \
360  { r_ = (den).Real / (den).Imag; \
361  (to).Real = -r_*((to).Imag = -1.0/((den).Imag + r_*(den).Real));\
362  } \
363 }
364 
365 
366 
367 
368 
369 
370 /*
371  * ASSERT and ABORT
372  *
373  * Macro used to assert that if the code is working correctly, then
374  * a condition must be true. If not, then execution is terminated
375  * and an error message is issued stating that there is an internal
376  * error and giving the file and line number. These assertions are
377  * not evaluated unless the DEBUG flag is true.
378  */
379 
380 #if DEBUG
381 #define ASSERT(condition) if (NOT(condition)) ABORT()
382 #else
383 #define ASSERT(condition)
384 #endif
385 
386 #if DEBUG
387 #define ABORT() \
388 { (void)fflush(stdout); \
389  (void)fprintf(stderr, "sparse: panic in file `%s' at line %d.\n", \
390  __FILE__, __LINE__); \
391  (void)fflush(stderr); \
392  abort(); \
393 }
394 #else
395 #define ABORT()
396 #endif
397 
398 
399 
400 
401 
402 /*
403  * IMAGINARY VECTORS
404  *
405  * The imaginary vectors iRHS and iSolution are only needed when the
406  * options spCOMPLEX and spSEPARATED_COMPLEX_VECTORS are set. The following
407  * macro makes it easy to include or exclude these vectors as needed.
408  */
409 
410 #if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
411 #define IMAG_VECTORS , iRHS, iSolution
412 #define IMAG_RHS , iRHS
413 #else
414 #define IMAG_VECTORS
415 #define IMAG_RHS
416 #endif
417 
418 
419 
420 
421 
422 
423 /*
424  * MEMORY ALLOCATION
425  */
426 #if 1
427 #include <stdlib.h>
428 #else
429 #if !defined(__MWERKS__)
430 extern char *malloc(), *calloc(), *realloc();
431 
432 #ifdef ultrix
433  extern void free();
434  extern void abort();
435 #else
436  extern free();
437  extern abort();
438 #endif
439 #endif
440 #endif
441 
442 #define ALLOC(type,number) ((type *)malloc((unsigned)(sizeof(type)*(number))))
443 #define REALLOC(ptr,type,number) \
444  ptr = (type *)realloc((char *)ptr,(unsigned)(sizeof(type)*(number)))
445 /* prevent setting an already freed value to NULL */
446 #define FREE(ptr) { if ((ptr) != NULL) {char* p = (char*)(ptr); (ptr) = NULL; free(p);} }
447 
448 
449 /* Calloc that properly handles allocating a cleared vector. */
450 #define CALLOC(ptr,type,number) \
451 { int i; ptr = ALLOC(type, number); \
452  if (ptr != (type *)NULL) \
453  for(i=(number)-1;i>=0; i--) ptr[i] = (type) 0; \
454 }
455 
456 
457 
458 
459 
460 
461 
462 /*
463  * REAL NUMBER
464  */
465 
466 /* Begin `RealNumber'. */
467 
469 
470 
471 
472 
473 
474 
475 
476 
477 /*
478  * COMPLEX NUMBER DATA STRUCTURE
479  *
480  * >>> Structure fields:
481  * Real (RealNumber)
482  * The real portion of the number. Real must be the first
483  * field in this structure.
484  * Imag (RealNumber)
485  * The imaginary portion of the number. This field must follow
486  * immediately after Real.
487  */
488 
489 /* Begin `ComplexNumber'. */
490 
491 typedef struct
495 
496 
497 
498 
499 
500 
501 
502 
503 /*
504  * MATRIX ELEMENT DATA STRUCTURE
505  *
506  * Every nonzero element in the matrix is stored in a dynamically allocated
507  * MatrixElement structure. These structures are linked together in an
508  * orthogonal linked list. Two different MatrixElement structures exist.
509  * One is used when only real matrices are expected, it is missing an entry
510  * for imaginary data. The other is used if complex matrices are expected.
511  * It contains an entry for imaginary data.
512  *
513  * >>> Structure fields:
514  * Real (RealNumber)
515  * The real portion of the value of the element. Real must be the first
516  * field in this structure.
517  * Imag (RealNumber)
518  * The imaginary portion of the value of the element. If the matrix
519  * routines are not compiled to handle complex matrices, then this
520  * field does not exist. If it exists, it must follow immediately after
521  * Real.
522  * Row (int)
523  * The row number of the element.
524  * Col (int)
525  * The column number of the element.
526  * NextInRow (struct MatrixElement *)
527  * NextInRow contains a pointer to the next element in the row to the
528  * right of this element. If this element is the last nonzero in the
529  * row then NextInRow contains NULL.
530  * NextInCol (struct MatrixElement *)
531  * NextInCol contains a pointer to the next element in the column below
532  * this element. If this element is the last nonzero in the column then
533  * NextInCol contains NULL.
534  * pInitInfo (char *)
535  * Pointer to user data used for initialization of the matrix element.
536  * Initialized to NULL.
537  *
538  * >>> Type definitions:
539  * ElementPtr
540  * A pointer to a MatrixElement.
541  * ArrayOfElementPtrs
542  * An array of ElementPtrs. Used for FirstInRow, FirstInCol and
543  * Diag pointer arrays.
544  */
545 
546 /* Begin `MatrixElement'. */
547 
550 #if spCOMPLEX
551  RealNumber Imag;
552 #endif
553  int Row;
554  int Col;
557 #if INITIALIZE
558  char *pInitInfo;
559 #endif
560 };
561 
562 typedef struct MatrixElement *ElementPtr;
563 typedef ElementPtr *ArrayOfElementPtrs;
564 
565 
566 
567 
568 
569 
570 
571 
572 /*
573  * ALLOCATION DATA STRUCTURE
574  *
575  * The sparse matrix routines keep track of all memory that is allocated by
576  * the operating system so the memory can later be freed. This is done by
577  * saving the pointers to all the chunks of memory that are allocated to a
578  * particular matrix in an allocation list. That list is organized as a
579  * linked list so that it can grow without a priori bounds.
580  *
581  * >>> Structure fields:
582  * AllocatedPtr (char *)
583  * Pointer to chunk of memory that has been allocated for the matrix.
584  * NextRecord (struct AllocationRecord *)
585  * Pointer to the next allocation record.
586  */
587 
588 /* Begin `AllocationRecord'. */
590 { char *AllocatedPtr;
592 };
593 
595 
596 
597 
598 
599 
600 
601 
602 
603 
604 /*
605  * FILL-IN LIST DATA STRUCTURE
606  *
607  * The sparse matrix routines keep track of all fill-ins separately from
608  * user specified elements so they may be removed by spStripFills(). Fill-ins
609  * are allocated in bunched in what is called a fill-in lists. The data
610  * structure defined below is used to organize these fill-in lists into a
611  * linked-list.
612  *
613  * >>> Structure fields:
614  * pFillinList (ElementPtr)
615  * Pointer to a fill-in list, or a bunch of fill-ins arranged contiguously
616  * in memory.
617  * NumberOfFillinsInList (int)
618  * Seems pretty self explanatory to me.
619  * Next (struct FillinListNodeStruct *)
620  * Pointer to the next fill-in list structures.
621  */
622 
623 /* Begin `FillinListNodeStruct'. */
625 { ElementPtr pFillinList;
628 };
629 
630 
631 
632 
633 
634 
635 
636 
637 
638 
639 /*
640  * MATRIX FRAME DATA STRUCTURE
641  *
642  * This structure contains all the pointers that support the orthogonal
643  * linked list that contains the matrix elements. Also included in this
644  * structure are other numbers and pointers that are used globally by the
645  * sparse matrix routines and are associated with one particular matrix.
646  *
647  * >>> Type definitions:
648  * MatrixPtr
649  * A pointer to MatrixFrame. Essentially, a pointer to the matrix.
650  *
651  * >>> Structure fields:
652  * AbsThreshold (RealNumber)
653  * The absolute magnitude an element must have to be considered as a
654  * pivot candidate, except as a last resort.
655  * AllocatedExtSize (int)
656  * The allocated size of the arrays used to translate external row and
657  * column numbers to their internal values.
658  * AllocatedSize (int)
659  * The currently allocated size of the matrix; the size the matrix can
660  * grow to when EXPANDABLE is set true and AllocatedSize is the largest
661  * the matrix can get without requiring that the matrix frame be
662  * reallocated.
663  * Complex (BOOLEAN)
664  * The flag which indicates whether the matrix is complex (true) or
665  * real.
666  * CurrentSize (int)
667  * This number is used during the building of the matrix when the
668  * TRANSLATE option is set true. It indicates the number of internal
669  * rows and columns that have elements in them.
670  * Diag (ArrayOfElementPtrs)
671  * Array of pointers that points to the diagonal elements.
672  * DoCmplxDirect (BOOLEAN *)
673  * Array of flags, one for each column in matrix. If a flag is true
674  * then corresponding column in a complex matrix should be eliminated
675  * in spFactor() using direct addressing (rather than indirect
676  * addressing).
677  * DoRealDirect (BOOLEAN *)
678  * Array of flags, one for each column in matrix. If a flag is true
679  * then corresponding column in a real matrix should be eliminated
680  * in spFactor() using direct addressing (rather than indirect
681  * addressing).
682  * Elements (int)
683  * The number of original elements (total elements minus fill ins)
684  * present in matrix.
685  * Error (int)
686  * The error status of the sparse matrix package.
687  * ExtSize (int)
688  * The value of the largest external row or column number encountered.
689  * ExtToIntColMap (int [])
690  * An array that is used to convert external columns number to internal
691  * external column numbers. Present only if TRANSLATE option is set true.
692  * ExtToIntRowMap (int [])
693  * An array that is used to convert external row numbers to internal
694  * external row numbers. Present only if TRANSLATE option is set true.
695  * Factored (BOOLEAN)
696  * Indicates if matrix has been factored. This flag is set true in
697  * spFactor() and spOrderAndFactor() and set false in spCreate()
698  * and spClear().
699  * Fillins (int)
700  * The number of fill-ins created during the factorization the matrix.
701  * FirstInCol (ArrayOfElementPtrs)
702  * Array of pointers that point to the first nonzero element of the
703  * column corresponding to the index.
704  * FirstInRow (ArrayOfElementPtrs)
705  * Array of pointers that point to the first nonzero element of the row
706  * corresponding to the index.
707  * ID (unsigned long int)
708  * A constant that provides the sparse data structure with a signature.
709  * When DEBUG is true, all externally available sparse routines check
710  * this signature to assure they are operating on a valid matrix.
711  * Intermediate (RealVector)
712  * Temporary storage used in the spSolve routines. Intermediate is an
713  * array used during forward and backward substitution. It is
714  * commonly called y when the forward and backward substitution process is
715  * denoted Ax = b => Ly = b and Ux = y.
716  * InternalVectorsAllocated (BOOLEAN)
717  * A flag that indicates whether the markowitz vectors and the
718  * Intermediate vector have been created.
719  * These vectors are created in CreateInternalVectors().
720  * IntToExtColMap (int [])
721  * An array that is used to convert internal column numbers to external
722  * external column numbers.
723  * IntToExtRowMap (int [])
724  * An array that is used to convert internal row numbers to external
725  * external row numbers.
726  * MarkowitzCol (int [])
727  * An array that contains the count of the non-zero elements excluding
728  * the pivots for each column. Used to generate and update MarkowitzProd.
729  * MarkowitzProd (long [])
730  * The array of the products of the Markowitz row and column counts. The
731  * element with the smallest product is the best pivot to use to maintain
732  * sparsity.
733  * MarkowitzRow (int [])
734  * An array that contains the count of the non-zero elements excluding
735  * the pivots for each row. Used to generate and update MarkowitzProd.
736  * MaxRowCountInLowerTri (int)
737  * The maximum number of off-diagonal element in the rows of L, the
738  * lower triangular matrix. This quantity is used when computing an
739  * estimate of the roundoff error in the matrix.
740  * NeedsOrdering (BOOLEAN)
741  * This is a flag that signifies that the matrix needs to be ordered
742  * or reordered. NeedsOrdering is set true in spCreate() and
743  * spGetElement() or spGetAdmittance() if new elements are added to the
744  * matrix after it has been previously factored. It is set false in
745  * spOrderAndFactor().
746  * NumberOfInterchangesIsOdd (BOOLEAN)
747  * Flag that indicates the sum of row and column interchange counts
748  * is an odd number. Used when determining the sign of the determinant.
749  * Partitioned (BOOLEAN)
750  * This flag indicates that the columns of the matrix have been
751  * partitioned into two groups. Those that will be addressed directly
752  * and those that will be addressed indirectly in spFactor().
753  * PivotsOriginalCol (int)
754  * Column pivot was chosen from.
755  * PivotsOriginalRow (int)
756  * Row pivot was chosen from.
757  * PivotSelectionMethod (char)
758  * Character that indicates which pivot search method was successful.
759  * PreviousMatrixWasComplex (BOOLEAN)
760  * This flag in needed to determine how to clear the matrix. When
761  * dealing with real matrices, it is important that the imaginary terms
762  * in the matrix elements be zero. Thus, if the previous matrix was
763  * complex, then the current matrix will be cleared as if it were complex
764  * even if it is real.
765  * RelThreshold (RealNumber)
766  * The magnitude an element must have relative to others in its row
767  * to be considered as a pivot candidate, except as a last resort.
768  * Reordered (BOOLEAN)
769  * This flag signifies that the matrix has been reordered. It
770  * is cleared in spCreate(), set in spMNA_Preorder() and
771  * spOrderAndFactor() and is used in spPrint().
772  * RowsLinked (BOOLEAN)
773  * A flag that indicates whether the row pointers exist. The AddByIndex
774  * routines do not generate the row pointers, which are needed by some
775  * of the other routines, such as spOrderAndFactor() and spScale().
776  * The row pointers are generated in the function spcLinkRows().
777  * SingularCol (int)
778  * Normally zero, but if matrix is found to be singular, SingularCol is
779  * assigned the external column number of pivot that was zero.
780  * SingularRow (int)
781  * Normally zero, but if matrix is found to be singular, SingularRow is
782  * assigned the external row number of pivot that was zero.
783  * Singletons (int)
784  * The number of singletons available for pivoting. Note that if row I
785  * and column I both contain singletons, only one of them is counted.
786  * Size (int)
787  * Number of rows and columns in the matrix. Does not change as matrix
788  * is factored.
789  * TrashCan (MatrixElement)
790  * This is a dummy MatrixElement that is used to by the user to stuff
791  * data related to the zero row or column. In other words, when the user
792  * adds an element in row zero or column zero, then the matrix returns
793  * a pointer to TrashCan. In this way the user can have a uniform way
794  * data into the matrix independent of whether a component is connected
795  * to ground.
796  *
797  * >>> The remaining fields are related to memory allocation.
798  * TopOfAllocationList (AllocationListPtr)
799  * Pointer which points to the top entry in a list. The list contains
800  * all the pointers to the segments of memory that have been allocated
801  * to this matrix. This is used when the memory is to be freed on
802  * deallocation of the matrix.
803  * RecordsRemaining (int)
804  * Number of slots left in the list of allocations.
805  * NextAvailElement (ElementPtr)
806  * Pointer to the next available element which has been allocated but as
807  * yet is unused. Matrix elements are allocated in groups of
808  * ELEMENTS_PER_ALLOCATION in order to speed element allocation and
809  * freeing.
810  * ElementsRemaining (int)
811  * Number of unused elements left in last block of elements allocated.
812  * NextAvailFillin (ElementPtr)
813  * Pointer to the next available fill-in which has been allocated but
814  * as yet is unused. Fill-ins are allocated in a group in order to keep
815  * them physically close in memory to the rest of the matrix.
816  * FillinsRemaining (int)
817  * Number of unused fill-ins left in the last block of fill-ins
818  * allocated.
819  * FirstFillinListNode (FillinListNodeStruct *)
820  * A pointer to the head of the linked-list that keeps track of the
821  * lists of fill-ins.
822  * LastFillinListNode (FillinListNodeStruct *)
823  * A pointer to the tail of the linked-list that keeps track of the
824  * lists of fill-ins.
825  */
826 
827 /* Begin `MatrixFrame'. */
834  ArrayOfElementPtrs Diag;
837  int Elements;
838  int Error;
839  int ExtSize;
843  int Fillins;
844  ArrayOfElementPtrs FirstInCol;
845  ArrayOfElementPtrs FirstInRow;
846  unsigned long ID;
868  int Size;
869  struct MatrixElement TrashCan;
870 
871  AllocationListPtr TopOfAllocationList;
873  ElementPtr NextAvailElement;
875  ElementPtr NextAvailFillin;
879 };
880 typedef struct MatrixFrame *MatrixPtr;
ArrayOfElementPtrs FirstInRow
Definition: spdefs.h:845
int AllocatedExtSize
Definition: spdefs.h:831
ElementPtr pFillinList
Definition: spdefs.h:625
RealNumber RelThreshold
Definition: spdefs.h:862
long * MarkowitzProd
Definition: spdefs.h:853
int ElementsRemaining
Definition: spdefs.h:874
AllocationListPtr TopOfAllocationList
Definition: spdefs.h:871
#define BOOLEAN
Definition: spdefs.h:107
ArrayOfElementPtrs Diag
Definition: spdefs.h:834
int NumberOfFillinsInList
Definition: spdefs.h:626
int * ExtToIntColMap
Definition: spdefs.h:840
BOOLEAN RowsLinked
Definition: spdefs.h:864
int SingularCol
Definition: spdefs.h:865
int ExtSize
Definition: spdefs.h:839
ElementPtr NextAvailElement
Definition: spdefs.h:873
RealVector Intermediate
Definition: spdefs.h:847
struct FillinListNodeStruct * Next
Definition: spdefs.h:627
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:844
spREAL * RealVector
Definition: spdefs.h:468
struct ComplexNumber * ComplexVector
struct MatrixElement * NextInRow
Definition: spdefs.h:555
int Singletons
Definition: spdefs.h:867
struct AllocationRecord * NextRecord
Definition: spdefs.h:591
BOOLEAN NeedsOrdering
Definition: spdefs.h:855
BOOLEAN InternalVectorsAllocated
Definition: spdefs.h:848
struct MatrixElement * ElementPtr
Definition: spdefs.h:562
RealNumber Real
Definition: spdefs.h:549
struct AllocationRecord * AllocationListPtr
Definition: spdefs.h:594
int * IntToExtColMap
Definition: spdefs.h:849
BOOLEAN * DoCmplxDirect
Definition: spdefs.h:835
BOOLEAN * DoRealDirect
Definition: spdefs.h:836
RealNumber AbsThreshold
Definition: spdefs.h:829
RealNumber Real
Definition: spdefs.h:492
int PivotsOriginalCol
Definition: spdefs.h:858
int AllocatedSize
Definition: spdefs.h:830
struct FillinListNodeStruct * LastFillinListNode
Definition: spdefs.h:878
BOOLEAN NumberOfInterchangesIsOdd
Definition: spdefs.h:856
char * AllocatedPtr
Definition: spdefs.h:590
int RecordsRemaining
Definition: spdefs.h:872
int Error
Definition: spdefs.h:838
int Fillins
Definition: spdefs.h:843
int Size
Definition: spdefs.h:868
RealNumber Imag
Definition: spdefs.h:493
int * ExtToIntRowMap
Definition: spdefs.h:841
#define spREAL
Definition: spmatrix.h:127
BOOLEAN Factored
Definition: spdefs.h:842
int * IntToExtRowMap
Definition: spdefs.h:850
spREAL RealNumber
Definition: spdefs.h:468
BOOLEAN Partitioned
Definition: spdefs.h:857
int * MarkowitzCol
Definition: spdefs.h:852
int PivotsOriginalRow
Definition: spdefs.h:859
ElementPtr NextAvailFillin
Definition: spdefs.h:875
struct FillinListNodeStruct * FirstFillinListNode
Definition: spdefs.h:877
int Elements
Definition: spdefs.h:837
int * MarkowitzRow
Definition: spdefs.h:851
int MaxRowCountInLowerTri
Definition: spdefs.h:854
BOOLEAN Complex
Definition: spdefs.h:832
char PivotSelectionMethod
Definition: spdefs.h:860
BOOLEAN Reordered
Definition: spdefs.h:863
unsigned long ID
Definition: spdefs.h:846
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:880
int FillinsRemaining
Definition: spdefs.h:876
ElementPtr * ArrayOfElementPtrs
Definition: spdefs.h:563
struct MatrixElement * NextInCol
Definition: spdefs.h:556
int SingularRow
Definition: spdefs.h:866
int CurrentSize
Definition: spdefs.h:833
BOOLEAN PreviousMatrixWasComplex
Definition: spdefs.h:861