@@ -14,7 +14,7 @@ function SciMLBase.solve(cache::LinearCache, alg::AbstractFactorization; kwargs.
14
14
SciMLBase. build_linear_solution (alg, y, nothing , cache)
15
15
end
16
16
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
18
18
# This should instead just create the factorization type.
19
19
function init_cacheval (alg:: AbstractFactorization , A, b, u, Pl, Pr, maxiters, abstol,
20
20
reltol, verbose)
@@ -328,23 +328,31 @@ end
328
328
329
329
# # RFLUFactorization
330
330
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} ()
333
333
end
334
- (:: RFWrapper{P, T} )(A) where {P, T} = RecursiveFactorization. lu! (A, Val (P), Val (T))
335
334
336
335
function RFLUFactorization (; pivot = Val (true ), thread = Val (true ))
337
- GenericFactorization (; fact_alg = RFWrapper ( pivot, thread) )
336
+ RFLUFactorization ( pivot, thread)
338
337
end
339
338
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,
341
340
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
343
343
end
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)
348
356
end
349
357
350
358
# # FastLAPACKFactorizations
0 commit comments