1 /* ========================================================================== */ 2 /* === SuiteSparse_config =================================================== */ 3 /* ========================================================================== */ 4 5 /* Configuration file for SuiteSparse: a Suite of Sparse matrix packages 6 * (AMD, COLAMD, CCOLAMD, CAMD, CHOLMOD, UMFPACK, CXSparse, and others). 7 * 8 * SuiteSparse_config.h provides the definition of the long integer. On most 9 * systems, a C program can be compiled in LP64 mode, in which long's and 10 * pointers are both 64-bits, and int's are 32-bits. Windows 64, however, uses 11 * the LLP64 model, in which int's and long's are 32-bits, and long long's and 12 * pointers are 64-bits. 13 * 14 * SuiteSparse packages that include long integer versions are 15 * intended for the LP64 mode. However, as a workaround for Windows 64 16 * (and perhaps other systems), the long integer can be redefined. 17 * 18 * If _WIN64 is defined, then the __int64 type is used instead of long. 19 * 20 * The long integer can also be defined at compile time. For example, this 21 * could be added to SuiteSparse_config.mk: 22 * 23 * CFLAGS = -O -D'SuiteSparse_long=long long' \ 24 * -D'SuiteSparse_long_max=9223372036854775801' -D'SuiteSparse_long_idd="lld"' 25 * 26 * This file defines SuiteSparse_long as either long (on all but _WIN64) or 27 * __int64 on Windows 64. The intent is that a SuiteSparse_long is always a 28 * 64-bit integer in a 64-bit code. ptrdiff_t might be a better choice than 29 * long; it is always the same size as a pointer. 30 * 31 * This file also defines the SUITESPARSE_VERSION and related definitions. 32 * 33 * Copyright (c) 2012, Timothy A. Davis. No licensing restrictions apply 34 * to this file or to the SuiteSparse_config directory. 35 * Author: Timothy A. Davis. 36 */ 37 38 #ifndef SUITESPARSE_CONFIG_H 39 #define SUITESPARSE_CONFIG_H 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 #include <limits.h> 46 #include <stdlib.h> 47 48 /* ========================================================================== */ 49 /* === SuiteSparse_long ===================================================== */ 50 /* ========================================================================== */ 51 52 #ifndef SuiteSparse_long 53 54 #ifdef _WIN64 55 56 #define SuiteSparse_long __int64 57 #define SuiteSparse_long_max _I64_MAX 58 #define SuiteSparse_long_idd "I64d" 59 60 #else 61 62 #define SuiteSparse_long long 63 #define SuiteSparse_long_max LONG_MAX 64 #define SuiteSparse_long_idd "ld" 65 66 #endif 67 #define SuiteSparse_long_id "%" SuiteSparse_long_idd 68 #endif 69 70 /* ========================================================================== */ 71 /* === SuiteSparse_config parameters and functions ========================== */ 72 /* ========================================================================== */ 73 74 /* SuiteSparse-wide parameters are placed in this struct. It is meant to be 75 an extern, globally-accessible struct. It is not meant to be updated 76 frequently by multiple threads. Rather, if an application needs to modify 77 SuiteSparse_config, it should do it once at the beginning of the application, 78 before multiple threads are launched. 79 80 The intent of these function pointers is that they not be used in your 81 application directly, except to assign them to the desired user-provided 82 functions. Rather, you should use the 83 */ 84 85 struct SuiteSparse_config_struct 86 { 87 void *(*malloc_func) (size_t) ; /* pointer to malloc */ 88 void *(*calloc_func) (size_t, size_t) ; /* pointer to calloc */ 89 void *(*realloc_func) (void *, size_t) ; /* pointer to realloc */ 90 void (*free_func) (void *) ; /* pointer to free */ 91 int (*printf_func) (const char *, ...) ; /* pointer to printf */ 92 double (*hypot_func) (double, double) ; /* pointer to hypot */ 93 int (*divcomplex_func) (double, double, double, double, double *, double *); 94 } ; 95 96 extern struct SuiteSparse_config_struct SuiteSparse_config ; 97 98 void SuiteSparse_start ( void ) ; /* called to start SuiteSparse */ 99 100 void SuiteSparse_finish ( void ) ; /* called to finish SuiteSparse */ 101 102 void *SuiteSparse_malloc /* pointer to allocated block of memory */ 103 ( 104 size_t nitems, /* number of items to malloc (>=1 is enforced) */ 105 size_t size_of_item /* sizeof each item */ 106 ) ; 107 108 void *SuiteSparse_calloc /* pointer to allocated block of memory */ 109 ( 110 size_t nitems, /* number of items to calloc (>=1 is enforced) */ 111 size_t size_of_item /* sizeof each item */ 112 ) ; 113 114 void *SuiteSparse_realloc /* pointer to reallocated block of memory, or 115 to original block if the realloc failed. */ 116 ( 117 size_t nitems_new, /* new number of items in the object */ 118 size_t nitems_old, /* old number of items in the object */ 119 size_t size_of_item, /* sizeof each item */ 120 void *p, /* old object to reallocate */ 121 int *ok /* 1 if successful, 0 otherwise */ 122 ) ; 123 124 void *SuiteSparse_free /* always returns NULL */ 125 ( 126 void *p /* block to free */ 127 ) ; 128 129 void SuiteSparse_tic /* start the timer */ 130 ( 131 double tic [2] /* output, contents undefined on input */ 132 ) ; 133 134 double SuiteSparse_toc /* return time in seconds since last tic */ 135 ( 136 double tic [2] /* input: from last call to SuiteSparse_tic */ 137 ) ; 138 139 double SuiteSparse_time /* returns current wall clock time in seconds */ 140 ( 141 void 142 ) ; 143 144 /* returns sqrt (x^2 + y^2), computed reliably */ 145 double SuiteSparse_hypot (double x, double y) ; 146 147 /* complex division of c = a/b */ 148 int SuiteSparse_divcomplex 149 ( 150 double ar, double ai, /* real and imaginary parts of a */ 151 double br, double bi, /* real and imaginary parts of b */ 152 double *cr, double *ci /* real and imaginary parts of c */ 153 ) ; 154 155 /* determine which timer to use, if any */ 156 #ifndef NTIMER 157 #ifdef _POSIX_C_SOURCE 158 #if _POSIX_C_SOURCE >= 199309L 159 #define SUITESPARSE_TIMER_ENABLED 160 #endif 161 #endif 162 #endif 163 164 /* SuiteSparse printf macro */ 165 #define SUITESPARSE_PRINTF(params) \ 166 { \ 167 if (SuiteSparse_config.printf_func != NULL) \ 168 { \ 169 (void) (SuiteSparse_config.printf_func) params ; \ 170 } \ 171 } 172 173 /* ========================================================================== */ 174 /* === SuiteSparse version ================================================== */ 175 /* ========================================================================== */ 176 177 /* SuiteSparse is not a package itself, but a collection of packages, some of 178 * which must be used together (UMFPACK requires AMD, CHOLMOD requires AMD, 179 * COLAMD, CAMD, and CCOLAMD, etc). A version number is provided here for the 180 * collection itself, which is also the version number of SuiteSparse_config. 181 */ 182 183 int SuiteSparse_version /* returns SUITESPARSE_VERSION */ 184 ( 185 /* output, not defined on input. Not used if NULL. Returns 186 the three version codes in version [0..2]: 187 version [0] is SUITESPARSE_MAIN_VERSION 188 version [1] is SUITESPARSE_SUB_VERSION 189 version [2] is SUITESPARSE_SUBSUB_VERSION 190 */ 191 int version [3] 192 ) ; 193 194 /* Versions prior to 4.2.0 do not have the above function. The following 195 code fragment will work with any version of SuiteSparse: 196 197 #ifdef SUITESPARSE_HAS_VERSION_FUNCTION 198 v = SuiteSparse_version (NULL) ; 199 #else 200 v = SUITESPARSE_VERSION ; 201 #endif 202 */ 203 #define SUITESPARSE_HAS_VERSION_FUNCTION 204 205 #define SUITESPARSE_DATE "May 17, 2021" 206 #define SUITESPARSE_VER_CODE(main,sub) ((main) * 1000 + (sub)) 207 #define SUITESPARSE_MAIN_VERSION 5 208 #define SUITESPARSE_SUB_VERSION 10 209 #define SUITESPARSE_SUBSUB_VERSION 1 210 #define SUITESPARSE_VERSION \ 211 SUITESPARSE_VER_CODE(SUITESPARSE_MAIN_VERSION,SUITESPARSE_SUB_VERSION) 212 213 #ifdef __cplusplus 214 } 215 #endif 216 #endif 217