1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
/* ========================================================================== */
/* === UMFPACK_report_matrix ================================================ */
/* ========================================================================== */
/* -------------------------------------------------------------------------- */
/* UMFPACK Version 4.1 (Apr. 30, 2003), Copyright (c) 2003 by Timothy A. */
/* Davis. All Rights Reserved. See ../README for License. */
/* email: davis@cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/umfpack */
/* -------------------------------------------------------------------------- */
/*
User-callable. Prints a column or row-oriented matrix. See
umfpack_report_matrix.h for details.
*/
#include "umf_internal.h"
#include "umf_malloc.h"
#include "umf_free.h"
GLOBAL Int UMFPACK_report_matrix
(
Int n_row,
Int n_col,
const Int Ap [ ],
const Int Ai [ ],
const double Ax [ ],
#ifdef COMPLEX
const double Az [ ],
#endif
Int col_form, /* 1: column form, 0: row form */
const double Control [UMFPACK_CONTROL]
)
{
Int prl, i, k, length, ilast, p, nz, prl1, p1, p2, n, n_i, do_values ;
char *vector, *index ;
Entry a ;
/* ---------------------------------------------------------------------- */
/* determine the form, and check if inputs exist */
/* ---------------------------------------------------------------------- */
prl = GET_CONTROL (UMFPACK_PRL, UMFPACK_DEFAULT_PRL) ;
if (prl <= 2)
{
return (UMFPACK_OK) ;
}
if (col_form)
{
vector = "column" ; /* column vectors */
index = "row" ; /* with row indices */
n = n_col ;
n_i = n_row ;
}
else
{
vector = "row" ; /* row vectors */
index = "column" ; /* with column indices */
n = n_row ;
n_i = n_col ;
}
PRINTF (("%s-form matrix, n_row "ID" n_col "ID", ", vector, n_row, n_col)) ;
if (n_row <= 0 || n_col <= 0)
{
PRINTF (("ERROR: n_row <= 0 or n_col <= 0\n\n")) ;
return (UMFPACK_ERROR_n_nonpositive) ;
}
if (!Ap)
{
PRINTF (("ERROR: Ap missing\n\n")) ;
return (UMFPACK_ERROR_argument_missing) ;
}
nz = Ap [n] ;
PRINTF (("nz = "ID". ", nz)) ;
if (nz < 0)
{
PRINTF (("ERROR: number of entries < 0\n\n")) ;
return (UMFPACK_ERROR_invalid_matrix) ;
}
if (Ap [0] != 0)
{
PRINTF (("ERROR: Ap ["ID"] = "ID" must be "ID"\n\n",
(Int) INDEX (0), INDEX (Ap [0]), (Int) INDEX (0))) ;
return (UMFPACK_ERROR_invalid_matrix) ;
}
if (!Ai)
{
PRINTF (("ERROR: Ai missing\n\n")) ;
return (UMFPACK_ERROR_argument_missing) ;
}
#ifdef COMPLEX
do_values = Ax && Az ;
#else
do_values = Ax != (double *) NULL ;
#endif
PRINTF4 (("\n")) ;
/* ---------------------------------------------------------------------- */
/* check the row/column pointers, Ap */
/* ---------------------------------------------------------------------- */
for (k = 0 ; k < n ; k++)
{
if (Ap [k] < 0)
{
PRINTF (("ERROR: Ap ["ID"] < 0\n\n", INDEX (k))) ;
return (UMFPACK_ERROR_invalid_matrix) ;
}
if (Ap [k] > nz)
{
PRINTF (("ERROR: Ap ["ID"] > size of Ai\n\n", INDEX (k))) ;
return (UMFPACK_ERROR_invalid_matrix) ;
}
}
for (k = 0 ; k < n ; k++)
{
length = Ap [k+1] - Ap [k] ;
if (length < 0)
{
PRINTF (("ERROR: # entries in %s "ID" is < 0\n\n",
vector, INDEX (k))) ;
return (UMFPACK_ERROR_invalid_matrix) ;
}
}
/* ---------------------------------------------------------------------- */
/* print each vector */
/* ---------------------------------------------------------------------- */
prl1 = prl ;
for (k = 0 ; k < n ; k++)
{
/* if prl is 4, print the first 10 entries of the first 10 vectors */
if (k < 10)
{
prl = prl1 ;
}
/* get the vector pointers */
p1 = Ap [k] ;
p2 = Ap [k+1] ;
length = p2 - p1 ;
PRINTF4 (("\n %s "ID": start: "ID" end: "ID" entries: "ID"\n",
vector, INDEX (k), p1, p2-1, length)) ;
ilast = EMPTY ;
for (p = p1 ; p < p2 ; p++)
{
i = Ai [p] ;
PRINTF4 (("\t%s "ID" ", index, INDEX (i))) ;
if (do_values && prl >= 4)
{
PRINTF ((":")) ;
ASSIGN (a, Ax [p], Az [p]) ;
PRINT_ENTRY (a) ;
}
if (i < 0 || i >= n_i)
{
PRINTF ((" ERROR: %s index "ID" out of range in %s "ID"\n\n",
index, INDEX (i), vector, INDEX (k))) ;
return (UMFPACK_ERROR_invalid_matrix) ;
}
if (i <= ilast)
{
PRINTF ((" ERROR: %s index "ID" out of order (or duplicate) in "
"%s "ID"\n\n", index, INDEX (i), vector, INDEX (k))) ;
return (UMFPACK_ERROR_invalid_matrix) ;
}
PRINTF4 (("\n")) ;
/* truncate printout, but continue to check matrix */
if (prl == 4 && (p - p1) == 9 && length > 10)
{
PRINTF4 (("\t...\n")) ;
prl-- ;
}
ilast = i ;
}
/* truncate printout, but continue to check matrix */
if (prl == 4 && k == 9 && n > 10)
{
PRINTF4 (("\n ...\n")) ;
prl-- ;
}
}
prl = prl1 ;
/* ---------------------------------------------------------------------- */
/* return the status of the matrix */
/* ---------------------------------------------------------------------- */
PRINTF4 ((" %s-form matrix ", vector)) ;
PRINTF (("OK\n\n")) ;
return (UMFPACK_OK) ;
}
|