src/amd/amd_info.c
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/amd/amd_info.c	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +/* ========================================================================= */
     1.5 +/* === AMD_info ============================================================ */
     1.6 +/* ========================================================================= */
     1.7 +
     1.8 +/* ------------------------------------------------------------------------- */
     1.9 +/* AMD, Copyright (c) Timothy A. Davis,                                      */
    1.10 +/* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
    1.11 +/* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
    1.12 +/* web: http://www.cise.ufl.edu/research/sparse/amd                          */
    1.13 +/* ------------------------------------------------------------------------- */
    1.14 +
    1.15 +/* User-callable.  Prints the output statistics for AMD.  See amd.h
    1.16 + * for details.  If the Info array is not present, nothing is printed.
    1.17 + */
    1.18 +
    1.19 +#include "amd_internal.h"
    1.20 +
    1.21 +#define PRI(format,x) { if (x >= 0) { PRINTF ((format, x)) ; }}
    1.22 +
    1.23 +GLOBAL void AMD_info
    1.24 +(
    1.25 +    double Info [ ]
    1.26 +)
    1.27 +{
    1.28 +    double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;
    1.29 +
    1.30 +    PRINTF (("\nAMD version %d.%d.%d, %s, results:\n",
    1.31 +        AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ;
    1.32 +
    1.33 +    if (!Info)
    1.34 +    {
    1.35 +        return ;
    1.36 +    }
    1.37 +
    1.38 +    n = Info [AMD_N] ;
    1.39 +    ndiv = Info [AMD_NDIV] ;
    1.40 +    nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ;
    1.41 +    nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ;
    1.42 +    lnz = Info [AMD_LNZ] ;
    1.43 +    lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;
    1.44 +
    1.45 +    /* AMD return status */
    1.46 +    PRINTF (("    status: ")) ;
    1.47 +    if (Info [AMD_STATUS] == AMD_OK)
    1.48 +    {
    1.49 +        PRINTF (("OK\n")) ;
    1.50 +    }
    1.51 +    else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY)
    1.52 +    {
    1.53 +        PRINTF (("out of memory\n")) ;
    1.54 +    }
    1.55 +    else if (Info [AMD_STATUS] == AMD_INVALID)
    1.56 +    {
    1.57 +        PRINTF (("invalid matrix\n")) ;
    1.58 +    }
    1.59 +    else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED)
    1.60 +    {
    1.61 +        PRINTF (("OK, but jumbled\n")) ;
    1.62 +    }
    1.63 +    else
    1.64 +    {
    1.65 +        PRINTF (("unknown\n")) ;
    1.66 +    }
    1.67 +
    1.68 +    /* statistics about the input matrix */
    1.69 +    PRI ("    n, dimension of A:                                  %.20g\n", n);
    1.70 +    PRI ("    nz, number of nonzeros in A:                        %.20g\n",
    1.71 +        Info [AMD_NZ]) ;
    1.72 +    PRI ("    symmetry of A:                                      %.4f\n",
    1.73 +        Info [AMD_SYMMETRY]) ;
    1.74 +    PRI ("    number of nonzeros on diagonal:                     %.20g\n",
    1.75 +        Info [AMD_NZDIAG]) ;
    1.76 +    PRI ("    nonzeros in pattern of A+A' (excl. diagonal):       %.20g\n",
    1.77 +        Info [AMD_NZ_A_PLUS_AT]) ;
    1.78 +    PRI ("    # dense rows/columns of A+A':                       %.20g\n",
    1.79 +        Info [AMD_NDENSE]) ;
    1.80 +
    1.81 +    /* statistics about AMD's behavior  */
    1.82 +    PRI ("    memory used, in bytes:                              %.20g\n",
    1.83 +        Info [AMD_MEMORY]) ;
    1.84 +    PRI ("    # of memory compactions:                            %.20g\n",
    1.85 +        Info [AMD_NCMPA]) ;
    1.86 +
    1.87 +    /* statistics about the ordering quality */
    1.88 +    PRINTF (("\n"
    1.89 +        "    The following approximate statistics are for a subsequent\n"
    1.90 +        "    factorization of A(P,P) + A(P,P)'.  They are slight upper\n"
    1.91 +        "    bounds if there are no dense rows/columns in A+A', and become\n"
    1.92 +        "    looser if dense rows/columns exist.\n\n")) ;
    1.93 +
    1.94 +    PRI ("    nonzeros in L (excluding diagonal):                 %.20g\n",
    1.95 +        lnz) ;
    1.96 +    PRI ("    nonzeros in L (including diagonal):                 %.20g\n",
    1.97 +        lnzd) ;
    1.98 +    PRI ("    # divide operations for LDL' or LU:                 %.20g\n",
    1.99 +        ndiv) ;
   1.100 +    PRI ("    # multiply-subtract operations for LDL':            %.20g\n",
   1.101 +        nmultsubs_ldl) ;
   1.102 +    PRI ("    # multiply-subtract operations for LU:              %.20g\n",
   1.103 +        nmultsubs_lu) ;
   1.104 +    PRI ("    max nz. in any column of L (incl. diagonal):        %.20g\n",
   1.105 +        Info [AMD_DMAX]) ;
   1.106 +
   1.107 +    /* total flop counts for various factorizations */
   1.108 +
   1.109 +    if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
   1.110 +    {
   1.111 +        PRINTF (("\n"
   1.112 +        "    chol flop count for real A, sqrt counted as 1 flop: %.20g\n"
   1.113 +        "    LDL' flop count for real A:                         %.20g\n"
   1.114 +        "    LDL' flop count for complex A:                      %.20g\n"
   1.115 +        "    LU flop count for real A (with no pivoting):        %.20g\n"
   1.116 +        "    LU flop count for complex A (with no pivoting):     %.20g\n\n",
   1.117 +        n + ndiv + 2*nmultsubs_ldl,
   1.118 +            ndiv + 2*nmultsubs_ldl,
   1.119 +          9*ndiv + 8*nmultsubs_ldl,
   1.120 +            ndiv + 2*nmultsubs_lu,
   1.121 +          9*ndiv + 8*nmultsubs_lu)) ;
   1.122 +    }
   1.123 +}