1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
|
ENH: sparse/dsolve: re-apply patches on top of SuperLU 4.3
- Hook up USER_* routines to Scipy
- Fix a dubious format string
- Sprinkle volatile into dlamc/slamc implementation to avoid an infinite loop
- Eliminate a crash for singular matrices for which pivoting fails
- Do not exit(1) when ILU decomposition encounters singularity;
instead call ABORT (which is hooked up in Scipy)
- Add missing declarations of dlamch_ (call without declaration to
functions returning floating point can cause NaN to appear later on, on i386).
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cpivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cpivotL.c
index a14ea72..f60c4dc 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cpivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cpivotL.c
@@ -125,7 +125,16 @@ if ( jcol == MIN_COL ) {
/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 1
+#if SCIPY_FIX
+ if (pivptr < nsupr) {
+ *pivrow = lsub_ptr[pivptr];
+ }
+ else {
+ *pivrow = diagind;
+ }
+#else
*pivrow = lsub_ptr[pivptr];
+#endif
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c
index 678ac35..e117915 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c
@@ -673,9 +673,13 @@ double dlamc3_(double *a, double *b)
{
/* >>Start of File<<
System generated locals */
- double ret_val;
+ volatile double ret_val;
+ volatile double x;
+ volatile double y;
- ret_val = *a + *b;
+ x = *a;
+ y = *b;
+ ret_val = x + y;
return ret_val;
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dpivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dpivotL.c
index bcfa96d..6a66068 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dpivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dpivotL.c
@@ -124,7 +124,16 @@ if ( jcol == MIN_COL ) {
/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 1
+#if SCIPY_FIX
+ if (pivptr < nsupr) {
+ *pivrow = lsub_ptr[pivptr];
+ }
+ else {
+ *pivrow = diagind;
+ }
+#else
*pivrow = lsub_ptr[pivptr];
+#endif
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c
index b6b0328..5a7203d 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c
@@ -17,6 +17,9 @@ int num_drop_U;
#endif
extern void ccopy_(int *, complex [], int *, complex [], int *);
+#if SCIPY_FIX
+extern double dlamch_(char *);
+#endif
#if 0
static complex *A; /* used in _compare_ only */
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cpivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cpivotL.c
index d806485..98991d7 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cpivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cpivotL.c
@@ -136,9 +136,13 @@ ilu_cpivotL(
/* Test for singularity */
if (pivmax < 0.0) {
+#if SCIPY_FIX
+ ABORT("[0]: matrix is singular");
+#else
fprintf(stderr, "[0]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
if ( pivmax == 0.0 ) {
if (diag != EMPTY)
@@ -151,9 +155,13 @@ ilu_cpivotL(
for (icol = jcol; icol < n; icol++)
if (marker[swap[icol]] <= jcol) break;
if (icol >= n) {
+#if SCIPY_FIX
+ ABORT("[1]: matrix is singular");
+#else
fprintf(stderr, "[1]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
*pivrow = swap[icol];
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dpivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dpivotL.c
index 33c316d..0cbb21d 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dpivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dpivotL.c
@@ -134,9 +134,13 @@ ilu_dpivotL(
/* Test for singularity */
if (pivmax < 0.0) {
+#if SCIPY_FIX
+ ABORT("[0]: matrix is singular");
+#else
fprintf(stderr, "[0]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
if ( pivmax == 0.0 ) {
if (diag != EMPTY)
@@ -149,9 +153,13 @@ ilu_dpivotL(
for (icol = jcol; icol < n; icol++)
if (marker[swap[icol]] <= jcol) break;
if (icol >= n) {
+#if SCIPY_FIX
+ ABORT("[1]: matrix is singular");
+#else
fprintf(stderr, "[1]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
*pivrow = swap[icol];
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c
index 7e0e97c..b9fd387 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c
@@ -17,6 +17,9 @@ int num_drop_U;
#endif
extern void scopy_(int *, float [], int *, float [], int *);
+#if SCIPY_FIX
+extern double dlamch_(char *);
+#endif
#if 0
static float *A; /* used in _compare_ only */
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_spivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_spivotL.c
index 25b6b00..ff36657 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_spivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_spivotL.c
@@ -134,9 +134,13 @@ ilu_spivotL(
/* Test for singularity */
if (pivmax < 0.0) {
+#if SCIPY_FIX
+ ABORT("[0]: matrix is singular");
+#else
fprintf(stderr, "[0]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
if ( pivmax == 0.0 ) {
if (diag != EMPTY)
@@ -149,9 +153,13 @@ ilu_spivotL(
for (icol = jcol; icol < n; icol++)
if (marker[swap[icol]] <= jcol) break;
if (icol >= n) {
+#if SCIPY_FIX
+ ABORT("[1]: matrix is singular");
+#else
fprintf(stderr, "[1]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
*pivrow = swap[icol];
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zpivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zpivotL.c
index dafea2b..4ea86b1 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zpivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zpivotL.c
@@ -136,9 +136,13 @@ ilu_zpivotL(
/* Test for singularity */
if (pivmax < 0.0) {
+#if SCIPY_FIX
+ ABORT("[0]: matrix is singular");
+#else
fprintf(stderr, "[0]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
if ( pivmax == 0.0 ) {
if (diag != EMPTY)
@@ -151,9 +155,13 @@ ilu_zpivotL(
for (icol = jcol; icol < n; icol++)
if (marker[swap[icol]] <= jcol) break;
if (icol >= n) {
+#if SCIPY_FIX
+ ABORT("[1]: matrix is singular");
+#else
fprintf(stderr, "[1]: jcol=%d, SINGULAR!!!\n", jcol);
fflush(stderr);
exit(1);
+#endif
}
*pivrow = swap[icol];
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/scipy_slu_config.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/scipy_slu_config.h
new file mode 100644
index 0000000..5afc93b
--- /dev/null
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/scipy_slu_config.h
@@ -0,0 +1,36 @@
+#ifndef SCIPY_SLU_CONFIG_H
+#define SCIPY_SLU_CONFIG_H
+
+#include <stdlib.h>
+
+/*
+ * Support routines
+ */
+void superlu_python_module_abort(char *msg);
+void *superlu_python_module_malloc(size_t size);
+void superlu_python_module_free(void *ptr);
+
+#define USER_ABORT superlu_python_module_abort
+#define USER_MALLOC superlu_python_module_malloc
+#define USER_FREE superlu_python_module_free
+
+#define SCIPY_FIX 1
+
+/*
+ * Fortran configuration
+ */
+#if defined(NO_APPEND_FORTRAN)
+#if defined(UPPERCASE_FORTRAN)
+#define UpCase 1
+#else
+#define NoChange 1
+#endif
+#else
+#if defined(UPPERCASE_FORTRAN)
+#error Uppercase and trailing slash in Fortran names not supported
+#else
+#define Add_ 1
+#endif
+#endif
+
+#endif
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c
index ec3cd61..09cf6e2 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c
@@ -684,11 +684,13 @@ double slamc3_(float *a, float *b)
/* >>Start of File<<
System generated locals */
- float ret_val;
-
-
+ volatile float ret_val;
+ volatile float x;
+ volatile float y;
- ret_val = *a + *b;
+ x = *a;
+ y = *b;
+ ret_val = x + y;
return ret_val;
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_Cnames.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_Cnames.h
index 7bcd1bc..80b8aa1 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_Cnames.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_Cnames.h
@@ -19,6 +19,7 @@
#ifndef __SUPERLU_CNAMES /* allow multiple inclusions */
#define __SUPERLU_CNAMES
+#include "scipy_slu_config.h"
#define ADD_ 0
#define ADD__ 1
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h
index 30b5f9b..f41b4ca 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h
@@ -22,6 +22,8 @@
#include <assert.h>
#include "superlu_enum_consts.h"
+#include "scipy_slu_config.h"
+
/***********************************************************************
* Macros
***********************************************************************/
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/spivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/spivotL.c
index 2a6950c..a9f0de5 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/spivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/spivotL.c
@@ -124,7 +124,16 @@ if ( jcol == MIN_COL ) {
/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 1
+#if SCIPY_FIX
+ if (pivptr < nsupr) {
+ *pivrow = lsub_ptr[pivptr];
+ }
+ else {
+ *pivrow = diagind;
+ }
+#else
*pivrow = lsub_ptr[pivptr];
+#endif
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/util.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/util.c
index 858fbbc..4c19e77 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/util.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/util.c
@@ -29,7 +29,7 @@
void superlu_abort_and_exit(char* msg)
{
- fprintf(stderr, msg);
+ fprintf(stderr, "%s\n", msg);
exit (-1);
}
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zpivotL.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zpivotL.c
index ce4f513..e134896 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zpivotL.c
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zpivotL.c
@@ -125,7 +125,16 @@ if ( jcol == MIN_COL ) {
/* Test for singularity */
if ( pivmax == 0.0 ) {
#if 1
+#if SCIPY_FIX
+ if (pivptr < nsupr) {
+ *pivrow = lsub_ptr[pivptr];
+ }
+ else {
+ *pivrow = diagind;
+ }
+#else
*pivrow = lsub_ptr[pivptr];
+#endif
perm_r[*pivrow] = jcol;
#else
perm_r[diagind] = jcol;
|