1 /* ========================================================================= */ 2 /* === AMD_info ============================================================ */ 3 /* ========================================================================= */ 4 5 /* ------------------------------------------------------------------------- */ 6 /* AMD, Copyright (c) Timothy A. Davis, */ 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 AMD. See amd.h 12 * for details. If the Info array is not present, nothing is printed. 13 */ 14 15 module amd_info; 16 17 nothrow @nogc extern(C): 18 19 import glob_opts; 20 import amd_internal; 21 import amd; 22 import SuiteSparse_config; 23 24 //#define PRI(format,x) { if (x >= 0) { SUITESPARSE_PRINTF ((format, x)) ; }} 25 //auto PRI (T)(string format, auto ref T x) { if (x >= 0) { SUITESPARSE_PRINTF ((format, x)) ; }} 26 auto PRI (T)(string format, auto ref T x) { return; } // todo : later 27 28 void AMD_info 29 ( 30 c_float *Info 31 ) 32 { 33 c_float n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ; 34 35 //SUITESPARSE_PRINTF (("\nAMD version %d.%d.%d, %s, results:\n", AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ; // todo : later 36 37 if (!Info) 38 { 39 return ; 40 } 41 42 n = Info [AMD_N] ; 43 ndiv = Info [AMD_NDIV] ; 44 nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ; 45 nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ; 46 lnz = Info [AMD_LNZ] ; 47 lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ; 48 49 /* AMD return status */ 50 SUITESPARSE_PRINTF ((" status: ")) ; 51 if (Info [AMD_STATUS] == AMD_OK) 52 { 53 SUITESPARSE_PRINTF (("OK\n")) ; 54 } 55 else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY) 56 { 57 SUITESPARSE_PRINTF (("out of memory\n")) ; 58 } 59 else if (Info [AMD_STATUS] == AMD_INVALID) 60 { 61 SUITESPARSE_PRINTF (("invalid matrix\n")) ; 62 } 63 else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED) 64 { 65 SUITESPARSE_PRINTF (("OK, but jumbled\n")) ; 66 } 67 else 68 { 69 SUITESPARSE_PRINTF (("unknown\n")) ; 70 } 71 72 /* statistics about the input matrix */ 73 PRI (" n, dimension of A: %.20g\n", n); 74 PRI (" nz, number of nonzeros in A: %.20g\n", 75 Info [AMD_NZ]) ; 76 PRI (" symmetry of A: %.4f\n", 77 Info [AMD_SYMMETRY]) ; 78 PRI (" number of nonzeros on diagonal: %.20g\n", 79 Info [AMD_NZDIAG]) ; 80 PRI (" nonzeros in pattern of A+A' (excl. diagonal): %.20g\n", 81 Info [AMD_NZ_A_PLUS_AT]) ; 82 PRI (" # dense rows/columns of A+A': %.20g\n", 83 Info [AMD_NDENSE]) ; 84 85 /* statistics about AMD's behavior */ 86 PRI (" memory used, in bytes: %.20g\n", 87 Info [AMD_MEMORY]) ; 88 PRI (" # of memory compactions: %.20g\n", 89 Info [AMD_NCMPA]) ; 90 91 /* statistics about the ordering quality */ 92 /*SUITESPARSE_PRINTF (("\n" 93 " The following approximate statistics are for a subsequent\n" 94 " factorization of A(P,P) + A(P,P)'. They are slight upper\n" 95 " bounds if there are no dense rows/columns in A+A', and become\n" 96 " looser if dense rows/columns exist.\n\n")) ; 97 98 PRI (" nonzeros in L (excluding diagonal): %.20g\n", 99 lnz) ; 100 PRI (" nonzeros in L (including diagonal): %.20g\n", 101 lnzd) ; 102 PRI (" # divide operations for LDL' or LU: %.20g\n", 103 ndiv) ; 104 PRI (" # multiply-subtract operations for LDL': %.20g\n", 105 nmultsubs_ldl) ; 106 PRI (" # multiply-subtract operations for LU: %.20g\n", 107 nmultsubs_lu) ; 108 PRI (" max nz. in any column of L (incl. diagonal): %.20g\n", 109 Info [AMD_DMAX]) ;*/ // todo : later 110 111 /* total flop counts for various factorizations */ 112 113 if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0) 114 { 115 /*SUITESPARSE_PRINTF (("\n" 116 " chol flop count for real A, sqrt counted as 1 flop: %.20g\n" 117 " LDL' flop count for real A: %.20g\n" 118 " LDL' flop count for complex A: %.20g\n" 119 " LU flop count for real A (with no pivoting): %.20g\n" 120 " LU flop count for complex A (with no pivoting): %.20g\n\n", 121 n + ndiv + 2*nmultsubs_ldl, 122 ndiv + 2*nmultsubs_ldl, 123 9*ndiv + 8*nmultsubs_ldl, 124 ndiv + 2*nmultsubs_lu, 125 9*ndiv + 8*nmultsubs_lu)) ;*/ // todo : later 126 } 127 }