@@ -6,6 +6,7 @@ using LinearSolve: LinearSolve, BLASELTYPES, pattern_changed, ArrayInterface,
66 KLUFactorization, LUFactorization, NormalCholeskyFactorization,
77 OperatorAssumptions, LinearVerbosity,
88 QRFactorization, RFLUFactorization, UMFPACKFactorization, solve
9+ using SciMLOperators: AbstractSciMLOperator, has_concretization
910using ArrayInterface: ArrayInterface
1011using LinearAlgebra: LinearAlgebra, I, Hermitian, Symmetric, cholesky, ldiv!, lu, lu!, QR
1112using SparseArrays: SparseArrays, AbstractSparseArray, AbstractSparseMatrixCSC,
@@ -274,6 +275,103 @@ function LinearSolve.init_cacheval(
274275 0 , 0 , [Int32 (1 )], Int32[], Float64[]))
275276end
276277
278+ # AbstractSciMLOperator handling for sparse factorizations
279+ function LinearSolve. init_cacheval (
280+ alg:: KLUFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
281+ maxiters:: Int , abstol, reltol,
282+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
283+ if has_concretization (A)
284+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
285+ maxiters, abstol, reltol, verbose, assumptions)
286+ else
287+ nothing
288+ end
289+ end
290+
291+ function LinearSolve. init_cacheval (
292+ alg:: UMFPACKFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
293+ maxiters:: Int , abstol, reltol,
294+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
295+ if has_concretization (A)
296+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
297+ maxiters, abstol, reltol, verbose, assumptions)
298+ else
299+ nothing
300+ end
301+ end
302+
303+ function LinearSolve. init_cacheval (
304+ alg:: LUFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
305+ maxiters:: Int , abstol, reltol,
306+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
307+ if has_concretization (A)
308+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
309+ maxiters, abstol, reltol, verbose, assumptions)
310+ else
311+ nothing
312+ end
313+ end
314+
315+ function LinearSolve. init_cacheval (
316+ alg:: CHOLMODFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
317+ maxiters:: Int , abstol, reltol,
318+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
319+ if has_concretization (A)
320+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
321+ maxiters, abstol, reltol, verbose, assumptions)
322+ else
323+ nothing
324+ end
325+ end
326+
327+ function LinearSolve. init_cacheval (
328+ alg:: GenericFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
329+ maxiters:: Int , abstol, reltol,
330+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
331+ if has_concretization (A)
332+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
333+ maxiters, abstol, reltol, verbose, assumptions)
334+ else
335+ nothing
336+ end
337+ end
338+
339+ function LinearSolve. init_cacheval (
340+ alg:: GenericLUFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
341+ maxiters:: Int , abstol, reltol,
342+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
343+ if has_concretization (A)
344+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
345+ maxiters, abstol, reltol, verbose, assumptions)
346+ else
347+ nothing
348+ end
349+ end
350+
351+ function LinearSolve. init_cacheval (
352+ alg:: QRFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
353+ maxiters:: Int , abstol, reltol,
354+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
355+ if has_concretization (A)
356+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
357+ maxiters, abstol, reltol, verbose, assumptions)
358+ else
359+ nothing
360+ end
361+ end
362+
363+ function LinearSolve. init_cacheval (
364+ alg:: NormalCholeskyFactorization , A:: AbstractSciMLOperator , b, u, Pl, Pr,
365+ maxiters:: Int , abstol, reltol,
366+ verbose:: Union{LinearVerbosity, Bool} , assumptions:: OperatorAssumptions )
367+ if has_concretization (A)
368+ return LinearSolve. init_cacheval (alg, convert (AbstractMatrix, A), b, u, Pl, Pr,
369+ maxiters, abstol, reltol, verbose, assumptions)
370+ else
371+ nothing
372+ end
373+ end
374+
277375function SciMLBase. solve! (cache:: LinearSolve.LinearCache , alg:: KLUFactorization ; kwargs... )
278376 A = cache. A
279377 A = convert (AbstractMatrix, A)
0 commit comments