amd_info.c 4.4 KB

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