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