1 /* ========================================================================== */
2 /* === Include/cholmod_check.h ============================================== */
3 /* ========================================================================== */
4 
5 /* -----------------------------------------------------------------------------
6  * CHOLMOD/Include/cholmod_check.h.  Copyright (C) 2005-2006, Timothy A. Davis
7  * http://www.suitesparse.com
8  * -------------------------------------------------------------------------- */
9 
10 /* CHOLMOD Check module.
11  *
12  * Routines that check and print the 5 basic data types in CHOLMOD, and 3 kinds
13  * of integer vectors (subset, perm, and parent), and read in matrices from a
14  * file:
15  *
16  * cholmod_check_common	    check/print the Common object
17  * cholmod_print_common
18  *
19  * cholmod_check_sparse	    check/print a sparse matrix in column-oriented form
20  * cholmod_print_sparse
21  *
22  * cholmod_check_dense	    check/print a dense matrix
23  * cholmod_print_dense
24  *
25  * cholmod_check_factor	    check/print a Cholesky factorization
26  * cholmod_print_factor
27  *
28  * cholmod_check_triplet    check/print a sparse matrix in triplet form
29  * cholmod_print_triplet
30  *
31  * cholmod_check_subset	    check/print a subset (integer vector in given range)
32  * cholmod_print_subset
33  *
34  * cholmod_check_perm	    check/print a permutation (an integer vector)
35  * cholmod_print_perm
36  *
37  * cholmod_check_parent	    check/print an elimination tree (an integer vector)
38  * cholmod_print_parent
39  *
40  * cholmod_read_triplet	    read a matrix in triplet form (any Matrix Market
41  *			    "coordinate" format, or a generic triplet format).
42  *
43  * cholmod_read_sparse	    read a matrix in sparse form (same file format as
44  *			    cholmod_read_triplet).
45  *
46  * cholmod_read_dense	    read a dense matrix (any Matrix Market "array"
47  *			    format, or a generic dense format).
48  *
49  * cholmod_write_sparse	    write a sparse matrix to a Matrix Market file.
50  *
51  * cholmod_write_dense	    write a dense matrix to a Matrix Market file.
52  *
53  * cholmod_print_common and cholmod_check_common are the only two routines that
54  * you may call after calling cholmod_finish.
55  *
56  * Requires the Core module.  Not required by any CHOLMOD module, except when
57  * debugging is enabled (in which case all modules require the Check module).
58  *
59  * See cholmod_read.c for a description of the file formats supported by the
60  * cholmod_read_* routines.
61  */
62 
63 #ifndef CHOLMOD_CHECK_H
64 #define CHOLMOD_CHECK_H
65 
66 #include "cholmod_core.h"
67 #include <stdio.h>
68 
69 /* -------------------------------------------------------------------------- */
70 /* cholmod_check_common:  check the Common object */
71 /* -------------------------------------------------------------------------- */
72 
73 int cholmod_check_common
74 (
75     cholmod_common *Common
76 ) ;
77 
78 int cholmod_l_check_common (cholmod_common *) ;
79 
80 /* -------------------------------------------------------------------------- */
81 /* cholmod_print_common:  print the Common object */
82 /* -------------------------------------------------------------------------- */
83 
84 int cholmod_print_common
85 (
86     /* ---- input ---- */
87     const char *name,	/* printed name of Common object */
88     /* --------------- */
89     cholmod_common *Common
90 ) ;
91 
92 int cholmod_l_print_common (const char *, cholmod_common *) ;
93 
94 /* -------------------------------------------------------------------------- */
95 /* cholmod_gpu_stats:  print the GPU / CPU statistics */
96 /* -------------------------------------------------------------------------- */
97 
98 int cholmod_gpu_stats   (cholmod_common *) ;
99 int cholmod_l_gpu_stats (cholmod_common *) ;
100 
101 /* -------------------------------------------------------------------------- */
102 /* cholmod_check_sparse:  check a sparse matrix */
103 /* -------------------------------------------------------------------------- */
104 
105 int cholmod_check_sparse
106 (
107     /* ---- input ---- */
108     cholmod_sparse *A,	/* sparse matrix to check */
109     /* --------------- */
110     cholmod_common *Common
111 ) ;
112 
113 int cholmod_l_check_sparse (cholmod_sparse *, cholmod_common *) ;
114 
115 /* -------------------------------------------------------------------------- */
116 /* cholmod_print_sparse */
117 /* -------------------------------------------------------------------------- */
118 
119 int cholmod_print_sparse
120 (
121     /* ---- input ---- */
122     cholmod_sparse *A,	/* sparse matrix to print */
123     const char *name,	/* printed name of sparse matrix */
124     /* --------------- */
125     cholmod_common *Common
126 ) ;
127 
128 int cholmod_l_print_sparse (cholmod_sparse *, const char *, cholmod_common *) ;
129 
130 /* -------------------------------------------------------------------------- */
131 /* cholmod_check_dense:  check a dense matrix */
132 /* -------------------------------------------------------------------------- */
133 
134 int cholmod_check_dense
135 (
136     /* ---- input ---- */
137     cholmod_dense *X,	/* dense matrix to check */
138     /* --------------- */
139     cholmod_common *Common
140 ) ;
141 
142 int cholmod_l_check_dense (cholmod_dense *, cholmod_common *) ;
143 
144 /* -------------------------------------------------------------------------- */
145 /* cholmod_print_dense:  print a dense matrix */
146 /* -------------------------------------------------------------------------- */
147 
148 int cholmod_print_dense
149 (
150     /* ---- input ---- */
151     cholmod_dense *X,	/* dense matrix to print */
152     const char *name,	/* printed name of dense matrix */
153     /* --------------- */
154     cholmod_common *Common
155 ) ;
156 
157 int cholmod_l_print_dense (cholmod_dense *, const char *, cholmod_common *) ;
158 
159 /* -------------------------------------------------------------------------- */
160 /* cholmod_check_factor:  check a factor */
161 /* -------------------------------------------------------------------------- */
162 
163 int cholmod_check_factor
164 (
165     /* ---- input ---- */
166     cholmod_factor *L,	/* factor to check */
167     /* --------------- */
168     cholmod_common *Common
169 ) ;
170 
171 int cholmod_l_check_factor (cholmod_factor *, cholmod_common *) ;
172 
173 /* -------------------------------------------------------------------------- */
174 /* cholmod_print_factor:  print a factor */
175 /* -------------------------------------------------------------------------- */
176 
177 int cholmod_print_factor
178 (
179     /* ---- input ---- */
180     cholmod_factor *L,	/* factor to print */
181     const char *name,	/* printed name of factor */
182     /* --------------- */
183     cholmod_common *Common
184 ) ;
185 
186 int cholmod_l_print_factor (cholmod_factor *, const char *, cholmod_common *) ;
187 
188 /* -------------------------------------------------------------------------- */
189 /* cholmod_check_triplet:  check a sparse matrix in triplet form */
190 /* -------------------------------------------------------------------------- */
191 
192 int cholmod_check_triplet
193 (
194     /* ---- input ---- */
195     cholmod_triplet *T,	/* triplet matrix to check */
196     /* --------------- */
197     cholmod_common *Common
198 ) ;
199 
200 int cholmod_l_check_triplet (cholmod_triplet *, cholmod_common *) ;
201 
202 /* -------------------------------------------------------------------------- */
203 /* cholmod_print_triplet:  print a triplet matrix */
204 /* -------------------------------------------------------------------------- */
205 
206 int cholmod_print_triplet
207 (
208     /* ---- input ---- */
209     cholmod_triplet *T,	/* triplet matrix to print */
210     const char *name,	/* printed name of triplet matrix */
211     /* --------------- */
212     cholmod_common *Common
213 ) ;
214 
215 int cholmod_l_print_triplet (cholmod_triplet *, const char *, cholmod_common *);
216 
217 /* -------------------------------------------------------------------------- */
218 /* cholmod_check_subset:  check a subset */
219 /* -------------------------------------------------------------------------- */
220 
221 int cholmod_check_subset
222 (
223     /* ---- input ---- */
224     int *Set,		/* Set [0:len-1] is a subset of 0:n-1.  Duplicates OK */
225     SuiteSparse_long len,   /* size of Set (an integer array) */
226     size_t n,		/* 0:n-1 is valid range */
227     /* --------------- */
228     cholmod_common *Common
229 ) ;
230 
231 int cholmod_l_check_subset (SuiteSparse_long *, SuiteSparse_long, size_t,
232     cholmod_common *) ;
233 
234 /* -------------------------------------------------------------------------- */
235 /* cholmod_print_subset:  print a subset */
236 /* -------------------------------------------------------------------------- */
237 
238 int cholmod_print_subset
239 (
240     /* ---- input ---- */
241     int *Set,		/* Set [0:len-1] is a subset of 0:n-1.  Duplicates OK */
242     SuiteSparse_long len,   /* size of Set (an integer array) */
243     size_t n,		/* 0:n-1 is valid range */
244     const char *name,	/* printed name of Set */
245     /* --------------- */
246     cholmod_common *Common
247 ) ;
248 
249 int cholmod_l_print_subset (SuiteSparse_long *, SuiteSparse_long, size_t,
250     const char *, cholmod_common *) ;
251 
252 /* -------------------------------------------------------------------------- */
253 /* cholmod_check_perm:  check a permutation */
254 /* -------------------------------------------------------------------------- */
255 
256 int cholmod_check_perm
257 (
258     /* ---- input ---- */
259     int *Perm,		/* Perm [0:len-1] is a permutation of subset of 0:n-1 */
260     size_t len,		/* size of Perm (an integer array) */
261     size_t n,		/* 0:n-1 is valid range */
262     /* --------------- */
263     cholmod_common *Common
264 ) ;
265 
266 int cholmod_l_check_perm (SuiteSparse_long *, size_t, size_t, cholmod_common *);
267 
268 /* -------------------------------------------------------------------------- */
269 /* cholmod_print_perm:  print a permutation vector */
270 /* -------------------------------------------------------------------------- */
271 
272 int cholmod_print_perm
273 (
274     /* ---- input ---- */
275     int *Perm,		/* Perm [0:len-1] is a permutation of subset of 0:n-1 */
276     size_t len,		/* size of Perm (an integer array) */
277     size_t n,		/* 0:n-1 is valid range */
278     const char *name,	/* printed name of Perm */
279     /* --------------- */
280     cholmod_common *Common
281 ) ;
282 
283 int cholmod_l_print_perm (SuiteSparse_long *, size_t, size_t, const char *,
284     cholmod_common *) ;
285 
286 /* -------------------------------------------------------------------------- */
287 /* cholmod_check_parent:  check an elimination tree */
288 /* -------------------------------------------------------------------------- */
289 
290 int cholmod_check_parent
291 (
292     /* ---- input ---- */
293     int *Parent,	/* Parent [0:n-1] is an elimination tree */
294     size_t n,		/* size of Parent */
295     /* --------------- */
296     cholmod_common *Common
297 ) ;
298 
299 int cholmod_l_check_parent (SuiteSparse_long *, size_t, cholmod_common *) ;
300 
301 /* -------------------------------------------------------------------------- */
302 /* cholmod_print_parent */
303 /* -------------------------------------------------------------------------- */
304 
305 int cholmod_print_parent
306 (
307     /* ---- input ---- */
308     int *Parent,	/* Parent [0:n-1] is an elimination tree */
309     size_t n,		/* size of Parent */
310     const char *name,	/* printed name of Parent */
311     /* --------------- */
312     cholmod_common *Common
313 ) ;
314 
315 int cholmod_l_print_parent (SuiteSparse_long *, size_t, const char *,
316     cholmod_common *) ;
317 
318 /* -------------------------------------------------------------------------- */
319 /* cholmod_read_sparse: read a sparse matrix from a file */
320 /* -------------------------------------------------------------------------- */
321 
322 cholmod_sparse *cholmod_read_sparse
323 (
324     /* ---- input ---- */
325     FILE *f,		/* file to read from, must already be open */
326     /* --------------- */
327     cholmod_common *Common
328 ) ;
329 
330 cholmod_sparse *cholmod_l_read_sparse (FILE *, cholmod_common *) ;
331 
332 /* -------------------------------------------------------------------------- */
333 /* cholmod_read_triplet: read a triplet matrix from a file */
334 /* -------------------------------------------------------------------------- */
335 
336 cholmod_triplet *cholmod_read_triplet
337 (
338     /* ---- input ---- */
339     FILE *f,		/* file to read from, must already be open */
340     /* --------------- */
341     cholmod_common *Common
342 ) ;
343 
344 cholmod_triplet *cholmod_l_read_triplet (FILE *, cholmod_common *) ;
345 
346 /* -------------------------------------------------------------------------- */
347 /* cholmod_read_dense: read a dense matrix from a file */
348 /* -------------------------------------------------------------------------- */
349 
350 cholmod_dense *cholmod_read_dense
351 (
352     /* ---- input ---- */
353     FILE *f,		/* file to read from, must already be open */
354     /* --------------- */
355     cholmod_common *Common
356 ) ;
357 
358 cholmod_dense *cholmod_l_read_dense (FILE *, cholmod_common *) ;
359 
360 /* -------------------------------------------------------------------------- */
361 /* cholmod_read_matrix: read a sparse or dense matrix from a file */
362 /* -------------------------------------------------------------------------- */
363 
364 void *cholmod_read_matrix
365 (
366     /* ---- input ---- */
367     FILE *f,		/* file to read from, must already be open */
368     int prefer,		/* If 0, a sparse matrix is always return as a
369 			 *	cholmod_triplet form.  It can have any stype
370 			 *	(symmetric-lower, unsymmetric, or
371 			 *	symmetric-upper).
372 			 * If 1, a sparse matrix is returned as an unsymmetric
373 			 *	cholmod_sparse form (A->stype == 0), with both
374 			 *	upper and lower triangular parts present.
375 			 *	This is what the MATLAB mread mexFunction does,
376 			 *	since MATLAB does not have an stype.
377 			 * If 2, a sparse matrix is returned with an stype of 0
378 			 *	or 1 (unsymmetric, or symmetric with upper part
379 			 *	stored).
380 			 * This argument has no effect for dense matrices.
381 			 */
382     /* ---- output---- */
383     int *mtype,		/* CHOLMOD_TRIPLET, CHOLMOD_SPARSE or CHOLMOD_DENSE */
384     /* --------------- */
385     cholmod_common *Common
386 ) ;
387 
388 void *cholmod_l_read_matrix (FILE *, int, int *, cholmod_common *) ;
389 
390 /* -------------------------------------------------------------------------- */
391 /* cholmod_write_sparse: write a sparse matrix to a file */
392 /* -------------------------------------------------------------------------- */
393 
394 int cholmod_write_sparse
395 (
396     /* ---- input ---- */
397     FILE *f,		    /* file to write to, must already be open */
398     cholmod_sparse *A,	    /* matrix to print */
399     cholmod_sparse *Z,	    /* optional matrix with pattern of explicit zeros */
400     const char *comments,    /* optional filename of comments to include */
401     /* --------------- */
402     cholmod_common *Common
403 ) ;
404 
405 int cholmod_l_write_sparse (FILE *, cholmod_sparse *, cholmod_sparse *,
406     const char *c, cholmod_common *) ;
407 
408 /* -------------------------------------------------------------------------- */
409 /* cholmod_write_dense: write a dense matrix to a file */
410 /* -------------------------------------------------------------------------- */
411 
412 int cholmod_write_dense
413 (
414     /* ---- input ---- */
415     FILE *f,		    /* file to write to, must already be open */
416     cholmod_dense *X,	    /* matrix to print */
417     const char *comments,    /* optional filename of comments to include */
418     /* --------------- */
419     cholmod_common *Common
420 ) ;
421 
422 int cholmod_l_write_dense (FILE *, cholmod_dense *, const char *,
423     cholmod_common *) ;
424 #endif
425