@@ -74,7 +74,8 @@ function defaultalg(A::GPUArraysCore.AbstractGPUArray, b, assump::OperatorAssump
74
74
end
75
75
end
76
76
77
- function defaultalg (A:: GPUArraysCore.AbstractGPUArray , b, assump:: OperatorAssumptions{true,OperatorCondition.IllConditioned} )
77
+ function defaultalg (A:: GPUArraysCore.AbstractGPUArray , b,
78
+ assump:: OperatorAssumptions{true, OperatorCondition.IllConditioned} )
78
79
QRFactorization ()
79
80
end
80
81
@@ -86,7 +87,8 @@ function defaultalg(A, b::GPUArraysCore.AbstractGPUArray, assump::OperatorAssump
86
87
end
87
88
end
88
89
89
- function defaultalg (A, b:: GPUArraysCore.AbstractGPUArray , assump:: OperatorAssumptions{true,OperatorCondition.IllConditioned} )
90
+ function defaultalg (A, b:: GPUArraysCore.AbstractGPUArray ,
91
+ assump:: OperatorAssumptions{true, OperatorCondition.IllConditioned} )
90
92
QRFactorization ()
91
93
end
92
94
@@ -130,7 +132,7 @@ function defaultalg(A::GPUArraysCore.AbstractGPUArray, b::GPUArraysCore.Abstract
130
132
end
131
133
132
134
function defaultalg (A:: GPUArraysCore.AbstractGPUArray , b:: GPUArraysCore.AbstractGPUArray ,
133
- :: OperatorAssumptions{true,OperatorCondition.IllConditioned} )
135
+ :: OperatorAssumptions{true, OperatorCondition.IllConditioned} )
134
136
QRFactorization ()
135
137
end
136
138
@@ -155,17 +157,50 @@ function defaultalg(A, b, assump::OperatorAssumptions{true})
155
157
# whether MKL or OpenBLAS is being used
156
158
if (A === nothing && ! (b isa GPUArraysCore. AbstractGPUArray)) || A isa Matrix
157
159
if (A === nothing || eltype (A) <: Union{Float32, Float64, ComplexF32, ComplexF64} ) &&
158
- ArrayInterface. can_setindex (b) && __conditioning (assump) === OperatorCondition. IllConditioned
160
+ ArrayInterface. can_setindex (b) &&
161
+ (__conditioning (assump) === OperatorCondition. IllConditioned ||
162
+ __conditioning (assump) === OperatorCondition. WellConditioned)
159
163
if length (b) <= 10
160
- alg = GenericLUFactorization ()
164
+ pivot = @static if VERSION < v " 1.7beta"
165
+ if __conditioning (assump) === OperatorCondition. IllConditioned
166
+ Val (true )
167
+ else
168
+ Val (false )
169
+ end
170
+ else
171
+ if __conditioning (assump) === OperatorCondition. IllConditioned
172
+ RowMaximum ()
173
+ else
174
+ RowNonZero ()
175
+ end
176
+ end
177
+ alg = GenericLUFactorization (pivot)
161
178
elseif (length (b) <= 100 || (isopenblas () && length (b) <= 500 )) &&
162
179
(A === nothing ? eltype (b) <: Union{Float32, Float64} :
163
180
eltype (A) <: Union{Float32, Float64} )
164
- alg = RFLUFactorization ()
181
+ pivot = if __conditioning (assump) === OperatorCondition. IllConditioned
182
+ Val (true )
183
+ else
184
+ Val (false )
185
+ end
186
+ alg = RFLUFactorization (; pivot = pivot)
165
187
# elseif A === nothing || A isa Matrix
166
188
# alg = FastLUFactorization()
167
189
else
168
- alg = LUFactorization ()
190
+ pivot = @static if VERSION < v " 1.7beta"
191
+ if __conditioning (assump) === OperatorCondition. IllConditioned
192
+ Val (true )
193
+ else
194
+ Val (false )
195
+ end
196
+ else
197
+ if __conditioning (assump) === OperatorCondition. IllConditioned
198
+ RowMaximum ()
199
+ else
200
+ RowNonZero ()
201
+ end
202
+ end
203
+ alg = LUFactorization (pivot)
169
204
end
170
205
elseif __conditioning (assump) === OperatorCondition. VeryIllConditioned
171
206
alg = QRFactorization ()
@@ -187,20 +222,34 @@ function defaultalg(A, b, assump::OperatorAssumptions{true})
187
222
alg
188
223
end
189
224
190
- function defaultalg (A, b, :: OperatorAssumptions{false,OperatorCondition.IllConditioned} )
225
+ function defaultalg (A, b, :: OperatorAssumptions{false, OperatorCondition.WellConditioned} )
226
+ NormalCholeskyFactorization ()
227
+ end
228
+
229
+ function defaultalg (A, b, :: OperatorAssumptions{false, OperatorCondition.IllConditioned} )
191
230
QRFactorization ()
192
231
end
193
232
194
- function defaultalg (A, b, :: OperatorAssumptions{false,OperatorCondition.VeryIllConditioned} )
233
+ function defaultalg (A, b,
234
+ :: OperatorAssumptions{false, OperatorCondition.VeryIllConditioned} )
195
235
QRFactorization ()
196
236
end
197
237
198
- function defaultalg (A, b, :: OperatorAssumptions{false,OperatorCondition.SuperIllConditioned} )
238
+ function defaultalg (A, b,
239
+ :: OperatorAssumptions{false, OperatorCondition.SuperIllConditioned} )
199
240
SVDFactorization (false , LinearAlgebra. QRIteration ())
200
241
end
201
242
202
243
# # Catch high level interface
203
244
245
+ function SciMLBase. init (prob:: LinearProblem , alg:: Nothing ,
246
+ args... ;
247
+ assumptions = OperatorAssumptions (Val (issquare (prob. A))),
248
+ kwargs... )
249
+ alg = defaultalg (prob. A, prob. b, assumptions)
250
+ SciMLBase. init (prob, alg, args... ; assumptions, kwargs... )
251
+ end
252
+
204
253
function SciMLBase. solve (cache:: LinearCache , alg:: Nothing ,
205
254
args... ; assumptions:: OperatorAssumptions = OperatorAssumptions (),
206
255
kwargs... )
0 commit comments