Amesos Package Browser (Single Doxygen Collection)
Development
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
SuiteSparse
AMD
Include
amesos_amd_internal.h
Go to the documentation of this file.
1
/* ========================================================================= */
2
/* === amesos_amd_internal.h ====================================================== */
3
/* ========================================================================= */
4
5
/* ------------------------------------------------------------------------- */
6
/* AMD, Copyright (c) Timothy A. Davis, */
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/amd */
10
/* ------------------------------------------------------------------------- */
11
12
/* This file is for internal use in AMD itself, and does not normally need to
13
* be included in user code (it is included in UMFPACK, however). All others
14
* should use amd.h instead.
15
*
16
* The following compile-time definitions affect how AMD 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 amesos_amd_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 amesos_amd_malloc, amesos_amd_free, amesos_amd_realloc, and
28
* amesos_amd_calloc at run-time for AMD 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 AMD 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 AMD library libamd.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
AMD 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
/* ANSI include files */
62
/* ------------------------------------------------------------------------- */
63
64
/* from stdlib.h: size_t, malloc, free, realloc, and calloc */
65
#include <stdlib.h>
66
67
#if !defined(NPRINT) || !defined(NDEBUG)
68
/* from stdio.h: printf. Not included if NPRINT is defined at compile time.
69
* fopen and fscanf are used when debugging. */
70
#include <stdio.h>
71
#endif
72
73
/* from limits.h: INT_MAX and LONG_MAX */
74
#include <limits.h>
75
76
/* from math.h: sqrt */
77
#include <math.h>
78
79
/* ------------------------------------------------------------------------- */
80
/* MATLAB include files (only if being used in or via MATLAB) */
81
/* ------------------------------------------------------------------------- */
82
83
#ifdef MATLAB_MEX_FILE
84
#include "matrix.h"
85
#include "mex.h"
86
#endif
87
88
/* ------------------------------------------------------------------------- */
89
/* basic definitions */
90
/* ------------------------------------------------------------------------- */
91
92
#ifdef FLIP
93
#undef FLIP
94
#endif
95
96
#ifdef MAX
97
#undef MAX
98
#endif
99
100
#ifdef MIN
101
#undef MIN
102
#endif
103
104
#ifdef EMPTY
105
#undef EMPTY
106
#endif
107
108
#ifdef GLOBAL
109
#undef GLOBAL
110
#endif
111
112
#ifdef PRIVATE
113
#undef PRIVATE
114
#endif
115
116
/* FLIP is a "negation about -1", and is used to mark an integer i that is
117
* normally non-negative. FLIP (EMPTY) is EMPTY. FLIP of a number > EMPTY
118
* is negative, and FLIP of a number < EMTPY is positive. FLIP (FLIP (i)) = i
119
* for all integers i. UNFLIP (i) is >= EMPTY. */
120
#define EMPTY (-1)
121
#define FLIP(i) (-(i)-2)
122
#define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i))
123
124
/* for integer MAX/MIN, or for doubles when we don't care how NaN's behave: */
125
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
126
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
127
128
/* logical expression of p implies q: */
129
#define IMPLIES(p,q) (!(p) || (q))
130
131
/* Note that the IBM RS 6000 xlc predefines TRUE and FALSE in <types.h>. */
132
/* The Compaq Alpha also predefines TRUE and FALSE. */
133
#ifdef TRUE
134
#undef TRUE
135
#endif
136
#ifdef FALSE
137
#undef FALSE
138
#endif
139
140
#define TRUE (1)
141
#define FALSE (0)
142
#define PRIVATE static
143
#define GLOBAL
144
#define EMPTY (-1)
145
146
/* Note that Linux's gcc 2.96 defines NULL as ((void *) 0), but other */
147
/* compilers (even gcc 2.95.2 on Solaris) define NULL as 0 or (0). We */
148
/* need to use the ANSI standard value of 0. */
149
#ifdef NULL
150
#undef NULL
151
#endif
152
153
#define NULL 0
154
155
/* largest value of size_t */
156
#ifndef SIZE_T_MAX
157
#define SIZE_T_MAX ((size_t) (-1))
158
#endif
159
160
/* ------------------------------------------------------------------------- */
161
/* integer type for AMD: int or UF_long */
162
/* ------------------------------------------------------------------------- */
163
164
/* define UF_long */
165
#include "
amesos_UFconfig.h
"
166
167
#if defined (DLONG) || defined (ZLONG)
168
169
#define Int UF_long
170
#define ID UF_long_id
171
#define Int_MAX UF_long_max
172
173
#define AMD_order amesos_amd_l_order
174
#define AMD_defaults amesos_amd_l_defaults
175
#define AMD_control amesos_amd_l_control
176
#define AMD_info amesos_amd_l_info
177
#define AMD_1 amesos_amd_l1
178
#define AMD_2 amesos_amd_l2
179
#define AMD_valid amesos_amd_l_valid
180
#define AMD_aat amesos_amd_l_aat
181
#define AMD_postorder amesos_amd_l_postorder
182
#define AMD_post_tree amesos_amd_l_post_tree
183
#define AMD_dump amesos_amd_l_dump
184
#define AMD_debug amesos_amd_l_debug
185
#define AMD_debug_init amesos_amd_l_debug_init
186
#define AMD_preprocess amesos_amd_l_preprocess
187
188
#else
189
190
#define Int int
191
#define ID "%d"
192
#define Int_MAX INT_MAX
193
194
#define AMD_order amesos_amd_order
195
#define AMD_defaults amesos_amd_defaults
196
#define AMD_control amesos_amd_control
197
#define AMD_info amesos_amd_info
198
#define AMD_1 amesos_amd_1
199
#define AMD_2 amesos_amd_2
200
#define AMD_valid amesos_amd_valid
201
#define AMD_aat amesos_amd_aat
202
#define AMD_postorder amesos_amd_postorder
203
#define AMD_post_tree amesos_amd_post_tree
204
#define AMD_dump amesos_amd_dump
205
#define AMD_debug amesos_amd_debug
206
#define AMD_debug_init amesos_amd_debug_init
207
#define AMD_preprocess amesos_amd_preprocess
208
209
#endif
210
211
/* ========================================================================= */
212
/* === PRINTF macro ======================================================== */
213
/* ========================================================================= */
214
215
/* All output goes through the PRINTF macro. */
216
#define PRINTF(params) { if (amesos_amd_printf != NULL) (void) amesos_amd_printf params ; }
217
218
/* ------------------------------------------------------------------------- */
219
/* AMD routine definitions (user-callable) */
220
/* ------------------------------------------------------------------------- */
221
222
#include "
amesos_amd.h
"
223
224
/* ------------------------------------------------------------------------- */
225
/* AMD routine definitions (not user-callable) */
226
/* ------------------------------------------------------------------------- */
227
228
GLOBAL
size_t
AMD_aat
229
(
230
Int
n,
231
const
Int
Ap [ ],
232
const
Int
Ai [ ],
233
Int
Len [ ],
234
Int
Tp [ ],
235
double
Info [ ]
236
) ;
237
238
GLOBAL
void
AMD_1
239
(
240
Int
n,
241
const
Int
Ap [ ],
242
const
Int
Ai [ ],
243
Int
P
[ ],
244
Int
Pinv [ ],
245
Int
Len [ ],
246
Int
slen,
247
Int
S [ ],
248
double
Control [ ],
249
double
Info [ ]
250
) ;
251
252
GLOBAL
void
AMD_postorder
253
(
254
Int
nn,
255
Int
Parent [ ],
256
Int
Npiv [ ],
257
Int
Fsize [ ],
258
Int
Order [ ],
259
Int
Child [ ],
260
Int
Sibling [ ],
261
Int
Stack [ ]
262
) ;
263
264
GLOBAL
Int
AMD_post_tree
265
(
266
Int
root,
267
Int
k,
268
Int
Child [ ],
269
const
Int
Sibling [ ],
270
Int
Order [ ],
271
Int
Stack [ ]
272
#ifndef
NDEBUG
273
,
Int
nn
274
#endif
275
) ;
276
277
GLOBAL
void
AMD_preprocess
278
(
279
Int
n,
280
const
Int
Ap [ ],
281
const
Int
Ai [ ],
282
Int
Rp [ ],
283
Int
Ri [ ],
284
Int
W [ ],
285
Int
Flag [ ]
286
) ;
287
288
/* ------------------------------------------------------------------------- */
289
/* debugging definitions */
290
/* ------------------------------------------------------------------------- */
291
292
#ifndef NDEBUG
293
294
/* from assert.h: assert macro */
295
#include <assert.h>
296
297
#ifndef EXTERN
298
#define EXTERN extern
299
#endif
300
301
EXTERN
Int
AMD_debug
;
302
303
GLOBAL
void
AMD_debug_init
(
char
*s ) ;
304
305
GLOBAL
void
AMD_dump
306
(
307
Int
n,
308
Int
Pe [ ],
309
Int
Iw [ ],
310
Int
Len [ ],
311
Int
iwlen,
312
Int
pfree,
313
Int
Nv [ ],
314
Int
Next [ ],
315
Int
Last [ ],
316
Int
Head [ ],
317
Int
Elen [ ],
318
Int
Degree [ ],
319
Int
W [ ],
320
Int
nel
321
) ;
322
323
#ifdef ASSERT
324
#undef ASSERT
325
#endif
326
327
/* Use mxAssert if AMD is compiled into a mexFunction */
328
#ifdef MATLAB_MEX_FILE
329
#define ASSERT(expression) (mxAssert ((expression), ""))
330
#else
331
#define ASSERT(expression) (assert (expression))
332
#endif
333
334
#define AMD_DEBUG0(params) { PRINTF (params) ; }
335
#define AMD_DEBUG1(params) { if (AMD_debug >= 1) PRINTF (params) ; }
336
#define AMD_DEBUG2(params) { if (AMD_debug >= 2) PRINTF (params) ; }
337
#define AMD_DEBUG3(params) { if (AMD_debug >= 3) PRINTF (params) ; }
338
#define AMD_DEBUG4(params) { if (AMD_debug >= 4) PRINTF (params) ; }
339
340
#else
341
342
/* no debugging */
343
#define ASSERT(expression)
344
#define AMD_DEBUG0(params)
345
#define AMD_DEBUG1(params)
346
#define AMD_DEBUG2(params)
347
#define AMD_DEBUG3(params)
348
#define AMD_DEBUG4(params)
349
350
#endif
AMD_1
#define AMD_1
Definition:
amesos_amd_internal.h:198
GLOBAL
#define GLOBAL
Definition:
amesos_amd_internal.h:143
Int
#define Int
Definition:
amesos_amd_internal.h:190
P
#define P(k)
Definition:
amesos_cholmod_solve.c:76
EXTERN
#define EXTERN
Definition:
amesos_amd.h:315
amesos_amd.h
AMD_debug
#define AMD_debug
Definition:
amesos_amd_internal.h:205
AMD_dump
#define AMD_dump
Definition:
amesos_amd_internal.h:204
AMD_preprocess
#define AMD_preprocess
Definition:
amesos_amd_internal.h:207
NDEBUG
#define NDEBUG
Definition:
amesos_btf_internal.h:29
AMD_post_tree
#define AMD_post_tree
Definition:
amesos_amd_internal.h:203
amesos_UFconfig.h
AMD_aat
#define AMD_aat
Definition:
amesos_amd_internal.h:201
AMD_postorder
#define AMD_postorder
Definition:
amesos_amd_internal.h:202
AMD_debug_init
#define AMD_debug_init
Definition:
amesos_amd_internal.h:206
Generated on Wed Jan 11 2017 09:45:18 for Amesos Package Browser (Single Doxygen Collection) by
1.8.6