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 2654 - (view) (download) (as text)

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