1 /* ========================================================================= */
2 /* === CAMD_info =========================================================== */
3 /* ========================================================================= */
4 
5 /* ------------------------------------------------------------------------- */
6 /* CAMD, Copyright (c) Timothy A. Davis, Yanqing Chen,			     */
7 /* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
8 /* email: DrTimothyAldenDavis@gmail.com                                      */
9 /* ------------------------------------------------------------------------- */
10 
11 /* User-callable.  Prints the output statistics for CAMD.  See camd.h
12  * for details.  If the Info array is not present, nothing is printed.
13  */
14 
15 #include "camd_internal.h"
16 
17 #define PRI(format,x) { if (x >= 0) { SUITESPARSE_PRINTF ((format, x)) ; }}
18 
CAMD_info(double Info[])19 GLOBAL void CAMD_info
20 (
21     double Info [ ]
22 )
23 {
24     double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;
25 
26     SUITESPARSE_PRINTF (("\nCAMD version %d.%d.%d, %s, results:\n",
27 	CAMD_MAIN_VERSION, CAMD_SUB_VERSION, CAMD_SUBSUB_VERSION, CAMD_DATE)) ;
28 
29     if (!Info)
30     {
31 	return ;
32     }
33 
34     n = Info [CAMD_N] ;
35     ndiv = Info [CAMD_NDIV] ;
36     nmultsubs_ldl = Info [CAMD_NMULTSUBS_LDL] ;
37     nmultsubs_lu = Info [CAMD_NMULTSUBS_LU] ;
38     lnz = Info [CAMD_LNZ] ;
39     lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;
40 
41     /* CAMD return status */
42     SUITESPARSE_PRINTF (("    status: ")) ;
43     if (Info [CAMD_STATUS] == CAMD_OK)
44     {
45 	SUITESPARSE_PRINTF (("OK\n")) ;
46     }
47     else if (Info [CAMD_STATUS] == CAMD_OUT_OF_MEMORY)
48     {
49 	SUITESPARSE_PRINTF (("out of memory\n")) ;
50     }
51     else if (Info [CAMD_STATUS] == CAMD_INVALID)
52     {
53 	SUITESPARSE_PRINTF (("invalid matrix\n")) ;
54     }
55     else if (Info [CAMD_STATUS] == CAMD_OK_BUT_JUMBLED)
56     {
57 	SUITESPARSE_PRINTF (("OK, but jumbled\n")) ;
58     }
59     else
60     {
61 	SUITESPARSE_PRINTF (("unknown\n")) ;
62     }
63 
64     /* statistics about the input matrix */
65     PRI ("    n, dimension of A:                                  %.20g\n", n);
66     PRI ("    nz, number of nonzeros in A:                        %.20g\n",
67 	Info [CAMD_NZ]) ;
68     PRI ("    symmetry of A:                                      %.4f\n",
69 	Info [CAMD_SYMMETRY]) ;
70     PRI ("    number of nonzeros on diagonal:                     %.20g\n",
71 	Info [CAMD_NZDIAG]) ;
72     PRI ("    nonzeros in pattern of A+A' (excl. diagonal):       %.20g\n",
73 	Info [CAMD_NZ_A_PLUS_AT]) ;
74     PRI ("    # dense rows/columns of A+A':                       %.20g\n",
75 	Info [CAMD_NDENSE]) ;
76 
77     /* statistics about CAMD's behavior  */
78     PRI ("    memory used, in bytes:                              %.20g\n",
79 	Info [CAMD_MEMORY]) ;
80     PRI ("    # of memory compactions:                            %.20g\n",
81 	Info [CAMD_NCMPA]) ;
82 
83     /* statistics about the ordering quality */
84     SUITESPARSE_PRINTF (("\n"
85 	"    The following approximate statistics are for a subsequent\n"
86 	"    factorization of A(P,P) + A(P,P)'.  They are slight upper\n"
87 	"    bounds if there are no dense rows/columns in A+A', and become\n"
88 	"    looser if dense rows/columns exist.\n\n")) ;
89 
90     PRI ("    nonzeros in L (excluding diagonal):                 %.20g\n",
91 	lnz) ;
92     PRI ("    nonzeros in L (including diagonal):                 %.20g\n",
93 	lnzd) ;
94     PRI ("    # divide operations for LDL' or LU:                 %.20g\n",
95 	ndiv) ;
96     PRI ("    # multiply-subtract operations for LDL':            %.20g\n",
97 	nmultsubs_ldl) ;
98     PRI ("    # multiply-subtract operations for LU:              %.20g\n",
99 	nmultsubs_lu) ;
100     PRI ("    max nz. in any column of L (incl. diagonal):        %.20g\n",
101 	Info [CAMD_DMAX]) ;
102 
103     /* total flop counts for various factorizations */
104 
105     if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
106     {
107 	SUITESPARSE_PRINTF (("\n"
108 	"    chol flop count for real A, sqrt counted as 1 flop: %.20g\n"
109 	"    LDL' flop count for real A:                         %.20g\n"
110 	"    LDL' flop count for complex A:                      %.20g\n"
111 	"    LU flop count for real A (with no pivoting):        %.20g\n"
112 	"    LU flop count for complex A (with no pivoting):     %.20g\n\n",
113 	n + ndiv + 2*nmultsubs_ldl,
114 	    ndiv + 2*nmultsubs_ldl,
115 	  9*ndiv + 8*nmultsubs_ldl,
116 	    ndiv + 2*nmultsubs_lu,
117 	  9*ndiv + 8*nmultsubs_lu)) ;
118     }
119 }
120