1 /* ========================================================================== */
2 /* === colamd/symamd prototypes and definitions ============================= */
3 /* ========================================================================== */
4 
5 /* COLAMD / SYMAMD include file
6 
7     You must include this file (colamd.h) in any routine that uses colamd,
8     symamd, or the related macros and definitions.
9 
10     Authors:
11 
12 	The authors of the code itself are Stefan I. Larimore and Timothy A.
13 	Davis (DrTimothyAldenDavis@gmail.com).  The algorithm was
14 	developed in collaboration with John Gilbert, Xerox PARC, and Esmond
15 	Ng, Oak Ridge National Laboratory.
16 
17     Acknowledgements:
18 
19 	This work was supported by the National Science Foundation, under
20 	grants DMS-9504974 and DMS-9803599.
21 
22     Notice:
23 
24 	Copyright (c) 1998-2007, Timothy A. Davis, All Rights Reserved.
25 
26 	THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
27 	EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
28 
29 	Permission is hereby granted to use, copy, modify, and/or distribute
30 	this program, provided that the Copyright, this License, and the
31 	Availability of the original version is retained on all copies and made
32 	accessible to the end-user of any code or package that includes COLAMD
33 	or any modified version of COLAMD.
34 
35     Availability:
36 
37 	The colamd/symamd library is available at http://www.suitesparse.com
38 	This file is required by the colamd.c, colamdmex.c, and symamdmex.c
39 	files, and by any C code that calls the routines whose prototypes are
40 	listed below, or that uses the colamd/symamd definitions listed below.
41 
42 */
43 
44 #ifndef COLAMD_H
45 #define COLAMD_H
46 
47 /* make it easy for C++ programs to include COLAMD */
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /* ========================================================================== */
53 /* === Include files ======================================================== */
54 /* ========================================================================== */
55 
56 #include <stdlib.h>
57 
58 /* ========================================================================== */
59 /* === COLAMD version ======================================================= */
60 /* ========================================================================== */
61 
62 /* COLAMD Version 2.4 and later will include the following definitions.
63  * As an example, to test if the version you are using is 2.4 or later:
64  *
65  * #ifdef COLAMD_VERSION
66  *	if (COLAMD_VERSION >= COLAMD_VERSION_CODE (2,4)) ...
67  * #endif
68  *
69  * This also works during compile-time:
70  *
71  *  #if defined(COLAMD_VERSION) && (COLAMD_VERSION >= COLAMD_VERSION_CODE (2,4))
72  *    printf ("This is version 2.4 or later\n") ;
73  *  #else
74  *    printf ("This is an early version\n") ;
75  *  #endif
76  *
77  * Versions 2.3 and earlier of COLAMD do not include a #define'd version number.
78  */
79 
80 #define COLAMD_DATE "Feb 1, 2016"
81 #define COLAMD_VERSION_CODE(main,sub) ((main) * 1000 + (sub))
82 #define COLAMD_MAIN_VERSION 2
83 #define COLAMD_SUB_VERSION 9
84 #define COLAMD_SUBSUB_VERSION 4
85 #define COLAMD_VERSION \
86 	COLAMD_VERSION_CODE(COLAMD_MAIN_VERSION,COLAMD_SUB_VERSION)
87 
88 /* ========================================================================== */
89 /* === Knob and statistics definitions ====================================== */
90 /* ========================================================================== */
91 
92 /* size of the knobs [ ] array.  Only knobs [0..1] are currently used. */
93 #define COLAMD_KNOBS 20
94 
95 /* number of output statistics.  Only stats [0..6] are currently used. */
96 #define COLAMD_STATS 20
97 
98 /* knobs [0] and stats [0]: dense row knob and output statistic. */
99 #define COLAMD_DENSE_ROW 0
100 
101 /* knobs [1] and stats [1]: dense column knob and output statistic. */
102 #define COLAMD_DENSE_COL 1
103 
104 /* knobs [2]: aggressive absorption */
105 #define COLAMD_AGGRESSIVE 2
106 
107 /* stats [2]: memory defragmentation count output statistic */
108 #define COLAMD_DEFRAG_COUNT 2
109 
110 /* stats [3]: colamd status:  zero OK, > 0 warning or notice, < 0 error */
111 #define COLAMD_STATUS 3
112 
113 /* stats [4..6]: error info, or info on jumbled columns */
114 #define COLAMD_INFO1 4
115 #define COLAMD_INFO2 5
116 #define COLAMD_INFO3 6
117 
118 /* error codes returned in stats [3]: */
119 #define COLAMD_OK				(0)
120 #define COLAMD_OK_BUT_JUMBLED			(1)
121 #define COLAMD_ERROR_A_not_present		(-1)
122 #define COLAMD_ERROR_p_not_present		(-2)
123 #define COLAMD_ERROR_nrow_negative		(-3)
124 #define COLAMD_ERROR_ncol_negative		(-4)
125 #define COLAMD_ERROR_nnz_negative		(-5)
126 #define COLAMD_ERROR_p0_nonzero			(-6)
127 #define COLAMD_ERROR_A_too_small		(-7)
128 #define COLAMD_ERROR_col_length_negative	(-8)
129 #define COLAMD_ERROR_row_index_out_of_bounds	(-9)
130 #define COLAMD_ERROR_out_of_memory		(-10)
131 #define COLAMD_ERROR_internal_error		(-999)
132 
133 
134 /* ========================================================================== */
135 /* === Prototypes of user-callable routines ================================= */
136 /* ========================================================================== */
137 
138 #include "SuiteSparse_config.h"
139 
140 size_t colamd_recommended	/* returns recommended value of Alen, */
141 				/* or 0 if input arguments are erroneous */
142 (
143     int nnz,			/* nonzeros in A */
144     int n_row,			/* number of rows in A */
145     int n_col			/* number of columns in A */
146 ) ;
147 
148 size_t colamd_l_recommended	/* returns recommended value of Alen, */
149 				/* or 0 if input arguments are erroneous */
150 (
151     SuiteSparse_long nnz,       /* nonzeros in A */
152     SuiteSparse_long n_row,     /* number of rows in A */
153     SuiteSparse_long n_col      /* number of columns in A */
154 ) ;
155 
156 void colamd_set_defaults	/* sets default parameters */
157 (				/* knobs argument is modified on output */
158     double knobs [COLAMD_KNOBS]	/* parameter settings for colamd */
159 ) ;
160 
161 void colamd_l_set_defaults	/* sets default parameters */
162 (				/* knobs argument is modified on output */
163     double knobs [COLAMD_KNOBS]	/* parameter settings for colamd */
164 ) ;
165 
166 int colamd			/* returns (1) if successful, (0) otherwise*/
167 (				/* A and p arguments are modified on output */
168     int n_row,			/* number of rows in A */
169     int n_col,			/* number of columns in A */
170     int Alen,			/* size of the array A */
171     int A [],			/* row indices of A, of size Alen */
172     int p [],			/* column pointers of A, of size n_col+1 */
173     double knobs [COLAMD_KNOBS],/* parameter settings for colamd */
174     int stats [COLAMD_STATS]	/* colamd output statistics and error codes */
175 ) ;
176 
177 SuiteSparse_long colamd_l       /* returns (1) if successful, (0) otherwise*/
178 (				/* A and p arguments are modified on output */
179     SuiteSparse_long n_row,     /* number of rows in A */
180     SuiteSparse_long n_col,     /* number of columns in A */
181     SuiteSparse_long Alen,      /* size of the array A */
182     SuiteSparse_long A [],      /* row indices of A, of size Alen */
183     SuiteSparse_long p [],      /* column pointers of A, of size n_col+1 */
184     double knobs [COLAMD_KNOBS],/* parameter settings for colamd */
185     SuiteSparse_long stats [COLAMD_STATS]   /* colamd output statistics
186                                              * and error codes */
187 ) ;
188 
189 int symamd				/* return (1) if OK, (0) otherwise */
190 (
191     int n,				/* number of rows and columns of A */
192     int A [],				/* row indices of A */
193     int p [],				/* column pointers of A */
194     int perm [],			/* output permutation, size n_col+1 */
195     double knobs [COLAMD_KNOBS],	/* parameters (uses defaults if NULL) */
196     int stats [COLAMD_STATS],		/* output statistics and error codes */
197     void * (*allocate) (size_t, size_t),
198     					/* pointer to calloc (ANSI C) or */
199 					/* mxCalloc (for MATLAB mexFunction) */
200     void (*release) (void *)
201     					/* pointer to free (ANSI C) or */
202     					/* mxFree (for MATLAB mexFunction) */
203 ) ;
204 
205 SuiteSparse_long symamd_l               /* return (1) if OK, (0) otherwise */
206 (
207     SuiteSparse_long n,                 /* number of rows and columns of A */
208     SuiteSparse_long A [],              /* row indices of A */
209     SuiteSparse_long p [],              /* column pointers of A */
210     SuiteSparse_long perm [],           /* output permutation, size n_col+1 */
211     double knobs [COLAMD_KNOBS],	/* parameters (uses defaults if NULL) */
212     SuiteSparse_long stats [COLAMD_STATS],  /* output stats and error codes */
213     void * (*allocate) (size_t, size_t),
214     					/* pointer to calloc (ANSI C) or */
215 					/* mxCalloc (for MATLAB mexFunction) */
216     void (*release) (void *)
217     					/* pointer to free (ANSI C) or */
218     					/* mxFree (for MATLAB mexFunction) */
219 ) ;
220 
221 void colamd_report
222 (
223     int stats [COLAMD_STATS]
224 ) ;
225 
226 void colamd_l_report
227 (
228     SuiteSparse_long stats [COLAMD_STATS]
229 ) ;
230 
231 void symamd_report
232 (
233     int stats [COLAMD_STATS]
234 ) ;
235 
236 void symamd_l_report
237 (
238     SuiteSparse_long stats [COLAMD_STATS]
239 ) ;
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 
245 #endif /* COLAMD_H */
246