src/amd/amd_info.c
author Alpar Juttner <alpar@cs.elte.hu>
Sun, 05 Dec 2010 17:35:23 +0100
changeset 2 4c8956a7bdf4
permissions -rw-r--r--
Set up CMAKE build environment
alpar@1
     1
/* ========================================================================= */
alpar@1
     2
/* === AMD_info ============================================================ */
alpar@1
     3
/* ========================================================================= */
alpar@1
     4
alpar@1
     5
/* ------------------------------------------------------------------------- */
alpar@1
     6
/* AMD, Copyright (c) Timothy A. Davis,                                      */
alpar@1
     7
/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
alpar@1
     8
/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
alpar@1
     9
/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
alpar@1
    10
/* ------------------------------------------------------------------------- */
alpar@1
    11
alpar@1
    12
/* User-callable.  Prints the output statistics for AMD.  See amd.h
alpar@1
    13
 * for details.  If the Info array is not present, nothing is printed.
alpar@1
    14
 */
alpar@1
    15
alpar@1
    16
#include "amd_internal.h"
alpar@1
    17
alpar@1
    18
#define PRI(format,x) { if (x >= 0) { PRINTF ((format, x)) ; }}
alpar@1
    19
alpar@1
    20
GLOBAL void AMD_info
alpar@1
    21
(
alpar@1
    22
    double Info [ ]
alpar@1
    23
)
alpar@1
    24
{
alpar@1
    25
    double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;
alpar@1
    26
alpar@1
    27
    PRINTF (("\nAMD version %d.%d.%d, %s, results:\n",
alpar@1
    28
        AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ;
alpar@1
    29
alpar@1
    30
    if (!Info)
alpar@1
    31
    {
alpar@1
    32
        return ;
alpar@1
    33
    }
alpar@1
    34
alpar@1
    35
    n = Info [AMD_N] ;
alpar@1
    36
    ndiv = Info [AMD_NDIV] ;
alpar@1
    37
    nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ;
alpar@1
    38
    nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ;
alpar@1
    39
    lnz = Info [AMD_LNZ] ;
alpar@1
    40
    lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;
alpar@1
    41
alpar@1
    42
    /* AMD return status */
alpar@1
    43
    PRINTF (("    status: ")) ;
alpar@1
    44
    if (Info [AMD_STATUS] == AMD_OK)
alpar@1
    45
    {
alpar@1
    46
        PRINTF (("OK\n")) ;
alpar@1
    47
    }
alpar@1
    48
    else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY)
alpar@1
    49
    {
alpar@1
    50
        PRINTF (("out of memory\n")) ;
alpar@1
    51
    }
alpar@1
    52
    else if (Info [AMD_STATUS] == AMD_INVALID)
alpar@1
    53
    {
alpar@1
    54
        PRINTF (("invalid matrix\n")) ;
alpar@1
    55
    }
alpar@1
    56
    else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED)
alpar@1
    57
    {
alpar@1
    58
        PRINTF (("OK, but jumbled\n")) ;
alpar@1
    59
    }
alpar@1
    60
    else
alpar@1
    61
    {
alpar@1
    62
        PRINTF (("unknown\n")) ;
alpar@1
    63
    }
alpar@1
    64
alpar@1
    65
    /* statistics about the input matrix */
alpar@1
    66
    PRI ("    n, dimension of A:                                  %.20g\n", n);
alpar@1
    67
    PRI ("    nz, number of nonzeros in A:                        %.20g\n",
alpar@1
    68
        Info [AMD_NZ]) ;
alpar@1
    69
    PRI ("    symmetry of A:                                      %.4f\n",
alpar@1
    70
        Info [AMD_SYMMETRY]) ;
alpar@1
    71
    PRI ("    number of nonzeros on diagonal:                     %.20g\n",
alpar@1
    72
        Info [AMD_NZDIAG]) ;
alpar@1
    73
    PRI ("    nonzeros in pattern of A+A' (excl. diagonal):       %.20g\n",
alpar@1
    74
        Info [AMD_NZ_A_PLUS_AT]) ;
alpar@1
    75
    PRI ("    # dense rows/columns of A+A':                       %.20g\n",
alpar@1
    76
        Info [AMD_NDENSE]) ;
alpar@1
    77
alpar@1
    78
    /* statistics about AMD's behavior  */
alpar@1
    79
    PRI ("    memory used, in bytes:                              %.20g\n",
alpar@1
    80
        Info [AMD_MEMORY]) ;
alpar@1
    81
    PRI ("    # of memory compactions:                            %.20g\n",
alpar@1
    82
        Info [AMD_NCMPA]) ;
alpar@1
    83
alpar@1
    84
    /* statistics about the ordering quality */
alpar@1
    85
    PRINTF (("\n"
alpar@1
    86
        "    The following approximate statistics are for a subsequent\n"
alpar@1
    87
        "    factorization of A(P,P) + A(P,P)'.  They are slight upper\n"
alpar@1
    88
        "    bounds if there are no dense rows/columns in A+A', and become\n"
alpar@1
    89
        "    looser if dense rows/columns exist.\n\n")) ;
alpar@1
    90
alpar@1
    91
    PRI ("    nonzeros in L (excluding diagonal):                 %.20g\n",
alpar@1
    92
        lnz) ;
alpar@1
    93
    PRI ("    nonzeros in L (including diagonal):                 %.20g\n",
alpar@1
    94
        lnzd) ;
alpar@1
    95
    PRI ("    # divide operations for LDL' or LU:                 %.20g\n",
alpar@1
    96
        ndiv) ;
alpar@1
    97
    PRI ("    # multiply-subtract operations for LDL':            %.20g\n",
alpar@1
    98
        nmultsubs_ldl) ;
alpar@1
    99
    PRI ("    # multiply-subtract operations for LU:              %.20g\n",
alpar@1
   100
        nmultsubs_lu) ;
alpar@1
   101
    PRI ("    max nz. in any column of L (incl. diagonal):        %.20g\n",
alpar@1
   102
        Info [AMD_DMAX]) ;
alpar@1
   103
alpar@1
   104
    /* total flop counts for various factorizations */
alpar@1
   105
alpar@1
   106
    if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
alpar@1
   107
    {
alpar@1
   108
        PRINTF (("\n"
alpar@1
   109
        "    chol flop count for real A, sqrt counted as 1 flop: %.20g\n"
alpar@1
   110
        "    LDL' flop count for real A:                         %.20g\n"
alpar@1
   111
        "    LDL' flop count for complex A:                      %.20g\n"
alpar@1
   112
        "    LU flop count for real A (with no pivoting):        %.20g\n"
alpar@1
   113
        "    LU flop count for complex A (with no pivoting):     %.20g\n\n",
alpar@1
   114
        n + ndiv + 2*nmultsubs_ldl,
alpar@1
   115
            ndiv + 2*nmultsubs_ldl,
alpar@1
   116
          9*ndiv + 8*nmultsubs_ldl,
alpar@1
   117
            ndiv + 2*nmultsubs_lu,
alpar@1
   118
          9*ndiv + 8*nmultsubs_lu)) ;
alpar@1
   119
    }
alpar@1
   120
}