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         See COLAMD/Doc/License.txt for the license.
26 
27     Availability:
28 
29 	The colamd/symamd library is available at http://www.suitesparse.com
30 	This file is required by the colamd.c, colamdmex.c, and symamdmex.c
31 	files, and by any C code that calls the routines whose prototypes are
32 	listed below, or that uses the colamd/symamd definitions listed below.
33 
34 */
35 
36 #ifndef COLAMD_H
37 #define COLAMD_H
38 
39 /* make it easy for C++ programs to include COLAMD */
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* ========================================================================== */
45 /* === Include files ======================================================== */
46 /* ========================================================================== */
47 
48 #include <stdlib.h>
49 
50 /* ========================================================================== */
51 /* === COLAMD version ======================================================= */
52 /* ========================================================================== */
53 
54 /* COLAMD Version 2.4 and later will include the following definitions.
55  * As an example, to test if the version you are using is 2.4 or later:
56  *
57  * #ifdef COLAMD_VERSION
58  *	if (COLAMD_VERSION >= COLAMD_VERSION_CODE (2,4)) ...
59  * #endif
60  *
61  * This also works during compile-time:
62  *
63  *  #if defined(COLAMD_VERSION) && (COLAMD_VERSION >= COLAMD_VERSION_CODE (2,4))
64  *    printf ("This is version 2.4 or later\n") ;
65  *  #else
66  *    printf ("This is an early version\n") ;
67  *  #endif
68  *
69  * Versions 2.3 and earlier of COLAMD do not include a #define'd version number.
70  */
71 
72 #define COLAMD_DATE "May 4, 2016"
73 #define COLAMD_VERSION_CODE(main,sub) ((main) * 1000 + (sub))
74 #define COLAMD_MAIN_VERSION 2
75 #define COLAMD_SUB_VERSION 9
76 #define COLAMD_SUBSUB_VERSION 6
77 #define COLAMD_VERSION \
78 	COLAMD_VERSION_CODE(COLAMD_MAIN_VERSION,COLAMD_SUB_VERSION)
79 
80 /* ========================================================================== */
81 /* === Knob and statistics definitions ====================================== */
82 /* ========================================================================== */
83 
84 /* size of the knobs [ ] array.  Only knobs [0..1] are currently used. */
85 #define COLAMD_KNOBS 20
86 
87 /* number of output statistics.  Only stats [0..6] are currently used. */
88 #define COLAMD_STATS 20
89 
90 /* knobs [0] and stats [0]: dense row knob and output statistic. */
91 #define COLAMD_DENSE_ROW 0
92 
93 /* knobs [1] and stats [1]: dense column knob and output statistic. */
94 #define COLAMD_DENSE_COL 1
95 
96 /* knobs [2]: aggressive absorption */
97 #define COLAMD_AGGRESSIVE 2
98 
99 /* stats [2]: memory defragmentation count output statistic */
100 #define COLAMD_DEFRAG_COUNT 2
101 
102 /* stats [3]: colamd status:  zero OK, > 0 warning or notice, < 0 error */
103 #define COLAMD_STATUS 3
104 
105 /* stats [4..6]: error info, or info on jumbled columns */
106 #define COLAMD_INFO1 4
107 #define COLAMD_INFO2 5
108 #define COLAMD_INFO3 6
109 
110 /* error codes returned in stats [3]: */
111 #define COLAMD_OK				(0)
112 #define COLAMD_OK_BUT_JUMBLED			(1)
113 #define COLAMD_ERROR_A_not_present		(-1)
114 #define COLAMD_ERROR_p_not_present		(-2)
115 #define COLAMD_ERROR_nrow_negative		(-3)
116 #define COLAMD_ERROR_ncol_negative		(-4)
117 #define COLAMD_ERROR_nnz_negative		(-5)
118 #define COLAMD_ERROR_p0_nonzero			(-6)
119 #define COLAMD_ERROR_A_too_small		(-7)
120 #define COLAMD_ERROR_col_length_negative	(-8)
121 #define COLAMD_ERROR_row_index_out_of_bounds	(-9)
122 #define COLAMD_ERROR_out_of_memory		(-10)
123 #define COLAMD_ERROR_internal_error		(-999)
124 
125 
126 /* ========================================================================== */
127 /* === Prototypes of user-callable routines ================================= */
128 /* ========================================================================== */
129 
130 #include "SuiteSparse_config.h"
131 
132 size_t colamd_recommended	/* returns recommended value of Alen, */
133 				/* or 0 if input arguments are erroneous */
134 (
135     int nnz,			/* nonzeros in A */
136     int n_row,			/* number of rows in A */
137     int n_col			/* number of columns in A */
138 ) ;
139 
140 size_t colamd_l_recommended	/* returns recommended value of Alen, */
141 				/* or 0 if input arguments are erroneous */
142 (
143     SuiteSparse_long nnz,       /* nonzeros in A */
144     SuiteSparse_long n_row,     /* number of rows in A */
145     SuiteSparse_long n_col      /* number of columns in A */
146 ) ;
147 
148 void colamd_set_defaults	/* sets default parameters */
149 (				/* knobs argument is modified on output */
150     double knobs [COLAMD_KNOBS]	/* parameter settings for colamd */
151 ) ;
152 
153 void colamd_l_set_defaults	/* sets default parameters */
154 (				/* knobs argument is modified on output */
155     double knobs [COLAMD_KNOBS]	/* parameter settings for colamd */
156 ) ;
157 
158 int colamd			/* returns (1) if successful, (0) otherwise*/
159 (				/* A and p arguments are modified on output */
160     int n_row,			/* number of rows in A */
161     int n_col,			/* number of columns in A */
162     int Alen,			/* size of the array A */
163     int A [],			/* row indices of A, of size Alen */
164     int p [],			/* column pointers of A, of size n_col+1 */
165     double knobs [COLAMD_KNOBS],/* parameter settings for colamd */
166     int stats [COLAMD_STATS]	/* colamd output statistics and error codes */
167 ) ;
168 
169 SuiteSparse_long colamd_l       /* returns (1) if successful, (0) otherwise*/
170 (				/* A and p arguments are modified on output */
171     SuiteSparse_long n_row,     /* number of rows in A */
172     SuiteSparse_long n_col,     /* number of columns in A */
173     SuiteSparse_long Alen,      /* size of the array A */
174     SuiteSparse_long A [],      /* row indices of A, of size Alen */
175     SuiteSparse_long p [],      /* column pointers of A, of size n_col+1 */
176     double knobs [COLAMD_KNOBS],/* parameter settings for colamd */
177     SuiteSparse_long stats [COLAMD_STATS]   /* colamd output statistics
178                                              * and error codes */
179 ) ;
180 
181 int symamd				/* return (1) if OK, (0) otherwise */
182 (
183     int n,				/* number of rows and columns of A */
184     int A [],				/* row indices of A */
185     int p [],				/* column pointers of A */
186     int perm [],			/* output permutation, size n_col+1 */
187     double knobs [COLAMD_KNOBS],	/* parameters (uses defaults if NULL) */
188     int stats [COLAMD_STATS],		/* output statistics and error codes */
189     void * (*allocate) (size_t, size_t),
190     					/* pointer to calloc (ANSI C) or */
191 					/* mxCalloc (for MATLAB mexFunction) */
192     void (*release) (void *)
193     					/* pointer to free (ANSI C) or */
194     					/* mxFree (for MATLAB mexFunction) */
195 ) ;
196 
197 SuiteSparse_long symamd_l               /* return (1) if OK, (0) otherwise */
198 (
199     SuiteSparse_long n,                 /* number of rows and columns of A */
200     SuiteSparse_long A [],              /* row indices of A */
201     SuiteSparse_long p [],              /* column pointers of A */
202     SuiteSparse_long perm [],           /* output permutation, size n_col+1 */
203     double knobs [COLAMD_KNOBS],	/* parameters (uses defaults if NULL) */
204     SuiteSparse_long stats [COLAMD_STATS],  /* output stats and error codes */
205     void * (*allocate) (size_t, size_t),
206     					/* pointer to calloc (ANSI C) or */
207 					/* mxCalloc (for MATLAB mexFunction) */
208     void (*release) (void *)
209     					/* pointer to free (ANSI C) or */
210     					/* mxFree (for MATLAB mexFunction) */
211 ) ;
212 
213 void colamd_report
214 (
215     int stats [COLAMD_STATS]
216 ) ;
217 
218 void colamd_l_report
219 (
220     SuiteSparse_long stats [COLAMD_STATS]
221 ) ;
222 
223 void symamd_report
224 (
225     int stats [COLAMD_STATS]
226 ) ;
227 
228 void symamd_l_report
229 (
230     SuiteSparse_long stats [COLAMD_STATS]
231 ) ;
232 
233 #ifdef __cplusplus
234 }
235 #endif
236 
237 #endif /* COLAMD_H */
238