@@ -74,7 +74,8 @@ function defaultalg(A::GPUArraysCore.AbstractGPUArray, b, assump::OperatorAssump
7474 end
7575end
7676
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} )
7879 QRFactorization ()
7980end
8081
@@ -86,7 +87,8 @@ function defaultalg(A, b::GPUArraysCore.AbstractGPUArray, assump::OperatorAssump
8687 end
8788end
8889
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} )
9092 QRFactorization ()
9193end
9294
@@ -130,7 +132,7 @@ function defaultalg(A::GPUArraysCore.AbstractGPUArray, b::GPUArraysCore.Abstract
130132end
131133
132134function defaultalg (A:: GPUArraysCore.AbstractGPUArray , b:: GPUArraysCore.AbstractGPUArray ,
133- :: OperatorAssumptions{true,OperatorCondition.IllConditioned} )
135+ :: OperatorAssumptions{true, OperatorCondition.IllConditioned} )
134136 QRFactorization ()
135137end
136138
@@ -155,17 +157,50 @@ function defaultalg(A, b, assump::OperatorAssumptions{true})
155157 # whether MKL or OpenBLAS is being used
156158 if (A === nothing && ! (b isa GPUArraysCore. AbstractGPUArray)) || A isa Matrix
157159 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)
159163 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)
161178 elseif (length (b) <= 100 || (isopenblas () && length (b) <= 500 )) &&
162179 (A === nothing ? eltype (b) <: Union{Float32, Float64} :
163180 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)
165187 # elseif A === nothing || A isa Matrix
166188 # alg = FastLUFactorization()
167189 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)
169204 end
170205 elseif __conditioning (assump) === OperatorCondition. VeryIllConditioned
171206 alg = QRFactorization ()
@@ -187,20 +222,34 @@ function defaultalg(A, b, assump::OperatorAssumptions{true})
187222 alg
188223end
189224
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} )
191230 QRFactorization ()
192231end
193232
194- function defaultalg (A, b, :: OperatorAssumptions{false,OperatorCondition.VeryIllConditioned} )
233+ function defaultalg (A, b,
234+ :: OperatorAssumptions{false, OperatorCondition.VeryIllConditioned} )
195235 QRFactorization ()
196236end
197237
198- function defaultalg (A, b, :: OperatorAssumptions{false,OperatorCondition.SuperIllConditioned} )
238+ function defaultalg (A, b,
239+ :: OperatorAssumptions{false, OperatorCondition.SuperIllConditioned} )
199240 SVDFactorization (false , LinearAlgebra. QRIteration ())
200241end
201242
202243# # Catch high level interface
203244
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+
204253function SciMLBase. solve (cache:: LinearCache , alg:: Nothing ,
205254 args... ; assumptions:: OperatorAssumptions = OperatorAssumptions (),
206255 kwargs... )
0 commit comments