@@ -14,7 +14,7 @@ function SciMLBase.solve(cache::LinearCache, alg::AbstractFactorization; kwargs.
1414 SciMLBase. build_linear_solution (alg, y, nothing , cache)
1515end
1616
17- # Bad fallback: will fail if `A` is just a stand-in
17+ # RF Bad fallback: will fail if `A` is just a stand-in
1818# This should instead just create the factorization type.
1919function init_cacheval (alg:: AbstractFactorization , A, b, u, Pl, Pr, maxiters, abstol,
2020 reltol, verbose)
@@ -328,23 +328,31 @@ end
328328
329329# # RFLUFactorization
330330
331- struct RFWrapper {P, T}
332- RFWrapper (:: Val{P} , :: Val{T} ) where {P, T} = new {P, T} ()
331+ struct RFLUFactorization {P, T}
332+ RFLUFactorization (:: Val{P} , :: Val{T} ) where {P, T} = new {P, T} ()
333333end
334- (:: RFWrapper{P, T} )(A) where {P, T} = RecursiveFactorization. lu! (A, Val (P), Val (T))
335334
336335function RFLUFactorization (; pivot = Val (true ), thread = Val (true ))
337- GenericFactorization (; fact_alg = RFWrapper ( pivot, thread) )
336+ RFLUFactorization ( pivot, thread)
338337end
339338
340- function init_cacheval (alg:: GenericFactorization{<:RFWrapper} , A, b, u, Pl, Pr, maxiters,
339+ function init_cacheval (alg:: RFLUFactorization , A, b, u, Pl, Pr, maxiters,
341340 abstol, reltol, verbose)
342- ArrayInterfaceCore. lu_instance (convert (AbstractMatrix, A))
341+ ipiv = Vector {LinearAlgebra.BlasInt} (undef, min (size (A)... ))
342+ ArrayInterfaceCore. lu_instance (convert (AbstractMatrix, A)), ipiv
343343end
344- function init_cacheval (alg:: GenericFactorization{<:RFWrapper} ,
345- A:: StridedMatrix{<:LinearAlgebra.BlasFloat} , b, u, Pl, Pr, maxiters,
346- abstol, reltol, verbose)
347- ArrayInterfaceCore. lu_instance (convert (AbstractMatrix, A))
344+
345+ function SciMLBase. solve (cache:: LinearCache , alg:: RFLUFactorization{P, T} ;
346+ kwargs... ) where {P, T}
347+ A = cache. A
348+ A = convert (AbstractMatrix, A)
349+ fact, ipiv = cache. cacheval
350+ if cache. isfresh
351+ fact = RecursiveFactorization. lu! (A, ipiv, Val (P), Val (T))
352+ cache = set_cacheval (cache, (fact, ipiv))
353+ end
354+ y = ldiv! (cache. u, cache. cacheval[1 ], cache. b)
355+ SciMLBase. build_linear_solution (alg, y, nothing , cache)
348356end
349357
350358# # FastLAPACKFactorizations
0 commit comments