1 /* ========================================================================== */ 2 /* === umf_config.h ========================================================= */ 3 /* ========================================================================== */ 4 5 /* -------------------------------------------------------------------------- */ 6 /* Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com. */ 7 /* All Rights Reserved. See ../Doc/License.txt for License. */ 8 /* -------------------------------------------------------------------------- */ 9 10 /* 11 This file controls the compile-time configuration of UMFPACK. Modify the 12 SuiteSparse_config/SuiteSparse_config.mk file and this file if necessary, 13 to control these options. The following flags may be given as options to 14 your C compiler (as in "cc -DNSUNPERF", for example). These flags are 15 normally placed in your UMFPACK_CONFIG string, defined in the 16 SuiteSparse_config/SuiteSparse_config.mk file. 17 18 All of these options, except for the timer, are for accessing the BLAS. 19 20 -DNSUNPERF 21 22 Applies only to Sun Solaris. If -DNSUNPERF is set, then the Sun 23 Performance Library BLAS will not be used. 24 25 The Sun Performance Library BLAS is used by default when compiling 26 the C-callable libumfpack.a library on Sun Solaris. 27 28 -DLONGBLAS 29 30 -DNRECIPROCAL 31 32 This option controls a tradeoff between speed and accuracy. Using 33 -DNRECIPROCAL can lead to more accurate results, but with perhaps 34 some cost in performance, particularly if floating-point division 35 is much more costly than floating-point multiplication. 36 37 This option determines the method used to scale the pivot column. 38 If set, or if the absolute value of the pivot is < 1e-12 (or is a 39 NaN), then the pivot column is divided by the pivot value. 40 Otherwise, the reciprocal of the pivot value is computed, and the 41 pivot column is multiplied by (1/pivot). Multiplying by the 42 reciprocal can be slightly less accurate than dividing by the 43 pivot, but it is often faster. See umf_scale.c. 44 45 This has a small effect on the performance of UMFPACK, at least on 46 a Pentium 4M. It may have a larger effect on other architectures 47 where floating-point division is much more costly than floating- 48 point multiplication. The RS 6000 is one such example. 49 50 By default, the method chosen is to multiply by the reciprocal 51 (sacrificing accuracy for speed), except when compiling UMFPACK 52 as a built-in routine in MATLAB, or when gcc is being used. 53 54 When MATHWORKS is defined, -DNRECIPROCAL is forced on, and the pivot 55 column is divided by the pivot value. The only way of using the 56 other method in this case is to edit this file. 57 58 If -DNRECIPROCAL is enabled, then the row scaling factors are always 59 applied by dividing each row by the scale factor, rather than 60 multiplying by the reciprocal. If -DNRECIPROCAL is not enabled 61 (the default case), then the scale factors are normally applied by 62 multiplying by the reciprocal. If, however, the smallest scale 63 factor is tiny, then the scale factors are applied via division. 64 65 -DNO_DIVIDE_BY_ZERO 66 67 If the pivot is zero, and this flag is set, then no divide-by-zero 68 occurs. 69 70 The following options are controlled by amd_internal.h: 71 72 -DMATLAB_MEX_FILE 73 74 This flag is turned on when compiling the umfpack mexFunction for 75 use in MATLAB. The -DNRECIPROCAL flag is forced on (more accurate, 76 slightly slower). The umfpack mexFunction always returns 77 L*U = P*(R\A)*Q. 78 79 -DMATHWORKS 80 81 This flag is turned on when compiling umfpack as a built-in routine 82 in MATLAB. The -DNRECIPROCAL flag is forced on. 83 84 -DNDEBUG 85 86 Debugging mode (if NDEBUG is not defined). The default, of course, 87 is no debugging. Turning on debugging takes some work (see below). 88 If you do not edit this file, then debugging is turned off anyway, 89 regardless of whether or not -DNDEBUG is specified in your compiler 90 options. 91 */ 92 93 /* ========================================================================== */ 94 /* === AMD configuration ==================================================== */ 95 /* ========================================================================== */ 96 97 #define PRINTF(params) SUITESPARSE_PRINTF(params) 98 99 /* ========================================================================== */ 100 /* === reciprocal option ==================================================== */ 101 /* ========================================================================== */ 102 103 /* Force the definition NRECIPROCAL when MATHWORKS or MATLAB_MEX_FILE 104 * are defined. Do not multiply by the reciprocal in those cases. */ 105 106 #ifndef NRECIPROCAL 107 #if defined (MATHWORKS) || defined (MATLAB_MEX_FILE) 108 #define NRECIPROCAL 109 #endif 110 #endif 111 112 /* ========================================================================== */ 113 /* === Microsoft Windows configuration ====================================== */ 114 /* ========================================================================== */ 115 116 #if defined (UMF_WINDOWS) || defined (UMF_MINGW) 117 /* Windows isn't Unix. Profound. */ 118 #define NPOSIX 119 #endif 120 121 /* ========================================================================== */ 122 /* === 0-based or 1-based printing ========================================== */ 123 /* ========================================================================== */ 124 125 #if defined (MATLAB_MEX_FILE) && defined (NDEBUG) 126 /* In MATLAB, matrices are 1-based to the user, but 0-based internally. */ 127 /* One is added to all row and column indices when printing matrices */ 128 /* for the MATLAB user. The +1 shift is turned off when debugging. */ 129 #define INDEX(i) ((i)+1) 130 #else 131 /* In ANSI C, matrices are 0-based and indices are reported as such. */ 132 /* This mode is also used for debug mode, and if MATHWORKS is defined rather */ 133 /* than MATLAB_MEX_FILE. */ 134 #define INDEX(i) (i) 135 #endif 136 137 138 /* ========================================================================== */ 139 /* === BLAS ================================================================= */ 140 /* ========================================================================== */ 141 142 #define BLAS_OK blas_ok 143 #include "cholmod_blas.h" 144 145 146 /* -------------------------------------------------------------------------- */ 147 /* DGEMM */ 148 /* -------------------------------------------------------------------------- */ 149 150 /* C = C - A*B', where: 151 * A is m-by-k with leading dimension ldac 152 * B is k-by-n with leading dimension ldb 153 * C is m-by-n with leading dimension ldac */ 154 #ifdef COMPLEX 155 #define BLAS_GEMM(m,n,k,A,B,ldb,C,ldac) \ 156 { \ 157 double alpha [2] = {-1,0}, beta [2] = {1,0} ; \ 158 BLAS_zgemm ("N", "T", m, n, k, alpha, (double *) A, ldac, \ 159 (double *) B, ldb, beta, (double *) C, ldac) ; \ 160 } 161 #else 162 #define BLAS_GEMM(m,n,k,A,B,ldb,C,ldac) \ 163 { \ 164 double alpha = -1, beta = 1 ; \ 165 BLAS_dgemm ("N", "T", m, n, k, &alpha, A, ldac, B, ldb, &beta, C, ldac) ; \ 166 } 167 #endif 168 169 170 /* -------------------------------------------------------------------------- */ 171 /* GER */ 172 /* -------------------------------------------------------------------------- */ 173 174 /* A = A - x*y', where: 175 * A is m-by-n with leading dimension d 176 x is a column vector with stride 1 177 y is a column vector with stride 1 */ 178 #ifdef COMPLEX 179 #define BLAS_GER(m,n,x,y,A,d) \ 180 { \ 181 double alpha [2] = {-1,0} ; \ 182 BLAS_zgeru (m, n, alpha, (double *) x, 1, (double *) y, 1, \ 183 (double *) A, d) ; \ 184 } 185 #else 186 #define BLAS_GER(m,n,x,y,A,d) \ 187 { \ 188 double alpha = -1 ; \ 189 BLAS_dger (m, n, &alpha, x, 1, y, 1, A, d) ; \ 190 } 191 #endif 192 193 194 /* -------------------------------------------------------------------------- */ 195 /* GEMV */ 196 /* -------------------------------------------------------------------------- */ 197 198 /* y = y - A*x, where A is m-by-n with leading dimension d, 199 x is a column vector with stride 1 200 y is a column vector with stride 1 */ 201 #ifdef COMPLEX 202 #define BLAS_GEMV(m,n,A,x,y,d) \ 203 { \ 204 double alpha [2] = {-1,0}, beta [2] = {1,0} ; \ 205 BLAS_zgemv ("N", m, n, alpha, (double *) A, d, (double *) x, 1, beta, \ 206 (double *) y, 1) ; \ 207 } 208 #else 209 #define BLAS_GEMV(m,n,A,x,y,d) \ 210 { \ 211 double alpha = -1, beta = 1 ; \ 212 BLAS_dgemv ("N", m, n, &alpha, A, d, x, 1, &beta, y, 1) ; \ 213 } 214 #endif 215 216 217 /* -------------------------------------------------------------------------- */ 218 /* TRSV */ 219 /* -------------------------------------------------------------------------- */ 220 221 /* solve Lx=b, where: 222 * B is a column vector (m-by-1) with leading dimension d 223 * A is m-by-m with leading dimension d */ 224 #ifdef COMPLEX 225 #define BLAS_TRSV(m,A,b,d) \ 226 { \ 227 BLAS_ztrsv ("L", "N", "U", m, (double *) A, d, (double *) b, 1) ; \ 228 } 229 #else 230 #define BLAS_TRSV(m,A,b,d) \ 231 { \ 232 BLAS_dtrsv ("L", "N", "U", m, A, d, b, 1) ; \ 233 } 234 #endif 235 236 237 /* -------------------------------------------------------------------------- */ 238 /* TRSM */ 239 /* -------------------------------------------------------------------------- */ 240 241 /* solve XL'=B where: 242 * B is m-by-n with leading dimension ldb 243 * A is n-by-n with leading dimension lda */ 244 #ifdef COMPLEX 245 #define BLAS_TRSM_RIGHT(m,n,A,lda,B,ldb) \ 246 { \ 247 double alpha [2] = {1,0} ; \ 248 BLAS_ztrsm ("R", "L", "T", "U", m, n, alpha, (double *) A, lda, \ 249 (double *) B, ldb) ; \ 250 } 251 #else 252 #define BLAS_TRSM_RIGHT(m,n,A,lda,B,ldb) \ 253 { \ 254 double alpha = 1 ; \ 255 BLAS_dtrsm ("R", "L", "T", "U", m, n, &alpha, A, lda, B, ldb) ; \ 256 } 257 #endif 258 259 260 /* -------------------------------------------------------------------------- */ 261 /* SCAL */ 262 /* -------------------------------------------------------------------------- */ 263 264 /* x = s*x, where x is a stride-1 vector of length n */ 265 #ifdef COMPLEX 266 #define BLAS_SCAL(n,s,x) \ 267 { \ 268 double alpha [2] ; \ 269 alpha [0] = REAL_COMPONENT (s) ; \ 270 alpha [1] = IMAG_COMPONENT (s) ; \ 271 BLAS_zscal (n, alpha, (double *) x, 1) ; \ 272 } 273 #else 274 #define BLAS_SCAL(n,s,x) \ 275 { \ 276 double alpha = REAL_COMPONENT (s) ; \ 277 BLAS_dscal (n, &alpha, (double *) x, 1) ; \ 278 } 279 #endif 280