Skip to content

Commit f7bd1fa

Browse files
committed
Revert error throwing to return nothing for default algorithm support
The init_cacheval methods need to return nothing when concretization is not supported, so that the default algorithm selection can fall back to other methods like Krylov solvers.
1 parent b3acd98 commit f7bd1fa

File tree

2 files changed

+9
-35
lines changed

2 files changed

+9
-35
lines changed

ext/LinearSolveSparseArraysExt.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using LinearSolve: LinearSolve, BLASELTYPES, pattern_changed, ArrayInterface,
44
@get_cacheval, CHOLMODFactorization, GenericFactorization,
55
GenericLUFactorization,
66
KLUFactorization, LUFactorization, NormalCholeskyFactorization,
7-
OperatorAssumptions, LinearVerbosity, RequiresConcreteMatrixError,
7+
OperatorAssumptions, LinearVerbosity,
88
QRFactorization, RFLUFactorization, UMFPACKFactorization, solve
99
using SciMLOperators: AbstractSciMLOperator, has_concretization
1010
using ArrayInterface: ArrayInterface
@@ -284,7 +284,7 @@ function LinearSolve.init_cacheval(
284284
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
285285
maxiters, abstol, reltol, verbose, assumptions)
286286
else
287-
throw(RequiresConcreteMatrixError("KLUFactorization"))
287+
nothing
288288
end
289289
end
290290

@@ -296,7 +296,7 @@ function LinearSolve.init_cacheval(
296296
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
297297
maxiters, abstol, reltol, verbose, assumptions)
298298
else
299-
throw(RequiresConcreteMatrixError("UMFPACKFactorization"))
299+
nothing
300300
end
301301
end
302302

@@ -308,7 +308,7 @@ function LinearSolve.init_cacheval(
308308
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
309309
maxiters, abstol, reltol, verbose, assumptions)
310310
else
311-
throw(RequiresConcreteMatrixError("LUFactorization"))
311+
nothing
312312
end
313313
end
314314

@@ -320,7 +320,7 @@ function LinearSolve.init_cacheval(
320320
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
321321
maxiters, abstol, reltol, verbose, assumptions)
322322
else
323-
throw(RequiresConcreteMatrixError("CHOLMODFactorization"))
323+
nothing
324324
end
325325
end
326326

@@ -332,7 +332,7 @@ function LinearSolve.init_cacheval(
332332
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
333333
maxiters, abstol, reltol, verbose, assumptions)
334334
else
335-
throw(RequiresConcreteMatrixError("GenericFactorization"))
335+
nothing
336336
end
337337
end
338338

@@ -344,7 +344,7 @@ function LinearSolve.init_cacheval(
344344
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
345345
maxiters, abstol, reltol, verbose, assumptions)
346346
else
347-
throw(RequiresConcreteMatrixError("GenericLUFactorization"))
347+
nothing
348348
end
349349
end
350350

@@ -356,7 +356,7 @@ function LinearSolve.init_cacheval(
356356
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
357357
maxiters, abstol, reltol, verbose, assumptions)
358358
else
359-
throw(RequiresConcreteMatrixError("QRFactorization"))
359+
nothing
360360
end
361361
end
362362

@@ -368,7 +368,7 @@ function LinearSolve.init_cacheval(
368368
return LinearSolve.init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
369369
maxiters, abstol, reltol, verbose, assumptions)
370370
else
371-
throw(RequiresConcreteMatrixError("NormalCholeskyFactorization"))
371+
nothing
372372
end
373373
end
374374

src/LinearSolve.jl

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -230,30 +230,6 @@ for integrating custom algorithms or simple solve strategies.
230230
"""
231231
abstract type AbstractSolveFunction <: SciMLLinearSolveAlgorithm end
232232

233-
# Errors
234-
235-
"""
236-
RequiresConcreteMatrixError(alg::String)
237-
238-
Error thrown when a factorization algorithm that requires a concrete matrix
239-
receives an operator that does not support concretization (i.e., `has_concretization(A)` returns `false`).
240-
241-
## Example
242-
243-
```julia
244-
throw(RequiresConcreteMatrixError("KLUFactorization"))
245-
```
246-
247-
This error suggests using a Krylov method instead, which can work with abstract operators.
248-
"""
249-
struct RequiresConcreteMatrixError <: Exception
250-
alg::String
251-
end
252-
253-
function Base.showerror(io::IO, e::RequiresConcreteMatrixError)
254-
print(io, "$(e.alg) requires a concrete matrix. The provided operator does not support concretization. Use a Krylov method instead.")
255-
end
256-
257233
# Traits
258234

259235
"""
@@ -543,8 +519,6 @@ export MetalOffload32MixedLUFactorization
543519

544520
export OperatorAssumptions, OperatorCondition
545521

546-
export RequiresConcreteMatrixError
547-
548522
export LinearSolveAdjoint
549523

550524
export LinearVerbosity

0 commit comments

Comments
 (0)