Jspice3
spoutput.c
Go to the documentation of this file.
1 /*
2  * MATRIX OUTPUT MODULE
3  *
4  * Author: Advisor:
5  * Kenneth S. Kundert Alberto Sangiovanni-Vincentelli
6  * UC Berkeley
7  *
8  * This file contains the output-to-file and output-to-screen routines for
9  * the matrix package.
10  *
11  * >>> User accessible functions contained in this file:
12  * spPrint
13  * spFileMatrix
14  * spFileVector
15  * spFileStats
16  *
17  * >>> Other functions contained in this file:
18  */
19 
20 
21 /*
22  * Revision and copyright information.
23  *
24  * Copyright (c) 1985,86,87,88,89,90
25  * by Kenneth S. Kundert and the University of California.
26  *
27  * Permission to use, copy, modify, and distribute this software and
28  * its documentation for any purpose and without fee is hereby granted,
29  * provided that the copyright notices appear in all copies and
30  * supporting documentation and that the authors and the University of
31  * California are properly credited. The authors and the University of
32  * California make no representations as to the suitability of this
33  * software for any purpose. It is provided `as is', without express
34  * or implied warranty.
35  */
36 
37 #ifdef notdef
38 static char copyright[] =
39  "Sparse1.3: Copyright (c) 1985,86,87,88,89,90 by Kenneth S. Kundert";
40 static char RCSid[] =
41  "$Header: spOutput.c,v 1.3 88/06/24 05:02:31 kundert Exp $";
42 #endif
43 
44 
45 
46 
47 /*
48  * IMPORTS
49  *
50  * >>> Import descriptions:
51  * spConfig.h
52  * Macros that customize the sparse matrix routines.
53  * spMatrix.h
54  * Macros and declarations to be imported by the user.
55  * spDefs.h
56  * Matrix type and macro definitions for the sparse matrix routines.
57  */
58 
59 #define spINSIDE_SPARSE
60 #include "spconfig.h"
61 #include "spmatrix.h"
62 #include "spdefs.h"
63 
64 
65 
66 
67 
68 #if DOCUMENTATION
69 
70 /*
71  * PRINT MATRIX
72  *
73  * Formats and send the matrix to standard output. Some elementary
74  * statistics are also output. The matrix is output in a format that is
75  * readable by people.
76  *
77  * >>> Arguments:
78  * Matrix <input> (char *)
79  * Pointer to matrix.
80  * PrintReordered <input> (int)
81  * Indicates whether the matrix should be printed out in its original
82  * form, as input by the user, or whether it should be printed in its
83  * reordered form, as used by the matrix routines. A zero indicates that
84  * the matrix should be printed as inputed, a one indicates that it
85  * should be printed reordered.
86  * Data <input> (int)
87  * Boolean flag that when false indicates that output should be
88  * compressed such that only the existence of an element should be
89  * indicated rather than giving the actual value. Thus 11 times as
90  * many can be printed on a row. A zero signifies that the matrix
91  * should be printed compressed. A one indicates that the matrix
92  * should be printed in all its glory.
93  * Header <input> (int)
94  * Flag indicating that extra information should be given, such as row
95  * and column numbers.
96  *
97  * >>> Local variables:
98  * Col (int)
99  * Column being printed.
100  * ElementCount (int)
101  * Variable used to count the number of nonzero elements in the matrix.
102  * LargestElement (RealNumber)
103  * The magnitude of the largest element in the matrix.
104  * LargestDiag (RealNumber)
105  * The magnitude of the largest diagonal in the matrix.
106  * Magnitude (RealNumber)
107  * The absolute value of the matrix element being printed.
108  * PrintOrdToIntColMap (int [])
109  * A translation array that maps the order that columns will be
110  * printed in (if not PrintReordered) to the internal column numbers.
111  * PrintOrdToIntRowMap (int [])
112  * A translation array that maps the order that rows will be
113  * printed in (if not PrintReordered) to the internal row numbers.
114  * pElement (ElementPtr)
115  * Pointer to the element in the matrix that is to be printed.
116  * pImagElements (ElementPtr [ ])
117  * Array of pointers to elements in the matrix. These pointers point
118  * to the elements whose real values have just been printed. They are
119  * used to quickly access those same elements so their imaginary values
120  * can be printed.
121  * Row (int)
122  * Row being printed.
123  * Size (int)
124  * The size of the matrix.
125  * SmallestDiag (RealNumber)
126  * The magnitude of the smallest diagonal in the matrix.
127  * SmallestElement (RealNumber)
128  * The magnitude of the smallest element in the matrix excluding zero
129  * elements.
130  * StartCol (int)
131  * The column number of the first column to be printed in the group of
132  * columns currently being printed.
133  * StopCol (int)
134  * The column number of the last column to be printed in the group of
135  * columns currently being printed.
136  * Top (int)
137  * The largest expected external row or column number.
138  */
139 
140 void
141 spPrint( eMatrix, PrintReordered, Data, Header )
142 
143 char *eMatrix;
144 int PrintReordered, Data, Header;
145 {
146 MatrixPtr Matrix = (MatrixPtr)eMatrix;
147 register int J = 0;
148 int I, Row, Col, Size, Top, StartCol = 1, StopCol, Columns, ElementCount = 0;
149 double Magnitude, SmallestDiag, SmallestElement;
150 double LargestElement = 0.0, LargestDiag = 0.0;
151 ElementPtr pElement, pImagElements[PRINTER_WIDTH/10+1];
152 int *PrintOrdToIntRowMap, *PrintOrdToIntColMap;
153 
154 /* Begin `spPrint'. */
155  ASSERT( IS_SPARSE( Matrix ) );
156  Size = Matrix->Size;
157 
158 /* Create a packed external to internal row and column translation array. */
159 # if TRANSLATE
160  Top = Matrix->AllocatedExtSize;
161 #else
162  Top = Matrix->AllocatedSize;
163 #endif
164  CALLOC( PrintOrdToIntRowMap, int, Top + 1 );
165  CALLOC( PrintOrdToIntColMap, int, Top + 1 );
166  if ( PrintOrdToIntRowMap == NULL OR PrintOrdToIntColMap == NULL)
167  { Matrix->Error = spNO_MEMORY;
168  return;
169  }
170  for (I = 1; I <= Size; I++)
171  { PrintOrdToIntRowMap[ Matrix->IntToExtRowMap[I] ] = I;
172  PrintOrdToIntColMap[ Matrix->IntToExtColMap[I] ] = I;
173  }
174 
175 /* Pack the arrays. */
176  for (J = 1, I = 1; I <= Top; I++)
177  { if (PrintOrdToIntRowMap[I] != 0)
178  PrintOrdToIntRowMap[ J++ ] = PrintOrdToIntRowMap[ I ];
179  }
180  for (J = 1, I = 1; I <= Top; I++)
181  { if (PrintOrdToIntColMap[I] != 0)
182  PrintOrdToIntColMap[ J++ ] = PrintOrdToIntColMap[ I ];
183  }
184 
185 /* Print header. */
186  if (Header)
187  { printf("MATRIX SUMMARY\n\n");
188  printf("Size of matrix = %1d x %1d.\n", Size, Size);
189  if ( Matrix->Reordered AND PrintReordered )
190  printf("Matrix has been reordered.\n");
191  putchar('\n');
192 
193  if ( Matrix->Factored )
194  printf("Matrix after factorization:\n");
195  else
196  printf("Matrix before factorization:\n");
197 
198  SmallestElement = LARGEST_REAL;
199  SmallestDiag = SmallestElement;
200  }
201 
202 /* Determine how many columns to use. */
203  Columns = PRINTER_WIDTH;
204  if (Header) Columns -= 5;
205  if (Data) Columns = (Columns+1) / 10;
206 
207 /*
208  * Print matrix by printing groups of complete columns until all the columns
209  * are printed.
210  */
211  J = 0;
212  while ( J <= Size )
213 
214 /* Calculate index of last column to printed in this group. */
215  { StopCol = StartCol + Columns - 1;
216  if (StopCol > Size)
217  StopCol = Size;
218 
219 /* Label the columns. */
220  if (Header)
221  { if (Data)
222  { printf(" ");
223  for (I = StartCol; I <= StopCol; I++)
224  { if (PrintReordered)
225  Col = I;
226  else
227  Col = PrintOrdToIntColMap[I];
228  printf(" %9d", Matrix->IntToExtColMap[ Col ]);
229  }
230  printf("\n\n");
231  }
232  else
233  { if (PrintReordered)
234  printf("Columns %1d to %1d.\n",StartCol,StopCol);
235  else
236  { printf("Columns %1d to %1d.\n",
237  Matrix->IntToExtColMap[ PrintOrdToIntColMap[StartCol] ],
238  Matrix->IntToExtColMap[ PrintOrdToIntColMap[StopCol] ]);
239  }
240  }
241  }
242 
243 /* Print every row ... */
244  for (I = 1; I <= Size; I++)
245  { if (PrintReordered)
246  Row = I;
247  else
248  Row = PrintOrdToIntRowMap[I];
249 
250  if (Header)
251  { if (PrintReordered AND NOT Data)
252  printf("%4d", I);
253  else
254  printf("%4d", Matrix->IntToExtRowMap[ Row ]);
255  if (NOT Data) putchar(' ');
256  }
257 
258 /* ... in each column of the group. */
259  for (J = StartCol; J <= StopCol; J++)
260  { if (PrintReordered)
261  Col = J;
262  else
263  Col = PrintOrdToIntColMap[J];
264 
265  pElement = Matrix->FirstInCol[Col];
266  while(pElement != NULL AND pElement->Row != Row)
267  pElement = pElement->NextInCol;
268 
269  if (Data)
270  pImagElements[J - StartCol] = pElement;
271 
272  if (pElement != NULL)
273 
274 /* Case where element exists */
275  { if (Data)
276  printf(" %9.3g", (double)pElement->Real);
277  else
278  putchar('x');
279 
280 /* Update status variables */
281  if ( (Magnitude = ELEMENT_MAG(pElement)) > LargestElement )
282  LargestElement = Magnitude;
283  if ((Magnitude < SmallestElement) AND (Magnitude != 0.0))
284  SmallestElement = Magnitude;
285  ElementCount++;
286  }
287 
288 /* Case where element is structurally zero */
289  else
290  { if (Data)
291  printf(" ...");
292  else
293  putchar('.');
294  }
295  }
296  putchar('\n');
297 
298 #if spCOMPLEX
299  if (Matrix->Complex AND Data)
300  { printf(" ");
301  for (J = StartCol; J <= StopCol; J++)
302  { if (pImagElements[J - StartCol] != NULL)
303  { printf(" %8.2gj",
304  (double)pImagElements[J-StartCol]->Imag);
305  }
306  else printf(" ");
307  }
308  putchar('\n');
309  }
310 #endif /* spCOMPLEX */
311  }
312 
313 /* Calculate index of first column in next group. */
314  StartCol = StopCol;
315  StartCol++;
316  putchar('\n');
317  }
318  if (Header)
319  { printf("\nLargest element in matrix = %-1.4g.\n", LargestElement);
320  printf("Smallest element in matrix = %-1.4g.\n", SmallestElement);
321 
322 /* Search for largest and smallest diagonal values */
323  for (I = 1; I <= Size; I++)
324  { if (Matrix->Diag[I] != NULL)
325  { Magnitude = ELEMENT_MAG( Matrix->Diag[I] );
326  if ( Magnitude > LargestDiag ) LargestDiag = Magnitude;
327  if ( Magnitude < SmallestDiag ) SmallestDiag = Magnitude;
328  }
329  }
330 
331  /* Print the largest and smallest diagonal values */
332  if ( Matrix->Factored )
333  { printf("\nLargest diagonal element = %-1.4g.\n", LargestDiag);
334  printf("Smallest diagonal element = %-1.4g.\n", SmallestDiag);
335  }
336  else
337  { printf("\nLargest pivot element = %-1.4g.\n", LargestDiag);
338  printf("Smallest pivot element = %-1.4g.\n", SmallestDiag);
339  }
340 
341  /* Calculate and print sparsity and number of fill-ins created. */
342  printf("\nDensity = %2.2f%%.\n", ((double)(ElementCount * 100)) /
343  ((double)(Size * Size)));
344  if (NOT Matrix->NeedsOrdering)
345  printf("Number of fill-ins = %1d.\n", Matrix->Fillins);
346  }
347  putchar('\n');
348  (void)fflush(stdout);
349 
350  FREE(PrintOrdToIntColMap);
351  FREE(PrintOrdToIntRowMap);
352  return;
353 }
354 
355 
356 
357 
358 
359 
360 
361 
362 
363 
364 
365 /*
366  * OUTPUT MATRIX TO FILE
367  *
368  * Writes matrix to file in format suitable to be read back in by the
369  * matrix test program.
370  *
371  * >>> Returns:
372  * One is returned if routine was successful, otherwise zero is returned.
373  * The calling function can query errno (the system global error variable)
374  * as to the reason why this routine failed.
375  *
376  * >>> Arguments:
377  * Matrix <input> (char *)
378  * Pointer to matrix.
379  * File <input> (char *)
380  * Name of file into which matrix is to be written.
381  * Label <input> (char *)
382  * String that is transferred to file and is used as a label.
383  * Reordered <input> (BOOLEAN)
384  * Specifies whether matrix should be output in reordered form,
385  * or in original order.
386  * Data <input> (BOOLEAN)
387  * Indicates that the element values should be output along with
388  * the indices for each element. This parameter must be true if
389  * matrix is to be read by the sparse test program.
390  * Header <input> (BOOLEAN)
391  * Indicates that header is desired. This parameter must be true if
392  * matrix is to be read by the sparse test program.
393  *
394  * >>> Local variables:
395  * Col (int)
396  * The original column number of the element being output.
397  * pElement (ElementPtr)
398  * Pointer to an element in the matrix.
399  * pMatrixFile (FILE *)
400  * File pointer to the matrix file.
401  * Row (int)
402  * The original row number of the element being output.
403  * Size (int)
404  * The size of the matrix.
405  */
406 
407 int
408 spFileMatrix( eMatrix, File, Label, Reordered, Data, Header )
409 
410 char *eMatrix, *Label, *File;
411 int Reordered, Data, Header;
412 {
413 MatrixPtr Matrix = (MatrixPtr)eMatrix;
414 register int I, Size;
415 register ElementPtr pElement;
416 int Row, Col, Err;
417 FILE *pMatrixFile, *fopen();
418 
419 /* Begin `spFileMatrix'. */
420  ASSERT( IS_SPARSE( Matrix ) );
421 
422 /* Open file matrix file in write mode. */
423  if ((pMatrixFile = fopen(File, "w")) == NULL)
424  return 0;
425 
426 /* Output header. */
427  Size = Matrix->Size;
428  if (Header)
429  { if (Matrix->Factored AND Data)
430  { Err = fprintf
431  ( pMatrixFile,
432  "Warning : The following matrix is factored in to LU form.\n"
433  );
434  if (Err < 0) return 0;
435  }
436  if (fprintf(pMatrixFile, "%s\n", Label) < 0) return 0;
437  Err = fprintf( pMatrixFile, "%d\t%s\n", Size,
438  (Matrix->Complex ? "complex" : "real"));
439  if (Err < 0) return 0;
440  }
441 
442 /* Output matrix. */
443  if (NOT Data)
444  { for (I = 1; I <= Size; I++)
445  { pElement = Matrix->FirstInCol[I];
446  while (pElement != NULL)
447  { if (Reordered)
448  { Row = pElement->Row;
449  Col = I;
450  }
451  else
452  { Row = Matrix->IntToExtRowMap[pElement->Row];
453  Col = Matrix->IntToExtColMap[I];
454  }
455  pElement = pElement->NextInCol;
456  if (fprintf(pMatrixFile, "%d\t%d\n", Row, Col) < 0) return 0;
457  }
458  }
459 /* Output terminator, a line of zeros. */
460  if (Header)
461  if (fprintf(pMatrixFile, "0\t0\n") < 0) return 0;
462  }
463 
464 #if spCOMPLEX
465  if (Data AND Matrix->Complex)
466  { for (I = 1; I <= Size; I++)
467  { pElement = Matrix->FirstInCol[I];
468  while (pElement != NULL)
469  { if (Reordered)
470  { Row = pElement->Row;
471  Col = I;
472  }
473  else
474  { Row = Matrix->IntToExtRowMap[pElement->Row];
475  Col = Matrix->IntToExtColMap[I];
476  }
477  Err = fprintf
478  ( pMatrixFile,"%d\t%d\t%-.15g\t%-.15g\n",
479  Row, Col, (double)pElement->Real, (double)pElement->Imag
480  );
481  if (Err < 0) return 0;
482  pElement = pElement->NextInCol;
483  }
484  }
485 /* Output terminator, a line of zeros. */
486  if (Header)
487  if (fprintf(pMatrixFile,"0\t0\t0.0\t0.0\n") < 0) return 0;
488 
489  }
490 #endif /* spCOMPLEX */
491 
492 #if REAL
493  if (Data AND NOT Matrix->Complex)
494  { for (I = 1; I <= Size; I++)
495  { pElement = Matrix->FirstInCol[I];
496  while (pElement != NULL)
497  { Row = Matrix->IntToExtRowMap[pElement->Row];
498  Col = Matrix->IntToExtColMap[I];
499  Err = fprintf
500  ( pMatrixFile,"%d\t%d\t%-.15g\n",
501  Row, Col, (double)pElement->Real
502  );
503  if (Err < 0) return 0;
504  pElement = pElement->NextInCol;
505  }
506  }
507 /* Output terminator, a line of zeros. */
508  if (Header)
509  if (fprintf(pMatrixFile,"0\t0\t0.0\n") < 0) return 0;
510 
511  }
512 #endif /* REAL */
513 
514 /* Close file. */
515  if (fclose(pMatrixFile) < 0) return 0;
516  return 1;
517 }
518 
519 
520 
521 
522 
523 
524 
525 /*
526  * OUTPUT SOURCE VECTOR TO FILE
527  *
528  * Writes vector to file in format suitable to be read back in by the
529  * matrix test program. This routine should be executed after the function
530  * spFileMatrix.
531  *
532  * >>> Returns:
533  * One is returned if routine was successful, otherwise zero is returned.
534  * The calling function can query errno (the system global error variable)
535  * as to the reason why this routine failed.
536  *
537  * >>> Arguments:
538  * Matrix <input> (char *)
539  * Pointer to matrix.
540  * File <input> (char *)
541  * Name of file into which matrix is to be written.
542  * RHS <input> (RealNumber [])
543  * Right-hand side vector. This is only the real portion if
544  * spSEPARATED_COMPLEX_VECTORS is true.
545  * iRHS <input> (RealNumber [])
546  * Right-hand side vector, imaginary portion. Not necessary if matrix
547  * is real or if spSEPARATED_COMPLEX_VECTORS is set false.
548  *
549  * >>> Local variables:
550  * pMatrixFile (FILE *)
551  * File pointer to the matrix file.
552  * Size (int)
553  * The size of the matrix.
554  *
555  * >>> Obscure Macros
556  * IMAG_RHS
557  * Replaces itself with `, iRHS' if the options spCOMPLEX and
558  * spSEPARATED_COMPLEX_VECTORS are set, otherwise it disappears
559  * without a trace.
560  */
561 
562 int
563 spFileVector( eMatrix, File, RHS IMAG_RHS )
564 
565 char *eMatrix, *File;
567 {
568 MatrixPtr Matrix = (MatrixPtr)eMatrix;
569 register int I, Size, Err;
570 FILE *pMatrixFile;
571 FILE *fopen();
572 
573 /* Begin `spFileVector'. */
574  ASSERT( IS_SPARSE( Matrix ) AND RHS != NULL)
575 
576 /* Open File in append mode. */
577  if ((pMatrixFile = fopen(File,"a")) == NULL)
578  return 0;
579 
580 /* Correct array pointers for ARRAY_OFFSET. */
581 #if NOT ARRAY_OFFSET
582 #if spCOMPLEX
583  if (Matrix->Complex)
584  {
585 #if spSEPARATED_COMPLEX_VECTORS
586  ASSERT(iRHS != NULL)
587  --RHS;
588  --iRHS;
589 #else
590  RHS -= 2;
591 #endif
592  }
593  else
594 #endif /* spCOMPLEX */
595  --RHS;
596 #endif /* NOT ARRAY_OFFSET */
597 
598 
599 /* Output vector. */
600  Size = Matrix->Size;
601 #if spCOMPLEX
602  if (Matrix->Complex)
603  {
604 #if spSEPARATED_COMPLEX_VECTORS
605  for (I = 1; I <= Size; I++)
606  { Err = fprintf
607  ( pMatrixFile, "%-.15g\t%-.15g\n",
608  (double)RHS[I], (double)iRHS[I]
609  );
610  if (Err < 0) return 0;
611  }
612 #else
613  for (I = 1; I <= Size; I++)
614  { Err = fprintf
615  ( pMatrixFile, "%-.15g\t%-.15g\n",
616  (double)RHS[2*I], (double)RHS[2*I+1]
617  );
618  if (Err < 0) return 0;
619  }
620 #endif
621  }
622 #endif /* spCOMPLEX */
623 #if REAL AND spCOMPLEX
624  else
625 #endif
626 #if REAL
627  { for (I = 1; I <= Size; I++)
628  { if (fprintf(pMatrixFile, "%-.15g\n", (double)RHS[I]) < 0)
629  return 0;
630  }
631  }
632 #endif /* REAL */
633 
634 /* Close file. */
635  if (fclose(pMatrixFile) < 0) return 0;
636  return 1;
637 }
638 
639 
640 
641 
642 
643 
644 
645 
646 
647 /*
648  * OUTPUT STATISTICS TO FILE
649  *
650  * Writes useful information concerning the matrix to a file. Should be
651  * executed after the matrix is factored.
652  *
653  * >>> Returns:
654  * One is returned if routine was successful, otherwise zero is returned.
655  * The calling function can query errno (the system global error variable)
656  * as to the reason why this routine failed.
657  *
658  * >>> Arguments:
659  * Matrix <input> (char *)
660  * Pointer to matrix.
661  * File <input> (char *)
662  * Name of file into which matrix is to be written.
663  * Label <input> (char *)
664  * String that is transferred to file and is used as a label.
665  *
666  * >>> Local variables:
667  * Data (RealNumber)
668  * The value of the matrix element being output.
669  * LargestElement (RealNumber)
670  * The largest element in the matrix.
671  * NumberOfElements (int)
672  * Number of nonzero elements in the matrix.
673  * pElement (ElementPtr)
674  * Pointer to an element in the matrix.
675  * pStatsFile (FILE *)
676  * File pointer to the statistics file.
677  * Size (int)
678  * The size of the matrix.
679  * SmallestElement (RealNumber)
680  * The smallest element in the matrix excluding zero elements.
681  */
682 
683 int
684 spFileStats( eMatrix, File, Label )
685 
686 char *eMatrix, *File, *Label;
687 {
688 MatrixPtr Matrix = (MatrixPtr)eMatrix;
689 register int Size, I;
690 register ElementPtr pElement;
691 int NumberOfElements;
692 RealNumber Data, LargestElement, SmallestElement;
693 FILE *pStatsFile, *fopen();
694 
695 /* Begin `spFileStats'. */
696  ASSERT( IS_SPARSE( Matrix ) );
697 
698 /* Open File in append mode. */
699  if ((pStatsFile = fopen(File, "a")) == NULL)
700  return 0;
701 
702 /* Output statistics. */
703  Size = Matrix->Size;
704  if (NOT Matrix->Factored)
705  fprintf(pStatsFile, "Matrix has not been factored.\n");
706  fprintf(pStatsFile, "||| Starting new matrix |||\n");
707  fprintf(pStatsFile, "%s\n", Label);
708  if (Matrix->Complex)
709  fprintf(pStatsFile, "Matrix is complex.\n");
710  else
711  fprintf(pStatsFile, "Matrix is real.\n");
712  fprintf(pStatsFile," Size = %d\n",Size);
713 
714 /* Search matrix. */
715  NumberOfElements = 0;
716  LargestElement = 0.0;
717  SmallestElement = LARGEST_REAL;
718 
719  for (I = 1; I <= Size; I++)
720  { pElement = Matrix->FirstInCol[I];
721  while (pElement != NULL)
722  { NumberOfElements++;
723  Data = ELEMENT_MAG(pElement);
724  if (Data > LargestElement)
725  LargestElement = Data;
726  if (Data < SmallestElement AND Data != 0.0)
727  SmallestElement = Data;
728  pElement = pElement->NextInCol;
729  }
730  }
731 
732  SmallestElement = MIN( SmallestElement, LargestElement );
733 
734 /* Output remaining statistics. */
735  fprintf(pStatsFile, " Initial number of elements = %d\n",
736  NumberOfElements - Matrix->Fillins);
737  fprintf(pStatsFile,
738  " Initial average number of elements per row = %f\n",
739  (double)(NumberOfElements - Matrix->Fillins) / (double)Size);
740  fprintf(pStatsFile, " Fill-ins = %d\n",Matrix->Fillins);
741  fprintf(pStatsFile, " Average number of fill-ins per row = %f%%\n",
742  (double)Matrix->Fillins / (double)Size);
743  fprintf(pStatsFile, " Total number of elements = %d\n",
744  NumberOfElements);
745  fprintf(pStatsFile, " Average number of elements per row = %f\n",
746  (double)NumberOfElements / (double)Size);
747  fprintf(pStatsFile," Density = %f%%\n",
748  (double)(100.0*NumberOfElements)/(double)(Size*Size));
749  fprintf(pStatsFile," Relative Threshold = %e\n", Matrix->RelThreshold);
750  fprintf(pStatsFile," Absolute Threshold = %e\n", Matrix->AbsThreshold);
751  fprintf(pStatsFile," Largest Element = %e\n", LargestElement);
752  fprintf(pStatsFile," Smallest Element = %e\n\n\n", SmallestElement);
753 
754 /* Close file. */
755  (void)fclose(pStatsFile);
756  return 1;
757 }
758 #endif /* DOCUMENTATION */
RealNumber RelThreshold
Definition: spdefs.h:853
int spFileVector()
void spPrint()
int Size
Definition: spdefs.h:859
#define MIN(a, b)
Definition: spdefs.h:136
int spFileMatrix()
RealNumber Real
Definition: spdefs.h:539
This document describes the JSPICE3 Josephson junction model I derivation of the model The expression for the junction current is J
Definition: model.doc:9
#define FREE(ptr)
Definition: spdefs.h:436
spREAL * RealVector
Definition: spdefs.h:458
#define IS_SPARSE(matrix)
Definition: spdefs.h:125
#define ELEMENT_MAG(ptr)
Definition: spdefs.h:161
struct MatrixElement * NextInCol
Definition: spdefs.h:547
BOOLEAN Factored
Definition: spdefs.h:833
BOOLEAN NeedsOrdering
Definition: spdefs.h:846
RealNumber AbsThreshold
Definition: spdefs.h:820
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
#define CALLOC(ptr, type, number)
Definition: spdefs.h:440
#define NULL
Definition: spdefs.h:121
#define OR
Definition: fteparse.h:93
register ElementPtr pElement
Definition: spsolve.c:158
long * Top
Definition: cd.c:1907
int * IntToExtColMap
Definition: spdefs.h:840
register int Size
Definition: spsolve.c:163
int * IntToExtRowMap
Definition: spdefs.h:841
int Fillins
Definition: spdefs.h:834
int Error
Definition: spdefs.h:829
BOOLEAN Complex
Definition: spdefs.h:823
spREAL RealNumber
Definition: spdefs.h:458
void Label()
RealVector RHS
Definition: spsolve.c:157
#define IMAG_RHS
Definition: spdefs.h:430
int AllocatedExtSize
Definition: spdefs.h:822
ArrayOfElementPtrs Diag
Definition: spdefs.h:825
#define NOT
Definition: fteparse.h:94
BOOLEAN Reordered
Definition: spdefs.h:854
int spFileStats()
register int I
Definition: spsolve.c:163
struct MatrixFrame * MatrixPtr
Definition: spdefs.h:871
#define spNO_MEMORY
Definition: spmatrix.h:105
ArrayOfElementPtrs FirstInCol
Definition: spdefs.h:835
#define AND
Definition: fteparse.h:92
int AllocatedSize
Definition: spdefs.h:821