38 static char copyright[] =
39 "Sparse1.3: Copyright (c) 1985,86,87,88,89,90 by Kenneth S. Kundert";
41 "$Header: spOutput.c,v 1.3 88/06/24 05:02:31 kundert Exp $";
59 #define spINSIDE_SPARSE 141 spPrint( eMatrix, PrintReordered, Data, Header )
144 int PrintReordered, Data, Header;
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;
152 int *PrintOrdToIntRowMap, *PrintOrdToIntColMap;
164 CALLOC( PrintOrdToIntRowMap,
int, Top + 1 );
165 CALLOC( PrintOrdToIntColMap,
int, Top + 1 );
166 if ( PrintOrdToIntRowMap ==
NULL OR PrintOrdToIntColMap ==
NULL)
170 for (I = 1; I <=
Size; I++)
176 for (J = 1, I = 1; I <=
Top; I++)
177 {
if (PrintOrdToIntRowMap[I] != 0)
178 PrintOrdToIntRowMap[ J++ ] = PrintOrdToIntRowMap[
I ];
180 for (J = 1, I = 1; I <=
Top; I++)
181 {
if (PrintOrdToIntColMap[I] != 0)
182 PrintOrdToIntColMap[ J++ ] = PrintOrdToIntColMap[
I ];
187 { printf(
"MATRIX SUMMARY\n\n");
188 printf(
"Size of matrix = %1d x %1d.\n", Size, Size);
190 printf(
"Matrix has been reordered.\n");
194 printf(
"Matrix after factorization:\n");
196 printf(
"Matrix before factorization:\n");
198 SmallestElement = LARGEST_REAL;
199 SmallestDiag = SmallestElement;
203 Columns = PRINTER_WIDTH;
204 if (Header) Columns -= 5;
205 if (Data) Columns = (Columns+1) / 10;
215 { StopCol = StartCol + Columns - 1;
223 for (I = StartCol; I <= StopCol; I++)
224 {
if (PrintReordered)
227 Col = PrintOrdToIntColMap[
I];
233 {
if (PrintReordered)
234 printf(
"Columns %1d to %1d.\n",StartCol,StopCol);
236 { printf(
"Columns %1d to %1d.\n",
244 for (I = 1; I <=
Size; I++)
245 {
if (PrintReordered)
248 Row = PrintOrdToIntRowMap[
I];
251 {
if (PrintReordered
AND NOT Data)
255 if (
NOT Data) putchar(
' ');
259 for (J = StartCol; J <= StopCol; J++)
260 {
if (PrintReordered)
263 Col = PrintOrdToIntColMap[
J];
266 while(pElement !=
NULL AND pElement->
Row != Row)
270 pImagElements[J - StartCol] =
pElement;
272 if (pElement !=
NULL)
276 printf(
" %9.3g", (
double)pElement->
Real);
281 if ( (Magnitude =
ELEMENT_MAG(pElement)) > LargestElement )
282 LargestElement = Magnitude;
283 if ((Magnitude < SmallestElement)
AND (Magnitude != 0.0))
284 SmallestElement = Magnitude;
301 for (J = StartCol; J <= StopCol; J++)
302 {
if (pImagElements[J - StartCol] !=
NULL)
304 (
double)pImagElements[J-StartCol]->Imag);
319 { printf(
"\nLargest element in matrix = %-1.4g.\n", LargestElement);
320 printf(
"Smallest element in matrix = %-1.4g.\n", SmallestElement);
323 for (I = 1; I <=
Size; I++)
326 if ( Magnitude > LargestDiag ) LargestDiag = Magnitude;
327 if ( Magnitude < SmallestDiag ) SmallestDiag = Magnitude;
333 { printf(
"\nLargest diagonal element = %-1.4g.\n", LargestDiag);
334 printf(
"Smallest diagonal element = %-1.4g.\n", SmallestDiag);
337 { printf(
"\nLargest pivot element = %-1.4g.\n", LargestDiag);
338 printf(
"Smallest pivot element = %-1.4g.\n", SmallestDiag);
342 printf(
"\nDensity = %2.2f%%.\n", ((
double)(ElementCount * 100)) /
343 ((
double)(Size * Size)));
345 printf(
"Number of fill-ins = %1d.\n", Matrix->
Fillins);
348 (void)fflush(stdout);
350 FREE(PrintOrdToIntColMap);
351 FREE(PrintOrdToIntRowMap);
410 char *eMatrix, *
Label, *File;
411 int Reordered, Data, Header;
414 register int I,
Size;
417 FILE *pMatrixFile, *fopen();
423 if ((pMatrixFile = fopen(File,
"w")) ==
NULL)
432 "Warning : The following matrix is factored in to LU form.\n" 434 if (Err < 0)
return 0;
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;
444 {
for (I = 1; I <=
Size; I++)
446 while (pElement !=
NULL)
448 { Row = pElement->
Row;
456 if (fprintf(pMatrixFile,
"%d\t%d\n", Row, Col) < 0)
return 0;
461 if (fprintf(pMatrixFile,
"0\t0\n") < 0)
return 0;
466 {
for (I = 1; I <=
Size; I++)
468 while (pElement !=
NULL)
470 { Row = pElement->
Row;
478 ( pMatrixFile,
"%d\t%d\t%-.15g\t%-.15g\n",
479 Row, Col, (
double)pElement->
Real, (
double)pElement->Imag
481 if (Err < 0)
return 0;
487 if (fprintf(pMatrixFile,
"0\t0\t0.0\t0.0\n") < 0)
return 0;
494 {
for (I = 1; I <=
Size; I++)
496 while (pElement !=
NULL)
500 ( pMatrixFile,
"%d\t%d\t%-.15g\n",
501 Row, Col, (
double)pElement->
Real 503 if (Err < 0)
return 0;
509 if (fprintf(pMatrixFile,
"0\t0\t0.0\n") < 0)
return 0;
515 if (fclose(pMatrixFile) < 0)
return 0;
565 char *eMatrix, *File;
569 register int I,
Size, Err;
577 if ((pMatrixFile = fopen(File,
"a")) ==
NULL)
585 #if spSEPARATED_COMPLEX_VECTORS 604 #if spSEPARATED_COMPLEX_VECTORS 605 for (I = 1; I <=
Size; I++)
607 ( pMatrixFile,
"%-.15g\t%-.15g\n",
608 (
double)
RHS[I], (
double)iRHS[I]
610 if (Err < 0)
return 0;
613 for (I = 1; I <=
Size; I++)
615 ( pMatrixFile,
"%-.15g\t%-.15g\n",
616 (
double)
RHS[2*I], (
double)
RHS[2*I+1]
618 if (Err < 0)
return 0;
623 #if REAL AND spCOMPLEX 627 {
for (I = 1; I <=
Size; I++)
628 {
if (fprintf(pMatrixFile,
"%-.15g\n", (
double)
RHS[I]) < 0)
635 if (fclose(pMatrixFile) < 0)
return 0;
686 char *eMatrix, *File, *
Label;
689 register int Size,
I;
691 int NumberOfElements;
692 RealNumber Data, LargestElement, SmallestElement;
693 FILE *pStatsFile, *fopen();
699 if ((pStatsFile = fopen(File,
"a")) ==
NULL)
705 fprintf(pStatsFile,
"Matrix has not been factored.\n");
706 fprintf(pStatsFile,
"||| Starting new matrix |||\n");
707 fprintf(pStatsFile,
"%s\n",
Label);
709 fprintf(pStatsFile,
"Matrix is complex.\n");
711 fprintf(pStatsFile,
"Matrix is real.\n");
712 fprintf(pStatsFile,
" Size = %d\n",Size);
715 NumberOfElements = 0;
716 LargestElement = 0.0;
717 SmallestElement = LARGEST_REAL;
719 for (I = 1; I <=
Size; I++)
721 while (pElement !=
NULL)
722 { NumberOfElements++;
724 if (Data > LargestElement)
725 LargestElement = Data;
726 if (Data < SmallestElement
AND Data != 0.0)
727 SmallestElement = Data;
732 SmallestElement =
MIN( SmallestElement, LargestElement );
735 fprintf(pStatsFile,
" Initial number of elements = %d\n",
736 NumberOfElements - Matrix->
Fillins);
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",
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);
755 (void)fclose(pStatsFile);
This document describes the JSPICE3 Josephson junction model I derivation of the model The expression for the junction current is J
#define IS_SPARSE(matrix)
struct MatrixElement * NextInCol
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
#define CALLOC(ptr, type, number)
register ElementPtr pElement
struct MatrixFrame * MatrixPtr
ArrayOfElementPtrs FirstInCol