File: camd_info.c

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (119 lines) | stat: -rw-r--r-- 4,179 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//------------------------------------------------------------------------------
// CAMD/Source/camd_info: print output statistics for CAMD
//------------------------------------------------------------------------------

// CAMD, Copyright (c) 2007-2022, Timothy A. Davis, Yanqing Chen, Patrick R.
// Amestoy, and Iain S. Duff.  All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause

//------------------------------------------------------------------------------

/* User-callable.  Prints the output statistics for CAMD.  See camd.h
 * for details.  If the Info array is not present, nothing is printed.
 */

#include "camd_internal.h"

#define PRI(format,x) { if (x >= 0) { SUITESPARSE_PRINTF ((format, x)) ; }}

void CAMD_info
(
    double Info [ ]
)
{
    double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;

    SUITESPARSE_PRINTF (("\nCAMD version %d.%d.%d, %s, results:\n",
	CAMD_MAIN_VERSION, CAMD_SUB_VERSION, CAMD_SUBSUB_VERSION, CAMD_DATE)) ;

    if (!Info)
    {
	return ;
    }

    n = Info [CAMD_N] ;
    ndiv = Info [CAMD_NDIV] ;
    nmultsubs_ldl = Info [CAMD_NMULTSUBS_LDL] ;
    nmultsubs_lu = Info [CAMD_NMULTSUBS_LU] ;
    lnz = Info [CAMD_LNZ] ;
    lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;

    /* CAMD return status */
    SUITESPARSE_PRINTF (("    status: ")) ;
    if (Info [CAMD_STATUS] == CAMD_OK)
    {
	SUITESPARSE_PRINTF (("OK\n")) ;
    }
    else if (Info [CAMD_STATUS] == CAMD_OUT_OF_MEMORY)
    {
	SUITESPARSE_PRINTF (("out of memory\n")) ;
    }
    else if (Info [CAMD_STATUS] == CAMD_INVALID)
    {
	SUITESPARSE_PRINTF (("invalid matrix\n")) ;
    }
    else if (Info [CAMD_STATUS] == CAMD_OK_BUT_JUMBLED)
    {
	SUITESPARSE_PRINTF (("OK, but jumbled\n")) ;
    }
    else
    {
	SUITESPARSE_PRINTF (("unknown\n")) ;
    }

    /* statistics about the input matrix */
    PRI ("    n, dimension of A:                                  %.20g\n", n);
    PRI ("    nz, number of nonzeros in A:                        %.20g\n",
	Info [CAMD_NZ]) ;
    PRI ("    symmetry of A:                                      %.4f\n",
	Info [CAMD_SYMMETRY]) ;
    PRI ("    number of nonzeros on diagonal:                     %.20g\n",
	Info [CAMD_NZDIAG]) ;
    PRI ("    nonzeros in pattern of A+A' (excl. diagonal):       %.20g\n",
	Info [CAMD_NZ_A_PLUS_AT]) ;
    PRI ("    # dense rows/columns of A+A':                       %.20g\n",
	Info [CAMD_NDENSE]) ;

    /* statistics about CAMD's behavior  */
    PRI ("    memory used, in bytes:                              %.20g\n",
	Info [CAMD_MEMORY]) ;
    PRI ("    # of memory compactions:                            %.20g\n",
	Info [CAMD_NCMPA]) ;

    /* statistics about the ordering quality */
    SUITESPARSE_PRINTF (("\n"
	"    The following approximate statistics are for a subsequent\n"
	"    factorization of A(P,P) + A(P,P)'.  They are slight upper\n"
	"    bounds if there are no dense rows/columns in A+A', and become\n"
	"    looser if dense rows/columns exist.\n\n")) ;

    PRI ("    nonzeros in L (excluding diagonal):                 %.20g\n",
	lnz) ;
    PRI ("    nonzeros in L (including diagonal):                 %.20g\n",
	lnzd) ;
    PRI ("    # divide operations for LDL' or LU:                 %.20g\n",
	ndiv) ;
    PRI ("    # multiply-subtract operations for LDL':            %.20g\n",
	nmultsubs_ldl) ;
    PRI ("    # multiply-subtract operations for LU:              %.20g\n",
	nmultsubs_lu) ;
    PRI ("    max nz. in any column of L (incl. diagonal):        %.20g\n",
	Info [CAMD_DMAX]) ;

    /* total flop counts for various factorizations */

    if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
    {
	SUITESPARSE_PRINTF (("\n"
	"    chol flop count for real A, sqrt counted as 1 flop: %.20g\n"
	"    LDL' flop count for real A:                         %.20g\n"
	"    LDL' flop count for complex A:                      %.20g\n"
	"    LU flop count for real A (with no pivoting):        %.20g\n"
	"    LU flop count for complex A (with no pivoting):     %.20g\n\n",
	n + ndiv + 2*nmultsubs_ldl,
	    ndiv + 2*nmultsubs_ldl,
	  9*ndiv + 8*nmultsubs_ldl,
	    ndiv + 2*nmultsubs_lu,
	  9*ndiv + 8*nmultsubs_lu)) ;
    }
}