-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscikits-umfpack.patch
More file actions
288 lines (262 loc) · 6.76 KB
/
Copy pathscikits-umfpack.patch
File metadata and controls
288 lines (262 loc) · 6.76 KB
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
diff -ruN ./scikit-umfpack3/pyproject.toml ./scikit-umfpack/pyproject.toml
--- ./scikit-umfpack3/pyproject.toml 2025-02-27 11:18:39
+++ ./scikit-umfpack/pyproject.toml 2025-02-27 11:20:33
@@ -2,7 +2,8 @@
build-backend = 'mesonpy'
requires = [
'meson-python',
- 'numpy<2.0.0',
+ 'numpy',
+ 'swig'
]
[project]
@@ -15,7 +16,7 @@
]
requires-python = ">=3.9"
dependencies = [
- "numpy<2.0.0",
+ "numpy",
"scipy",
]
readme = "README.rst"
diff -ruN ./scikit-umfpack3/scikits/umfpack/umfpack.i ./scikit-umfpack/scikits/umfpack/umfpack.i
--- ./scikit-umfpack3/scikits/umfpack/umfpack.i 2025-02-27 11:18:39
+++ ./scikit-umfpack/scikits/umfpack/umfpack.i 2025-02-27 11:24:19
@@ -19,25 +19,28 @@
#include <umfpack.h>
-%{
-#ifndef SuiteSparse_long
- #define SuiteSparse_long UF_long
-#endif
-%}
+typedef int64_t UF_long;
-typedef int64_t SuiteSparse_long;
-typedef SuiteSparse_long UF_long;
-
-/* Convert from Python --> C */
-%typemap(in) SuiteSparse_long {
- $1 = (SuiteSparse_long)PyInt_AsLong($input);
+/* Convert 32-bit integer from Python --> C */
+%typemap(in) int32_t {
+ $1 = (int32_t)PyLong_AsLong($input);
}
/* Convert from C --> Python */
-%typemap(out) SuiteSparse_long {
- $result = PyInt_FromLong((int)$1);
+%typemap(out) int32_t {
+ $result = PyLong_FromLong($1);
}
+/* Convert 64-bit integer from Python --> C */
+%typemap(in) int64_t {
+ $1 = (int64_t)PyLong_AsLongLong($input);
+}
+
+/* Convert 64-bit integer from C --> Python */
+%typemap(out) int64_t {
+ $result = PyLong_FromLongLong($1);
+}
+
%init %{
import_array();
%}
@@ -171,24 +174,18 @@
$result = helper_appendToTuple( $result, obj ); \
};
-ARRAY_IN( int, const int, INT )
-%apply const int *array {
- const int Ap [ ],
- const int Ai [ ]
+ARRAY_IN( int32_t, const int32_t, INT32 )
+%apply const int32_t *array {
+ const int32_t Ap [ ],
+ const int32_t Ai [ ]
};
-ARRAY_IN( long, const long, LONG )
-%apply const long *array {
- const long Ap [ ],
- const long Ai [ ]
+ARRAY_IN( int64_t, const int64_t, INT64 )
+%apply const int64_t *array {
+ const int64_t Ap [ ],
+ const int64_t Ai [ ]
};
-ARRAY_IN( SuiteSparse_long, const SuiteSparse_long, INT64 )
-%apply const SuiteSparse_long *array {
- const SuiteSparse_long Ap [ ],
- const SuiteSparse_long Ai [ ]
-};
-
ARRAY_IN( double, const double, DOUBLE )
%apply const double *array {
const double Ax [ ],
@@ -217,19 +214,17 @@
%include <umfpack.h>
-#if UMFPACK_MAIN_VERSION < 6
- %include <umfpack_solve.h>
- %include <umfpack_defaults.h>
- %include <umfpack_triplet_to_col.h>
- %include <umfpack_col_to_triplet.h>
- %include <umfpack_transpose.h>
- %include <umfpack_scale.h>
+%include <umfpack_solve.h>
+%include <umfpack_defaults.h>
+%include <umfpack_triplet_to_col.h>
+%include <umfpack_col_to_triplet.h>
+%include <umfpack_transpose.h>
+%include <umfpack_scale.h>
- %include <umfpack_report_symbolic.h>
- %include <umfpack_report_numeric.h>
- %include <umfpack_report_info.h>
- %include <umfpack_report_control.h>
-#endif
+%include <umfpack_report_symbolic.h>
+%include <umfpack_report_numeric.h>
+%include <umfpack_report_info.h>
+%include <umfpack_report_control.h>
/*
The order is important below!
@@ -241,10 +236,8 @@
void **Numeric
}
-#if UMFPACK_MAIN_VERSION < 6
- %include <umfpack_symbolic.h>
- %include <umfpack_numeric.h>
-#endif
+%include <umfpack_symbolic.h>
+%include <umfpack_numeric.h>
OPAQUE_ARGINOUT( void * )
%apply void ** opaque_arginout {
@@ -252,40 +245,29 @@
void **Numeric
}
-#if UMFPACK_MAIN_VERSION < 6
- %include <umfpack_free_symbolic.h>
- %include <umfpack_free_numeric.h>
-#endif
+%include <umfpack_free_symbolic.h>
+%include <umfpack_free_numeric.h>
/*
* wnbell - attempt to get L,U,P,Q out
*/
%include "typemaps.i"
-%apply int *OUTPUT {
- int *lnz,
- int *unz,
- int *n_row,
- int *n_col,
- int *nz_udiag
+%apply int *OUTPUT {
+ int32_t *lnz,
+ int32_t *unz,
+ int32_t *n_row,
+ int32_t *n_col,
+ int32_t *nz_udiag
};
-%apply long *OUTPUT {
- long *lnz,
- long *unz,
- long *n_row,
- long *n_col,
- long *nz_udiag
+%apply int *OUTPUT {
+ int64_t *lnz,
+ int64_t *unz,
+ int64_t *n_row,
+ int64_t *n_col,
+ int64_t *nz_udiag
};
-%apply long *OUTPUT {
- SuiteSparse_long *lnz,
- SuiteSparse_long *unz,
- SuiteSparse_long *n_row,
- SuiteSparse_long *n_col,
- SuiteSparse_long *nz_udiag
-};
-#if UMFPACK_MAIN_VERSION < 6
- %include <umfpack_get_lunz.h>
-#endif
+%include <umfpack_get_lunz.h>
ARRAY_IN( double, double, DOUBLE )
%apply double *array {
@@ -298,41 +280,28 @@
double Rs [ ]
};
-ARRAY_IN( int, int, INT )
-%apply int *array {
- int Lp [ ],
- int Lj [ ],
- int Up [ ],
- int Ui [ ],
- int P [ ],
- int Q [ ]
+ARRAY_IN( int32_t, int32_t, INT32 )
+%apply int32_t *array {
+ int32_t Lp [ ],
+ int32_t Lj [ ],
+ int32_t Up [ ],
+ int32_t Ui [ ],
+ int32_t P [ ],
+ int32_t Q [ ]
};
-%apply int *OUTPUT { int *do_recip};
+%apply int *OUTPUT { int32_t *do_recip};
-ARRAY_IN( long, long, LONG )
-%apply long *array {
- long Lp [ ],
- long Lj [ ],
- long Up [ ],
- long Ui [ ],
- long P [ ],
- long Q [ ]
+ARRAY_IN( int64_t, int64_t, INT64 )
+%apply int64_t *array {
+ int64_t Lp [ ],
+ int64_t Lj [ ],
+ int64_t Up [ ],
+ int64_t Ui [ ],
+ int64_t P [ ],
+ int64_t Q [ ]
};
-%apply long *OUTPUT { long *do_recip};
+%apply int *OUTPUT { int64_t *do_recip};
-ARRAY_IN( SuiteSparse_long, SuiteSparse_long, INT64 )
-%apply SuiteSparse_long *array {
- SuiteSparse_long Lp [ ],
- SuiteSparse_long Lj [ ],
- SuiteSparse_long Up [ ],
- SuiteSparse_long Ui [ ],
- SuiteSparse_long P [ ],
- SuiteSparse_long Q [ ]
-};
-%apply long *OUTPUT { SuiteSparse_long *do_recip};
-
-#if UMFPACK_MAIN_VERSION < 6
- %include <umfpack_get_numeric.h>
-#endif
+%include <umfpack_get_numeric.h>
#endif // SWIGPYTHON
diff -ruN ./scikit-umfpack3/scikits/umfpack/umfpack.py ./scikit-umfpack/scikits/umfpack/umfpack.py
--- ./scikit-umfpack3/scikits/umfpack/umfpack.py 2025-02-27 11:18:39
+++ ./scikit-umfpack/scikits/umfpack/umfpack.py 2025-02-27 11:24:19
@@ -845,8 +845,24 @@
"""
+ if isinstance(mtx, sp.coo_matrix):
+ if (mtx.row.dtype == np.int64) or (mtx.col.dtype == np.int64):
+ ind64 = True
+ else:
+ ind64 = False
+ else:
+ if (mtx.indices.dtype == np.int64) or (mtx.indptr.dtype == np.int64):
+ ind64 = True
+ else:
+ ind64 = False
+
# this should probably be changed
mtx = mtx.tocsc()
+
+ if ind64:
+ mtx.indices = mtx.indices.astype(np.int64)
+ mtx.indptr = mtx.indptr.astype(np.int64)
+
self.numeric(mtx)
# first find out how much space to reserve