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