1
1
needs_concrete_A (alg:: DefaultLinearSolver ) = true
2
2
mutable struct DefaultLinearSolverInit{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
3
- T13, T14, T15, T16, T17, T18}
3
+ T13, T14, T15, T16, T17, T18, T19 }
4
4
LUFactorization:: T1
5
5
QRFactorization:: T2
6
6
DiagonalFactorization:: T3
@@ -19,6 +19,7 @@ mutable struct DefaultLinearSolverInit{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
19
19
NormalCholeskyFactorization:: T16
20
20
AppleAccelerateLUFactorization:: T17
21
21
MKLLUFactorization:: T18
22
+ QRFactorizationPivoted:: T19
22
23
end
23
24
24
25
# Legacy fallback
@@ -168,8 +169,8 @@ function defaultalg(A, b, assump::OperatorAssumptions)
168
169
(A === nothing ? eltype (b) <: Union{Float32, Float64} :
169
170
eltype (A) <: Union{Float32, Float64} )
170
171
DefaultAlgorithmChoice. RFLUFactorization
171
- # elseif A === nothing || A isa Matrix
172
- # alg = FastLUFactorization()
172
+ # elseif A === nothing || A isa Matrix
173
+ # alg = FastLUFactorization()
173
174
elseif usemkl && (A === nothing ? eltype (b) <: Union{Float32, Float64} :
174
175
eltype (A) <: Union{Float32, Float64} )
175
176
DefaultAlgorithmChoice. MKLLUFactorization
@@ -199,9 +200,19 @@ function defaultalg(A, b, assump::OperatorAssumptions)
199
200
elseif assump. condition === OperatorCondition. WellConditioned
200
201
DefaultAlgorithmChoice. NormalCholeskyFactorization
201
202
elseif assump. condition === OperatorCondition. IllConditioned
202
- DefaultAlgorithmChoice. QRFactorization
203
+ if is_underdetermined (A)
204
+ # Underdetermined
205
+ DefaultAlgorithmChoice. QRFactorizationPivoted
206
+ else
207
+ DefaultAlgorithmChoice. QRFactorization
208
+ end
203
209
elseif assump. condition === OperatorCondition. VeryIllConditioned
204
- DefaultAlgorithmChoice. QRFactorization
210
+ if is_underdetermined (A)
211
+ # Underdetermined
212
+ DefaultAlgorithmChoice. QRFactorizationPivoted
213
+ else
214
+ DefaultAlgorithmChoice. QRFactorization
215
+ end
205
216
elseif assump. condition === OperatorCondition. SuperIllConditioned
206
217
DefaultAlgorithmChoice. SVDFactorization
207
218
else
@@ -247,6 +258,12 @@ function algchoice_to_alg(alg::Symbol)
247
258
NormalCholeskyFactorization ()
248
259
elseif alg === :AppleAccelerateLUFactorization
249
260
AppleAccelerateLUFactorization ()
261
+ elseif alg === :QRFactorizationPivoted
262
+ @static if VERSION ≥ v " 1.7beta"
263
+ QRFactorization (ColumnNorm ())
264
+ else
265
+ QRFactorization (Val (true ))
266
+ end
250
267
else
251
268
error (" Algorithm choice symbol $alg not allowed in the default" )
252
269
end
@@ -311,6 +328,12 @@ function defaultalg_symbol(::Type{T}) where {T}
311
328
end
312
329
defaultalg_symbol (:: Type{<:GenericFactorization{typeof(ldlt!)}} ) = :LDLtFactorization
313
330
331
+ @static if VERSION >= v " 1.7"
332
+ defaultalg_symbol (:: Type{<:QRFactorization{ColumnNorm}} ) = :QRFactorizationPivoted
333
+ else
334
+ defaultalg_symbol (:: Type{<:QRFactorization{Val{true}}} ) = :QRFactorizationPivoted
335
+ end
336
+
314
337
"""
315
338
if alg.alg === DefaultAlgorithmChoice.LUFactorization
316
339
SciMLBase.solve!(cache, LUFactorization(), args...; kwargs...))
0 commit comments