@@ -15,18 +15,20 @@ Let's create a new wrapper for a simple LU-factorization which uses only the
1515basic machinery. A simplified version is:
1616
1717``` julia
18- struct MyLUFactorization{P} <: SciMLBase.AbstractLinearAlgorithm end
18+ struct MyLUFactorization{P} <: LinearSolve.SciMLLinearSolveAlgorithm end
1919
20- function init_cacheval (alg:: MyLUFactorization , A, b, u, Pl, Pr, maxiters, abstol, reltol,
21- verbose)
20+ function LinearSolve . init_cacheval (alg:: MyLUFactorization , A, b, u, Pl, Pr, maxiters:: Int , abstol, reltol,
21+ verbose:: Bool , assump :: LinearSolve.OperatorAssumptions )
2222 lu! (convert (AbstractMatrix, A))
2323end
2424
25- function SciMLBase. solve! (cache:: LinearCache , alg:: MyLUFactorization ; kwargs... )
25+ function SciMLBase. solve! (cache:: LinearSolve. LinearCache , alg:: MyLUFactorization ; kwargs... )
2626 if cache. isfresh
27+ A = cache. A
2728 A = convert (AbstractMatrix, A)
2829 fact = lu! (A)
29- cache = set_cacheval (cache, fact)
30+ cache. cacheval = fact
31+ cache. isfresh = false
3032 end
3133 y = ldiv! (cache. u, cache. cacheval, cache. b)
3234 SciMLBase. build_linear_solution (alg, y, nothing , cache)
@@ -39,7 +41,7 @@ need to cache their own things, and so there's one value `cacheval` that is
3941for the algorithms to modify. The function:
4042
4143``` julia
42- init_cacheval (alg:: MyLUFactorization , A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
44+ init_cacheval (alg:: MyLUFactorization , A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose, assump )
4345```
4446
4547is what is called at ` init ` time to create the first ` cacheval ` . Note that this
@@ -51,13 +53,13 @@ LU-factorization to get an `LU{T, Matrix{T}}` which it puts into the `cacheval`
5153so it is typed for future use.
5254
5355After the ` init_cacheval ` , the only thing left to do is to define
54- ` SciMLBase.solve(cache::LinearCache, alg::MyLUFactorization) ` . Many algorithms
56+ ` SciMLBase.solve! (cache::LinearCache, alg::MyLUFactorization) ` . Many algorithms
5557may use a lazy matrix-free representation of the operator ` A ` . Thus, if the
5658algorithm requires a concrete matrix, like LU-factorization does, the algorithm
5759should ` convert(AbstractMatrix,cache.A) ` . The flag ` cache.isfresh ` states whether
5860` A ` has changed since the last ` solve ` . Since we only need to factorize when
5961` A ` is new, the factorization part of the algorithm is done in a ` if cache.isfresh ` .
60- ` cache = set_cacheval( cache, fact) ` puts the new factorization into the cache,
62+ ` cache.cacheval = fact; cache.isfresh = false ` puts the new factorization into the cache,
6163so it's updated for future solves. Then ` y = ldiv!(cache.u, cache.cacheval, cache.b) `
6264performs the solve and a linear solution is returned via
6365` SciMLBase.build_linear_solution(alg,y,nothing,cache) ` .
0 commit comments