Amesos Package Browser (Single Doxygen Collection) Development
amesos_klu_dump.c
Go to the documentation of this file.
00001 /* ========================================================================== */
00002 /* === KLU_dump ============================================================= */
00003 /* ========================================================================== */
00004 
00005 /* Debug routines for klu.  Only used when NDEBUG is not defined at
00006  * compile-time.
00007  */
00008 
00009 #include "amesos_klu_internal.h"
00010 
00011 #ifndef NDEBUG
00012 
00013 /* ========================================================================== */
00014 /* === KLU_valid ============================================================ */
00015 /* ========================================================================== */
00016 
00017 /* Check if a column-form matrix is valid or not.  The matrix A is
00018  * n-by-n.  The row indices of entries in column j are in
00019  * Ai [Ap [j] ... Ap [j+1]-1].  Required conditions are:
00020  *
00021  *  n >= 0
00022  *  nz = Ap [n_col] >= 0      number of entries in the matrix
00023  *  Ap [0] == 0
00024  *  Ap [j] <= Ap [j+1] for all j in the range 0 to n_col.
00025  *  row indices in Ai [Ap [j] ... Ap [j+1]-1]
00026  *      must be in the range 0 to n_row-1,
00027  *      and no duplicate entries can exist (duplicates not checked here).
00028  *
00029  * Not user-callable.  Only used when debugging.
00030  */
00031 
00032 Int KLU_valid (Int n, Int Ap [ ], Int Ai [ ], Entry Ax [ ])
00033 {
00034     Int nz, j, p1, p2, i, p ;
00035     PRINTF (("\ncolumn oriented matrix, n = %d\n", n)) ;
00036     if (n <= 0)
00037     {
00038   PRINTF (("n must be >= 0: %d\n", n)) ;
00039   return (FALSE) ;
00040     }
00041     nz = Ap [n] ;
00042     if (Ap [0] != 0 || nz < 0)
00043     {
00044   /* column pointers must start at Ap [0] = 0, and Ap [n] must be >= 0 */
00045   PRINTF (("column 0 pointer bad or nz < 0\n")) ;
00046   return (FALSE) ;
00047     }
00048     for (j = 0 ; j < n ; j++)
00049     {
00050   p1 = Ap [j] ;
00051   p2 = Ap [j+1] ;
00052   PRINTF (("\nColumn: %d p1: %d p2: %d\n", j, p1, p2)) ;
00053   if (p1 > p2)
00054   {
00055       /* column pointers must be ascending */
00056       PRINTF (("column %d pointer bad\n", j)) ;
00057       return (FALSE) ;
00058   }
00059   for (p = p1 ; p < p2 ; p++)
00060   {
00061       i = Ai [p] ;
00062       PRINTF (("row: %d", i)) ;
00063       if (i < 0 || i >= n)
00064       {
00065     /* row index out of range */
00066     PRINTF (("index out of range, col %d row %d\n", j, i)) ;
00067     return (FALSE) ;
00068       }
00069       if (Ax != (Entry *) NULL)
00070       {
00071     PRINT_ENTRY (Ax [p]) ;
00072       }
00073       PRINTF (("\n")) ;
00074   }
00075     }
00076     return (TRUE) ;
00077 }
00078 
00079 
00080 /* ========================================================================== */
00081 /* === KLU_valid_LU ========================================================= */
00082 /* ========================================================================== */
00083 
00084 /* This function does the same validity tests as KLU_valid but for the
00085  * LU factor storage format. The flag flag_test_start_ptr is used to
00086  * test if Xip [0] = 0. This is not applicable for U. So when calling this
00087  * function for U, the flag should be set to false.  Only used when debugging.
00088  */
00089 
00090 Int KLU_valid_LU (Int n, Int flag_test_start_ptr, Int Xip [ ],
00091        Int Xlen [ ],  Unit LU [ ])
00092 {
00093     Int *Xi ;
00094     Entry *Xx ;
00095     Int j, p1, p2, i, p, len ;
00096 
00097     PRINTF (("\ncolumn oriented matrix, n = %d\n", n)) ;
00098     if (n <= 0)
00099     {
00100   PRINTF (("n must be >= 0: %d\n", n)) ;
00101   return (FALSE) ;
00102     }
00103     if (flag_test_start_ptr && Xip [0] != 0)
00104     {
00105   /* column pointers must start at Xip [0] = 0*/
00106   PRINTF (("column 0 pointer bad\n")) ;
00107   return (FALSE) ;
00108     }
00109 
00110     for (j = 0 ; j < n ; j++)
00111     {
00112   p1 = Xip [j] ;
00113   p2 = Xip [j+1] ;
00114   PRINTF (("\nColumn: %d p1: %d p2: %d\n", j, p1, p2)) ;
00115   if (p1 > p2)
00116   {
00117       /* column pointers must be ascending */
00118       PRINTF (("column %d pointer bad\n", j)) ;
00119       return (FALSE) ;
00120   }
00121   GET_POINTER (LU, Xip, Xlen, Xi, Xx, j, len) ;
00122   for (p = 0 ; p < len ; p++)
00123   {
00124       i = Xi [p] ;
00125       PRINTF (("row: %d", i)) ;
00126       if (i < 0 || i >= n)
00127       {
00128     /* row index out of range */
00129     PRINTF (("index out of range, col %d row %d\n", j, i)) ;
00130     return (FALSE) ;
00131       }
00132       if (Xx != (Entry *) NULL)
00133       {
00134     PRINT_ENTRY (Xx [p]) ;
00135       }
00136       PRINTF (("\n")) ;
00137   }
00138     }
00139 
00140     return (TRUE) ;
00141 }
00142 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines