SCM

SCM Repository

[matrix] Annotation of /pkg/Matrix/src/CHOLMOD/Include/cholmod_internal.h
ViewVC logotype

Annotation of /pkg/Matrix/src/CHOLMOD/Include/cholmod_internal.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1876 - (view) (download) (as text)
Original Path: pkg/src/CHOLMOD/Include/cholmod_internal.h

1 : bates 912 /* ========================================================================== */
2 :     /* === Include/cholmod_internal.h =========================================== */
3 :     /* ========================================================================== */
4 :    
5 :     /* -----------------------------------------------------------------------------
6 : bates 1876 * CHOLMOD/Include/cholmod_internal.h.
7 : bates 1515 * Copyright (C) 2005-2006, Univ. of Florida. Author: Timothy A. Davis
8 : bates 912 * CHOLMOD/Include/cholmod_internal.h is licensed under Version 2.1 of the GNU
9 :     * Lesser General Public License. See lesser.txt for a text of the license.
10 :     * CHOLMOD is also available under other licenses; contact authors for details.
11 :     * http://www.cise.ufl.edu/research/sparse
12 :     * -------------------------------------------------------------------------- */
13 :    
14 :     /* CHOLMOD internal include file.
15 :     *
16 :     * This file contains internal definitions for CHOLMOD, not meant to be included
17 :     * in user code. They define macros that are not prefixed with CHOLMOD_. This
18 :     * file can safely #include'd in user code if you want to make use of the
19 :     * macros defined here, and don't mind the possible name conflicts with your
20 :     * code, however.
21 :     *
22 :     * Required by all CHOLMOD routines. Not required by any user routine that
23 :     * uses CHOLMOMD. Unless debugging is enabled, this file does not require any
24 :     * CHOLMOD module (not even the Core module).
25 :     *
26 :     * If debugging is enabled, all CHOLMOD modules require the Check module.
27 :     * Enabling debugging requires that this file be editted. Debugging cannot be
28 :     * enabled with a compiler flag. This is because CHOLMOD is exceedingly slow
29 :     * when debugging is enabled. Debugging is meant for development of CHOLMOD
30 :     * itself, not by users of CHOLMOD.
31 :     */
32 :    
33 :     #ifndef CHOLMOD_INTERNAL_H
34 :     #define CHOLMOD_INTERNAL_H
35 :    
36 : bates 1876 /* ========================================================================== */
37 :     /* === large file I/O ======================================================= */
38 :     /* ========================================================================== */
39 :    
40 :     /* Definitions for large file I/O must come before any other #includes. If
41 :     * this causes problems (may not be portable to all platforms), then compile
42 :     * CHOLMOD with -DNLARGEFILE. You must do this for MATLAB 6.5 and earlier,
43 :     * for example. */
44 :    
45 :     #include "cholmod_io64.h"
46 :    
47 :     /* ========================================================================== */
48 :     /* === debugging and basic includes ========================================= */
49 :     /* ========================================================================== */
50 :    
51 : bates 912 /* turn off debugging */
52 :     #ifndef NDEBUG
53 :     #define NDEBUG
54 :     #endif
55 :    
56 :     /* Uncomment this line to enable debugging. CHOLMOD will be very slow.
57 :     #undef NDEBUG
58 :     */
59 :    
60 :     #if !defined(NPRINT) || !defined(NDEBUG)
61 :     #include <stdio.h>
62 :     #endif
63 :    
64 :     #include <stddef.h>
65 :     #include <math.h>
66 :     #include <limits.h>
67 :     #include <float.h>
68 :     #include <stdlib.h>
69 :    
70 :     /* ========================================================================== */
71 :     /* === basic definitions ==================================================== */
72 :     /* ========================================================================== */
73 :    
74 :     /* Some non-conforming compilers insist on defining TRUE and FALSE. */
75 :     #undef TRUE
76 :     #undef FALSE
77 :     #define TRUE 1
78 :     #define FALSE 0
79 :     #define BOOLEAN(x) ((x) ? TRUE : FALSE)
80 :    
81 :     /* NULL should already be defined, but ensure it is here. */
82 :     #ifndef NULL
83 :     #define NULL ((void *) 0)
84 :     #endif
85 :    
86 :     /* FLIP is a "negation about -1", and is used to mark an integer i that is
87 :     * normally non-negative. FLIP (EMPTY) is EMPTY. FLIP of a number > EMPTY
88 :     * is negative, and FLIP of a number < EMTPY is positive. FLIP (FLIP (i)) = i
89 :     * for all integers i. UNFLIP (i) is >= EMPTY. */
90 :     #define EMPTY (-1)
91 :     #define FLIP(i) (-(i)-2)
92 :     #define UNFLIP(i) (((i) < EMPTY) ? FLIP (i) : (i))
93 :    
94 :     /* MAX and MIN are not safe to use for NaN's */
95 :     #define MAX(a,b) (((a) > (b)) ? (a) : (b))
96 :     #define MAX3(a,b,c) (((a) > (b)) ? (MAX (a,c)) : (MAX (b,c)))
97 :     #define MAX4(a,b,c,d) (((a) > (b)) ? (MAX3 (a,c,d)) : (MAX3 (b,c,d)))
98 :     #define MIN(a,b) (((a) < (b)) ? (a) : (b))
99 :     #define IMPLIES(p,q) (!(p) || (q))
100 :    
101 :     /* find the sign: -1 if x < 0, 1 if x > 0, zero otherwise.
102 :     * Not safe for NaN's */
103 :     #define SIGN(x) (((x) < 0) ? (-1) : (((x) > 0) ? 1 : 0))
104 :    
105 :     /* round up an integer x to a multiple of s */
106 :     #define ROUNDUP(x,s) ((s) * (((x) + ((s) - 1)) / (s)))
107 :    
108 :     #define ERROR(status,msg) \
109 :     CHOLMOD(error) (status, __FILE__, __LINE__, msg, Common)
110 :    
111 :     /* Check a pointer and return if null. Set status to invalid, unless the
112 :     * status is already "out of memory" */
113 :     #define RETURN_IF_NULL(A,result) \
114 :     { \
115 :     if ((A) == NULL) \
116 :     { \
117 :     if (Common->status != CHOLMOD_OUT_OF_MEMORY) \
118 :     { \
119 :     ERROR (CHOLMOD_INVALID, "argument missing") ; \
120 :     } \
121 :     return (result) ; \
122 :     } \
123 :     }
124 :    
125 :     /* Return if Common is NULL or invalid */
126 :     #define RETURN_IF_NULL_COMMON(result) \
127 :     { \
128 :     if (Common == NULL) \
129 :     { \
130 :     return (result) ; \
131 :     } \
132 :     if (Common->itype != ITYPE || Common->dtype != DTYPE) \
133 :     { \
134 :     Common->status = CHOLMOD_INVALID ; \
135 :     return (result) ; \
136 :     } \
137 :     }
138 :    
139 :     #define IS_NAN(x) CHOLMOD_IS_NAN(x)
140 :     #define IS_ZERO(x) CHOLMOD_IS_ZERO(x)
141 :     #define IS_NONZERO(x) CHOLMOD_IS_NONZERO(x)
142 :     #define IS_LT_ZERO(x) CHOLMOD_IS_LT_ZERO(x)
143 :     #define IS_GT_ZERO(x) CHOLMOD_IS_GT_ZERO(x)
144 :     #define IS_LE_ZERO(x) CHOLMOD_IS_LE_ZERO(x)
145 :    
146 : bates 1876 /* 1e308 is a huge number that doesn't take many characters to print in a
147 :     * file, in CHOLMOD/Check/cholmod_read and _write. Numbers larger than this
148 :     * are interpretted as Inf, since sscanf doesn't read in Inf's properly.
149 :     * This assumes IEEE double precision arithmetic. DBL_MAX would be a little
150 :     * better, except that it takes too many digits to print in a file. */
151 :     #define HUGE_DOUBLE 1e308
152 :    
153 : bates 912 /* ========================================================================== */
154 : bates 1515 /* === int/UF_long and double/float definitions ============================= */
155 : bates 912 /* ========================================================================== */
156 :    
157 :     /* CHOLMOD is designed for 3 types of integer variables:
158 :     *
159 :     * (1) all integers are int
160 : bates 1515 * (2) most integers are int, some are UF_long
161 :     * (3) all integers are UF_long
162 : bates 912 *
163 :     * and two kinds of floating-point values:
164 :     *
165 :     * (1) double
166 :     * (2) float
167 :     *
168 :     * the complex types (ANSI-compatible complex, and MATLAB-compatable zomplex)
169 :     * are based on the double or float type, and are not selected here. They
170 :     * are typically selected via template routines.
171 :     *
172 :     * This gives 6 different modes in which CHOLMOD can be compiled (only the
173 :     * first two are currently supported):
174 :     *
175 : bates 1515 * DINT double, int prefix: cholmod_
176 :     * DLONG double, UF_long prefix: cholmod_l_
177 :     * DMIX double, mixed int/UF_long prefix: cholmod_m_
178 :     * SINT float, int prefix: cholmod_si_
179 :     * SLONG float, UF_long prefix: cholmod_sl_
180 :     * SMIX float, mixed int/log prefix: cholmod_sm_
181 : bates 912 *
182 :     * These are selected with compile time flags (-DDLONG, for example). If no
183 :     * flag is selected, the default is DINT.
184 :     *
185 :     * All six versions use the same include files. The user-visible include files
186 : bates 1515 * are completely independent of which int/UF_long/double/float version is being
187 : bates 912 * used. The integer / real types in all data structures (sparse, triplet,
188 :     * dense, common, and triplet) are defined at run-time, not compile-time, so
189 :     * there is only one "cholmod_sparse" data type. Void pointers are used inside
190 :     * that data structure to point to arrays of the proper type. Each data
191 :     * structure has an itype and dtype field which determines the kind of basic
192 :     * types used. These are defined in Include/cholmod_core.h.
193 :     *
194 : bates 1515 * FUTURE WORK: support all six types (float, and mixed int/UF_long)
195 :     *
196 :     * UF_long is normally defined as long. However, for WIN64 it is __int64.
197 :     * It can also be redefined for other platforms, by modifying UFconfig.h.
198 : bates 912 */
199 :    
200 : bates 1515 #include "UFconfig.h"
201 :    
202 : bates 912 /* -------------------------------------------------------------------------- */
203 : bates 1515 /* Size_max: the largest value of size_t */
204 : bates 912 /* -------------------------------------------------------------------------- */
205 :    
206 : bates 1515 #define Size_max ((size_t) (-1))
207 :    
208 :     /* routines for doing arithmetic on size_t, and checking for overflow */
209 :     size_t cholmod_add_size_t (size_t a, size_t b, int *ok) ;
210 :     size_t cholmod_mult_size_t (size_t a, size_t k, int *ok) ;
211 :     size_t cholmod_l_add_size_t (size_t a, size_t b, int *ok) ;
212 :     size_t cholmod_l_mult_size_t (size_t a, size_t k, int *ok) ;
213 :    
214 :     /* -------------------------------------------------------------------------- */
215 : bates 1876 /* double (also complex double), UF_long */
216 : bates 1515 /* -------------------------------------------------------------------------- */
217 :    
218 : bates 912 #ifdef DLONG
219 :     #define Real double
220 : bates 1515 #define Int UF_long
221 :     #define Int_max UF_long_max
222 : bates 912 #define CHOLMOD(name) cholmod_l_ ## name
223 :     #define LONG
224 :     #define DOUBLE
225 :     #define ITYPE CHOLMOD_LONG
226 :     #define DTYPE CHOLMOD_DOUBLE
227 : bates 1515 #define ID UF_long_id
228 : bates 912
229 :     /* -------------------------------------------------------------------------- */
230 : bates 1515 /* double, int/UF_long */
231 : bates 912 /* -------------------------------------------------------------------------- */
232 :    
233 :     #elif defined (DMIX)
234 : bates 1515 #error "mixed int/UF_long not yet supported"
235 : bates 912
236 :     /* -------------------------------------------------------------------------- */
237 :     /* single, int */
238 :     /* -------------------------------------------------------------------------- */
239 :    
240 :     #elif defined (SINT)
241 :     #error "single-precision not yet supported"
242 :    
243 :     /* -------------------------------------------------------------------------- */
244 : bates 1515 /* single, UF_long */
245 : bates 912 /* -------------------------------------------------------------------------- */
246 :    
247 :     #elif defined (SLONG)
248 :     #error "single-precision not yet supported"
249 :    
250 :     /* -------------------------------------------------------------------------- */
251 : bates 1515 /* single, int/UF_long */
252 : bates 912 /* -------------------------------------------------------------------------- */
253 :    
254 :     #elif defined (SMIX)
255 :     #error "single-precision not yet supported"
256 :    
257 :     /* -------------------------------------------------------------------------- */
258 : bates 1876 /* double (also complex double), int: this is the default */
259 : bates 912 /* -------------------------------------------------------------------------- */
260 :    
261 :     #else
262 :    
263 :     #ifndef DINT
264 :     #define DINT
265 :     #endif
266 :     #define INT
267 :     #define DOUBLE
268 :    
269 :     #define Real double
270 :     #define Int int
271 :     #define Int_max INT_MAX
272 :     #define CHOLMOD(name) cholmod_ ## name
273 :     #define ITYPE CHOLMOD_INT
274 :     #define DTYPE CHOLMOD_DOUBLE
275 :     #define ID "%d"
276 :    
277 :     #endif
278 :    
279 :    
280 :     /* ========================================================================== */
281 :     /* === real/complex arithmetic ============================================== */
282 :     /* ========================================================================== */
283 :    
284 :     #include "cholmod_complexity.h"
285 :    
286 :     /* ========================================================================== */
287 :     /* === Architecture and BLAS ================================================ */
288 :     /* ========================================================================== */
289 :    
290 :     #include "cholmod_blas.h"
291 :    
292 :     /* ========================================================================== */
293 :     /* === debugging definitions ================================================ */
294 :     /* ========================================================================== */
295 :    
296 :     #ifndef NDEBUG
297 :    
298 :     #include <assert.h>
299 :     #include "cholmod.h"
300 :    
301 :     /* The cholmod_dump routines are in the Check module. No CHOLMOD routine
302 :     * calls the cholmod_check_* or cholmod_print_* routines in the Check module,
303 :     * since they use Common workspace that may already be in use. Instead, they
304 :     * use the cholmod_dump_* routines defined there, which allocate their own
305 :     * workspace if they need it. */
306 :    
307 : bates 1515 #ifndef EXTERN
308 :     #define EXTERN extern
309 :     #endif
310 :    
311 : bates 912 /* double, int */
312 : bates 1515 EXTERN int cholmod_dump ;
313 :     EXTERN int cholmod_dump_malloc ;
314 :     UF_long cholmod_dump_sparse (cholmod_sparse *, char *, cholmod_common *) ;
315 : bates 912 int cholmod_dump_factor (cholmod_factor *, char *, cholmod_common *) ;
316 :     int cholmod_dump_triplet (cholmod_triplet *, char *, cholmod_common *) ;
317 :     int cholmod_dump_dense (cholmod_dense *, char *, cholmod_common *) ;
318 :     int cholmod_dump_subset (int *, size_t, size_t, char *, cholmod_common *) ;
319 :     int cholmod_dump_perm (int *, size_t, size_t, char *, cholmod_common *) ;
320 :     int cholmod_dump_parent (int *, size_t, char *, cholmod_common *) ;
321 :     void cholmod_dump_init (char *, cholmod_common *) ;
322 : bates 1515 int cholmod_dump_mem (char *, UF_long, cholmod_common *) ;
323 :     void cholmod_dump_real (char *, Real *, UF_long, UF_long, int, int,
324 : bates 912 cholmod_common *) ;
325 : bates 1515 void cholmod_dump_super (UF_long, int *, int *, int *, int *, double *, int,
326 : bates 912 cholmod_common *) ;
327 : bates 1515 int cholmod_dump_partition (UF_long, int *, int *, int *, int *, UF_long,
328 : bates 912 cholmod_common *) ;
329 : bates 1515 int cholmod_dump_work(int, int, UF_long, cholmod_common *) ;
330 : bates 912
331 : bates 1515 /* double, UF_long */
332 :     EXTERN int cholmod_l_dump ;
333 :     EXTERN int cholmod_l_dump_malloc ;
334 :     UF_long cholmod_l_dump_sparse (cholmod_sparse *, char *, cholmod_common *) ;
335 : bates 912 int cholmod_l_dump_factor (cholmod_factor *, char *, cholmod_common *) ;
336 :     int cholmod_l_dump_triplet (cholmod_triplet *, char *, cholmod_common *) ;
337 :     int cholmod_l_dump_dense (cholmod_dense *, char *, cholmod_common *) ;
338 : bates 1515 int cholmod_l_dump_subset (UF_long *, size_t, size_t, char *,
339 :     cholmod_common *) ;
340 :     int cholmod_l_dump_perm (UF_long *, size_t, size_t, char *, cholmod_common *) ;
341 :     int cholmod_l_dump_parent (UF_long *, size_t, char *, cholmod_common *) ;
342 : bates 912 void cholmod_l_dump_init (char *, cholmod_common *) ;
343 : bates 1515 int cholmod_l_dump_mem (char *, UF_long, cholmod_common *) ;
344 :     void cholmod_l_dump_real (char *, Real *, UF_long, UF_long, int, int,
345 : bates 912 cholmod_common *) ;
346 : bates 1515 void cholmod_l_dump_super (UF_long, UF_long *, UF_long *, UF_long *, UF_long *,
347 :     double *, int, cholmod_common *) ;
348 :     int cholmod_l_dump_partition (UF_long, UF_long *, UF_long *, UF_long *,
349 :     UF_long *, UF_long, cholmod_common *) ;
350 :     int cholmod_l_dump_work(int, int, UF_long, cholmod_common *) ;
351 : bates 912
352 :     #define DEBUG_INIT(s) { CHOLMOD(dump_init)(s, Common) ; }
353 :     #define ASSERT(expression) (assert (expression))
354 :    
355 :     #define PRK(k,params) \
356 :     { \
357 :     if (CHOLMOD(dump) >= (k) && Common->print_function != NULL) \
358 :     { \
359 : bates 1515 (Common->print_function) params ; \
360 : bates 912 } \
361 :     }
362 :    
363 :     #define PRINT0(params) PRK (0, params)
364 :     #define PRINT1(params) PRK (1, params)
365 :     #define PRINT2(params) PRK (2, params)
366 :     #define PRINT3(params) PRK (3, params)
367 :     #define PRINTM(params) PRK (CHOLMOD(dump_malloc), params)
368 :    
369 :     #define DEBUG(statement) statement
370 :    
371 :     #else
372 :    
373 :     /* Debugging disabled (the normal case) */
374 :     #define PRK(k,params)
375 :     #define DEBUG_INIT(s)
376 :     #define PRINT0(params)
377 :     #define PRINT1(params)
378 :     #define PRINT2(params)
379 :     #define PRINT3(params)
380 :     #define PRINTM(params)
381 :     #define ASSERT(expression)
382 :     #define DEBUG(statement)
383 :     #endif
384 :    
385 :     #endif

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge