@@ -27,13 +27,6 @@ function LinearSolve.init_cacheval(alg::RFLUFactorization,
27
27
nothing , nothing
28
28
end
29
29
30
- function LinearSolve. init_cacheval (
31
- alg:: QRFactorization , A:: Symmetric{<:Number, <:SparseMatrixCSC} , b, u, Pl, Pr,
32
- maxiters:: Int , abstol, reltol, verbose:: Bool ,
33
- assumptions:: OperatorAssumptions )
34
- return nothing
35
- end
36
-
37
30
function LinearSolve. handle_sparsematrixcsc_lu (A:: AbstractSparseMatrixCSC )
38
31
lu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A), nonzeros (A)),
39
32
check = false )
@@ -71,22 +64,51 @@ const PREALLOCATED_UMFPACK = SparseArrays.UMFPACK.UmfpackLU(SparseMatrixCSC(0, 0
71
64
Int[], Float64[]))
72
65
73
66
function LinearSolve. init_cacheval (
74
- alg:: UMFPACKFactorization , A:: SparseMatrixCSC{Float64, Int} , b, u,
67
+ alg:: Union{LUFactorization, GenericLUFactorization} , A:: AbstractSparseArray{<:Number, <:Integer} , b, u,
68
+ Pl, Pr,
69
+ maxiters:: Int , abstol, reltol,
70
+ verbose:: Bool , assumptions:: OperatorAssumptions )
71
+ nothing
72
+ end
73
+
74
+ function LinearSolve. init_cacheval (
75
+ alg:: UMFPACKFactorization , A:: AbstractArray , b, u,
76
+ Pl, Pr,
77
+ maxiters:: Int , abstol, reltol,
78
+ verbose:: Bool , assumptions:: OperatorAssumptions )
79
+ nothing
80
+ end
81
+
82
+ function LinearSolve. init_cacheval (
83
+ alg:: Union{LUFactorization, GenericLUFactorization} , A:: AbstractSparseArray{Float64, Int64} , b, u,
75
84
Pl, Pr,
76
85
maxiters:: Int , abstol, reltol,
77
86
verbose:: Bool , assumptions:: OperatorAssumptions )
78
87
PREALLOCATED_UMFPACK
79
88
end
80
89
81
90
function LinearSolve. init_cacheval (
82
- alg:: UMFPACKFactorization , A:: AbstractSparseArray{Float64} , b, u, Pl, Pr,
91
+ alg:: Union{LUFactorization, GenericLUFactorization} , A:: AbstractSparseArray{Float64, Int32} , b, u,
92
+ Pl, Pr,
93
+ maxiters:: Int , abstol, reltol,
94
+ verbose:: Bool , assumptions:: OperatorAssumptions )
95
+ SparseArrays. UMFPACK. UmfpackLU (SparseMatrixCSC {Float64, Int32} (0 , 0 , [Int32 (1 )], Int32[], Float64[]))
96
+ end
97
+
98
+ function LinearSolve. init_cacheval (
99
+ alg:: UMFPACKFactorization , A:: AbstractSparseArray{Float64, Int} , b, u, Pl, Pr,
83
100
maxiters:: Int , abstol,
84
101
reltol,
85
102
verbose:: Bool , assumptions:: OperatorAssumptions )
86
- A = convert (AbstractMatrix, A)
87
- zerobased = SparseArrays. getcolptr (A)[1 ] == 0
88
- return SparseArrays. UMFPACK. UmfpackLU (SparseMatrixCSC (size (A)... , getcolptr (A),
89
- rowvals (A), nonzeros (A)))
103
+ PREALLOCATED_UMFPACK
104
+ end
105
+
106
+ function LinearSolve. init_cacheval (
107
+ alg:: UMFPACKFactorization , A:: AbstractSparseArray{Float64, Int32} , b, u,
108
+ Pl, Pr,
109
+ maxiters:: Int , abstol, reltol,
110
+ verbose:: Bool , assumptions:: OperatorAssumptions )
111
+ SparseArrays. UMFPACK. UmfpackLU (SparseMatrixCSC {Float64, Int32} (0 , 0 , [Int32 (1 )], Int32[], Float64[]))
90
112
end
91
113
92
114
function SciMLBase. solve! (
@@ -118,7 +140,7 @@ function SciMLBase.solve!(
118
140
F = LinearSolve. @get_cacheval (cache, :UMFPACKFactorization )
119
141
if F. status == SparseArrays. UMFPACK. UMFPACK_OK
120
142
y = ldiv! (cache. u, F, cache. b)
121
- SciMLBase. build_linear_solution (alg, y, nothing , cache)
143
+ SciMLBase. build_linear_solution (alg, y, nothing , cache; retcode = ReturnCode . Success )
122
144
else
123
145
SciMLBase. build_linear_solution (
124
146
alg, cache. u, nothing , cache; retcode = ReturnCode. Infeasible)
@@ -129,21 +151,27 @@ const PREALLOCATED_KLU = KLU.KLUFactorization(SparseMatrixCSC(0, 0, [1], Int[],
129
151
Float64[]))
130
152
131
153
function LinearSolve. init_cacheval (
132
- alg:: KLUFactorization , A:: SparseMatrixCSC{Float64, Int} , b, u, Pl,
154
+ alg:: KLUFactorization , A:: AbstractArray , b, u, Pl,
133
155
Pr,
134
156
maxiters:: Int , abstol, reltol,
135
157
verbose:: Bool , assumptions:: OperatorAssumptions )
158
+ nothing
159
+ end
160
+
161
+ function LinearSolve. init_cacheval (
162
+ alg:: KLUFactorization , A:: AbstractSparseArray{Float64, Int64} , b, u, Pl, Pr,
163
+ maxiters:: Int , abstol,
164
+ reltol,
165
+ verbose:: Bool , assumptions:: OperatorAssumptions )
136
166
PREALLOCATED_KLU
137
167
end
138
168
139
169
function LinearSolve. init_cacheval (
140
- alg:: KLUFactorization , A:: AbstractSparseArray{Float64} , b, u, Pl, Pr,
170
+ alg:: KLUFactorization , A:: AbstractSparseArray{Float64, Int32 } , b, u, Pl, Pr,
141
171
maxiters:: Int , abstol,
142
172
reltol,
143
173
verbose:: Bool , assumptions:: OperatorAssumptions )
144
- A = convert (AbstractMatrix, A)
145
- return KLU. KLUFactorization (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
146
- nonzeros (A)))
174
+ KLU. KLUFactorization (SparseMatrixCSC {Float64, Int32} (0 , 0 , [Int32 (1 )], Int32[], Float64[]))
147
175
end
148
176
149
177
# TODO : guard this against errors
@@ -173,7 +201,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::KLUFactorization;
173
201
F = LinearSolve. @get_cacheval (cache, :KLUFactorization )
174
202
if F. common. status == KLU. KLU_OK
175
203
y = ldiv! (cache. u, F, cache. b)
176
- SciMLBase. build_linear_solution (alg, y, nothing , cache)
204
+ SciMLBase. build_linear_solution (alg, y, nothing , cache; retcode = ReturnCode . Success )
177
205
else
178
206
SciMLBase. build_linear_solution (
179
207
alg, cache. u, nothing , cache; retcode = ReturnCode. Infeasible)
@@ -249,6 +277,34 @@ function LinearSolve.defaultalg(
249
277
end
250
278
end
251
279
280
+ # SPQR Handling
281
+ function LinearSolve. init_cacheval (
282
+ alg:: QRFactorization , A:: AbstractSparseArray{<:Number, <:Integer} , b, u,
283
+ Pl, Pr,
284
+ maxiters:: Int , abstol, reltol,
285
+ verbose:: Bool , assumptions:: OperatorAssumptions )
286
+ nothing
287
+ end
288
+
289
+ function LinearSolve. init_cacheval (alg:: QRFactorization , A:: SparseMatrixCSC{Float64, Int} , b, u, Pl, Pr,
290
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
291
+ assumptions:: OperatorAssumptions )
292
+ LinearSolve. ArrayInterface. qr_instance (convert (AbstractMatrix, A), alg. pivot)
293
+ end
294
+
295
+ function LinearSolve. init_cacheval (alg:: QRFactorization , A:: SparseMatrixCSC{Float64, Int32} , b, u, Pl, Pr,
296
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
297
+ assumptions:: OperatorAssumptions )
298
+ LinearSolve. ArrayInterface. qr_instance (convert (AbstractMatrix, A), alg. pivot)
299
+ end
300
+
301
+ function LinearSolve. init_cacheval (
302
+ alg:: QRFactorization , A:: Symmetric{<:Number, <:SparseMatrixCSC} , b, u, Pl, Pr,
303
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
304
+ assumptions:: OperatorAssumptions )
305
+ return nothing
306
+ end
307
+
252
308
LinearSolve. PrecompileTools. @compile_workload begin
253
309
A = sprand (4 , 4 , 0.3 ) + I
254
310
b = rand (4 )
0 commit comments