Amesos Package Browser (Single Doxygen Collection)
Development
src
SuiteSparse
CAMD
Include
amesos_camd_internal.h
Go to the documentation of this file.
1
/* ========================================================================= */
2
/* === camd_internal.h ===================================================== */
3
/* ========================================================================= */
4
5
/* ------------------------------------------------------------------------- */
6
/* CAMD, Copyright (c) Timothy A. Davis, Yanqing Chen, */
7
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
9
/* web: http://www.cise.ufl.edu/research/sparse/camd */
10
/* ------------------------------------------------------------------------- */
11
12
/* This file is for internal use in CAMD itself, and does not normally need to
13
* be included in user code (it is included in UMFPACK, however). All others
14
* should use camd.h instead.
15
*
16
* The following compile-time definitions affect how CAMD is compiled.
17
*
18
* -DNPRINT
19
*
20
* Disable all printing. stdio.h will not be included. Printing can
21
* be re-enabled at run-time by setting the global pointer camd_printf
22
* to printf (or mexPrintf for a MATLAB mexFunction).
23
*
24
* -DNMALLOC
25
*
26
* No memory manager is defined at compile-time. You MUST define the
27
* function pointers camd_malloc, camd_free, camd_realloc, and
28
* camd_calloc at run-time for CAMD to work properly.
29
*/
30
31
/* ========================================================================= */
32
/* === NDEBUG ============================================================== */
33
/* ========================================================================= */
34
35
/*
36
* Turning on debugging takes some work (see below). If you do not edit this
37
* file, then debugging is always turned off, regardless of whether or not
38
* -DNDEBUG is specified in your compiler options.
39
*
40
* If CAMD is being compiled as a mexFunction, then MATLAB_MEX_FILE is defined,
41
* and mxAssert is used instead of assert. If debugging is not enabled, no
42
* MATLAB include files or functions are used. Thus, the CAMD library libcamd.a
43
* can be safely used in either a stand-alone C program or in another
44
* mexFunction, without any change.
45
*/
46
47
/*
48
CAMD will be exceedingly slow when running in debug mode. The next three
49
lines ensure that debugging is turned off.
50
*/
51
#ifndef NDEBUG
52
#define NDEBUG
53
#endif
54
55
/*
56
To enable debugging, uncomment the following line:
57
#undef NDEBUG
58
*/
59
60
61
/* ------------------------------------------------------------------------- */
62
/* ANSI include files */
63
/* ------------------------------------------------------------------------- */
64
65
/* from stdlib.h: size_t, malloc, free, realloc, and calloc */
66
#include <stdlib.h>
67
68
#if !defined(NPRINT) || !defined(NDEBUG)
69
/* from stdio.h: printf. Not included if NPRINT is defined at compile time.
70
* fopen and fscanf are used when debugging. */
71
#include <stdio.h>
72
#endif
73
74
/* from limits.h: INT_MAX and LONG_MAX */
75
#include <limits.h>
76
77
/* from math.h: sqrt */
78
#include <math.h>
79
80
/* ------------------------------------------------------------------------- */
81
/* MATLAB include files (only if being used in or via MATLAB) */
82
/* ------------------------------------------------------------------------- */
83
84
#ifdef MATLAB_MEX_FILE
85
#include "matrix.h"
86
#include "mex.h"
87
#endif
88
89
/* ------------------------------------------------------------------------- */
90
/* basic definitions */
91
/* ------------------------------------------------------------------------- */
92
93
#ifdef FLIP
94
#undef FLIP
95
#endif
96
97
#ifdef MAX
98
#undef MAX
99
#endif
100
101
#ifdef MIN
102
#undef MIN
103
#endif
104
105
#ifdef EMPTY
106
#undef EMPTY
107
#endif
108
109
#ifdef GLOBAL
110
#undef GLOBAL
111
#endif
112
113
#ifdef PRIVATE
114
#undef PRIVATE
115
#endif
116
117
/* FLIP is a "negation about -1", and is used to mark an integer i that is
118
* normally non-negative. FLIP (EMPTY) is EMPTY. FLIP of a number > EMPTY
119
* is negative, and FLIP of a number < EMTPY is positive. FLIP (FLIP (i)) = i
120
* for all integers i. UNFLIP (i) is >= EMPTY. */
121
#define EMPTY (-1)
122
#define FLIP(i) (-(i)-2)
123
#define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i))
124
125
/* for integer MAX/MIN, or for doubles when we don't care how NaN's behave: */
126
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
127
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
128
129
/* logical expression of p implies q: */
130
#define IMPLIES(p,q) (!(p) || (q))
131
132
/* Note that the IBM RS 6000 xlc predefines TRUE and FALSE in <types.h>. */
133
/* The Compaq Alpha also predefines TRUE and FALSE. */
134
#ifdef TRUE
135
#undef TRUE
136
#endif
137
#ifdef FALSE
138
#undef FALSE
139
#endif
140
141
#define TRUE (1)
142
#define FALSE (0)
143
#define PRIVATE static
144
#define GLOBAL
145
#define EMPTY (-1)
146
147
/* Note that Linux's gcc 2.96 defines NULL as ((void *) 0), but other */
148
/* compilers (even gcc 2.95.2 on Solaris) define NULL as 0 or (0). We */
149
/* need to use the ANSI standard value of 0. */
150
#ifdef NULL
151
#undef NULL
152
#endif
153
154
#define NULL 0
155
156
/* largest value of size_t */
157
#ifndef SIZE_T_MAX
158
#define SIZE_T_MAX ((size_t) (-1))
159
#endif
160
161
/* ------------------------------------------------------------------------- */
162
/* integer type for CAMD: int or UF_long */
163
/* ------------------------------------------------------------------------- */
164
165
/* define UF_long */
166
#include "
amesos_UFconfig.h
"
167
168
#if defined (DLONG) || defined (ZLONG)
169
170
#define Int UF_long
171
#define ID UF_long_id
172
#define Int_MAX UF_long_max
173
174
#define CAMD_order amesos_camd_l_order
175
#define CAMD_defaults amesos_camd_l_defaults
176
#define CAMD_control amesos_camd_l_control
177
#define CAMD_info amesos_camd_l_info
178
#define CAMD_1 amesos_camd_l1
179
#define CAMD_2 amesos_camd_l2
180
#define CAMD_valid amesos_camd_l_valid
181
#define CAMD_cvalid amesos_camd_l_cvalid
182
#define CAMD_aat amesos_camd_l_aat
183
#define CAMD_postorder amesos_camd_l_postorder
184
#define CAMD_post_tree amesos_camd_l_post_tree
185
#define CAMD_dump amesos_camd_l_dump
186
#define CAMD_debug amesos_camd_l_debug
187
#define CAMD_debug_init amesos_camd_l_debug_init
188
#define CAMD_preprocess amesos_camd_l_preprocess
189
190
#else
191
192
#define Int int
193
#define ID "%d"
194
#define Int_MAX INT_MAX
195
196
#define CAMD_order amesos_camd_order
197
#define CAMD_defaults amesos_camd_defaults
198
#define CAMD_control amesos_camd_control
199
#define CAMD_info amesos_camd_info
200
#define CAMD_1 amesos_camd_1
201
#define CAMD_2 amesos_camd_2
202
#define CAMD_valid amesos_camd_valid
203
#define CAMD_cvalid amesos_camd_cvalid
204
#define CAMD_aat amesos_camd_aat
205
#define CAMD_postorder amesos_camd_postorder
206
#define CAMD_post_tree amesos_camd_post_tree
207
#define CAMD_dump amesos_camd_dump
208
#define CAMD_debug amesos_camd_debug
209
#define CAMD_debug_init amesos_camd_debug_init
210
#define CAMD_preprocess amesos_camd_preprocess
211
212
#endif
213
214
/* ========================================================================= */
215
/* === PRINTF macro ======================================================== */
216
/* ========================================================================= */
217
218
/* All output goes through the PRINTF macro. */
219
#define PRINTF(params) { if (amesos_camd_printf != NULL) (void) amesos_camd_printf params ; }
220
221
/* ------------------------------------------------------------------------- */
222
/* CAMD routine definitions (user-callable) */
223
/* ------------------------------------------------------------------------- */
224
225
#include "
amesos_camd.h
"
226
227
/* ------------------------------------------------------------------------- */
228
/* CAMD routine definitions (not user-callable) */
229
/* ------------------------------------------------------------------------- */
230
231
GLOBAL
size_t
CAMD_aat
232
(
233
Int
n,
234
const
Int
Ap [ ],
235
const
Int
Ai [ ],
236
Int
Len [ ],
237
Int
Tp [ ],
238
double
Info [ ]
239
) ;
240
241
GLOBAL
void
CAMD_1
242
(
243
Int
n,
244
const
Int
Ap [ ],
245
const
Int
Ai [ ],
246
Int
P
[ ],
247
Int
Pinv [ ],
248
Int
Len [ ],
249
Int
slen,
250
Int
S [ ],
251
double
Control [ ],
252
double
Info [ ],
253
const
Int
C
[ ]
254
) ;
255
256
GLOBAL
Int
CAMD_postorder
257
(
258
Int
j,
Int
k,
Int
n,
Int
head [],
Int
next [],
Int
post [],
Int
stack []
259
) ;
260
261
GLOBAL
void
CAMD_preprocess
262
(
263
Int
n,
264
const
Int
Ap [ ],
265
const
Int
Ai [ ],
266
Int
Rp [ ],
267
Int
Ri [ ],
268
Int
W [ ],
269
Int
Flag [ ]
270
) ;
271
272
/* ------------------------------------------------------------------------- */
273
/* debugging definitions */
274
/* ------------------------------------------------------------------------- */
275
276
#ifndef NDEBUG
277
278
/* from assert.h: assert macro */
279
#include <assert.h>
280
281
#ifndef EXTERN
282
#define EXTERN extern
283
#endif
284
285
EXTERN
Int
CAMD_debug
;
286
287
GLOBAL
void
CAMD_debug_init
(
char
*s ) ;
288
289
GLOBAL
void
CAMD_dump
290
(
291
Int
n,
292
Int
Pe [ ],
293
Int
Iw [ ],
294
Int
Len [ ],
295
Int
iwlen,
296
Int
pfree,
297
Int
Nv [ ],
298
Int
Next [ ],
299
Int
Last [ ],
300
Int
Head [ ],
301
Int
Elen [ ],
302
Int
Degree [ ],
303
Int
W [ ],
304
Int
nel,
305
Int
BucketSet [],
306
const
Int
C
[],
307
Int
Curc
308
) ;
309
310
#ifdef ASSERT
311
#undef ASSERT
312
#endif
313
314
/* Use mxAssert if CAMD is compiled into a mexFunction */
315
#ifdef MATLAB_MEX_FILE
316
#define ASSERT(expression) (mxAssert ((expression), ""))
317
#else
318
#define ASSERT(expression) (assert (expression))
319
#endif
320
321
#define CAMD_DEBUG0(params) { PRINTF (params) ; }
322
#define CAMD_DEBUG1(params) { if (CAMD_debug >= 1) PRINTF (params) ; }
323
#define CAMD_DEBUG2(params) { if (CAMD_debug >= 2) PRINTF (params) ; }
324
#define CAMD_DEBUG3(params) { if (CAMD_debug >= 3) PRINTF (params) ; }
325
#define CAMD_DEBUG4(params) { if (CAMD_debug >= 4) PRINTF (params) ; }
326
327
#else
328
329
/* no debugging */
330
#define ASSERT(expression)
331
#define CAMD_DEBUG0(params)
332
#define CAMD_DEBUG1(params)
333
#define CAMD_DEBUG2(params)
334
#define CAMD_DEBUG3(params)
335
#define CAMD_DEBUG4(params)
336
337
#endif
CAMD_dump
#define CAMD_dump
Definition:
amesos_camd_internal.h:207
GLOBAL
#define GLOBAL
Definition:
amesos_camd_internal.h:144
CAMD_postorder
#define CAMD_postorder
Definition:
amesos_camd_internal.h:205
CAMD_debug
#define CAMD_debug
Definition:
amesos_camd_internal.h:208
CAMD_aat
#define CAMD_aat
Definition:
amesos_camd_internal.h:204
CAMD_1
#define CAMD_1
Definition:
amesos_camd_internal.h:200
CAMD_debug_init
#define CAMD_debug_init
Definition:
amesos_camd_internal.h:209
P
#define P(k)
Definition:
amesos_cholmod_solve.c:76
EXTERN
#define EXTERN
Definition:
amesos_amd.h:315
amesos_UFconfig.h
C
CAMD_preprocess
#define CAMD_preprocess
Definition:
amesos_camd_internal.h:210
Int
#define Int
Definition:
amesos_camd_internal.h:192
amesos_camd.h
Generated by
1.8.14