diff --git a/docs/pages.jl b/docs/pages.jl index 9db75654f..762377418 100644 --- a/docs/pages.jl +++ b/docs/pages.jl @@ -11,5 +11,5 @@ pages = ["index.md", "Solvers" => Any["solvers/solvers.md"], "Advanced" => Any["advanced/developing.md" "advanced/custom.md"], - "Release Notes" => "release_notes.md" + "Release Notes" => "release_notes.md", ] diff --git a/docs/src/release_notes.md b/docs/src/release_notes.md index 1e8514115..fcb5336bf 100644 --- a/docs/src/release_notes.md +++ b/docs/src/release_notes.md @@ -2,9 +2,9 @@ ## v2.0 -* `LinearCache` changed from immutable to mutable. With this, the out of place interfaces like - `set_A` were deprecated for simply mutating the cache, `cache.A = ...`. This fixes some - correctness checks and makes the package more robust while improving performance. -* The default algorithm is now type-stable and does not rely on a dynamic dispatch for the choice. -* IterativeSolvers.jl and KrylovKit.jl were made into extension packages. -* Documentation of the solvers has changed to docstrings \ No newline at end of file + - `LinearCache` changed from immutable to mutable. With this, the out of place interfaces like + `set_A` were deprecated for simply mutating the cache, `cache.A = ...`. This fixes some + correctness checks and makes the package more robust while improving performance. + - The default algorithm is now type-stable and does not rely on a dynamic dispatch for the choice. + - IterativeSolvers.jl and KrylovKit.jl were made into extension packages. + - Documentation of the solvers has changed to docstrings diff --git a/src/LinearSolve.jl b/src/LinearSolve.jl index c773fe92c..35b42e6c1 100644 --- a/src/LinearSolve.jl +++ b/src/LinearSolve.jl @@ -66,6 +66,29 @@ include("init.jl") include("extension_algs.jl") include("deprecated.jl") +@generated function SciMLBase.solve!(cache::LinearCache, alg::AbstractFactorization; + kwargs...) + quote + if cache.isfresh + fact = do_factorization(alg, cache.A, cache.b, cache.u) + cache.cacheval = fact + cache.isfresh = false + end + y = _ldiv!(cache.u, get_cacheval(cache, $(Meta.quot(defaultalg_symbol(alg)))), + cache.b) + + #= + retcode = if LinearAlgebra.issuccess(fact) + SciMLBase.ReturnCode.Success + else + SciMLBase.ReturnCode.Failure + end + SciMLBase.build_linear_solution(alg, y, nothing, cache; retcode = retcode) + =# + SciMLBase.build_linear_solution(alg, y, nothing, cache) + end +end + @static if INCLUDE_SPARSE include("factorization_sparse.jl") end @@ -82,7 +105,6 @@ isopenblas() = IS_OPENBLAS[] import PrecompileTools -#= PrecompileTools.@compile_workload begin A = rand(4, 4) b = rand(4) @@ -110,7 +132,6 @@ PrecompileTools.@compile_workload begin sol = solve(prob) # in case sparspak is used as default sol = solve(prob, SparspakFactorization()) end -=# export LUFactorization, SVDFactorization, QRFactorization, GenericFactorization, GenericLUFactorization, SimpleLUFactorization, RFLUFactorization, diff --git a/src/factorization.jl b/src/factorization.jl index a07eef238..b95c7ded7 100644 --- a/src/factorization.jl +++ b/src/factorization.jl @@ -6,29 +6,6 @@ function _ldiv!(x::Vector, A::Factorization, b::Vector) ldiv!(A, x) end -@generated function SciMLBase.solve!(cache::LinearCache, alg::AbstractFactorization; - kwargs...) - quote - if cache.isfresh - fact = do_factorization(alg, cache.A, cache.b, cache.u) - cache.cacheval = fact - cache.isfresh = false - end - y = _ldiv!(cache.u, get_cacheval(cache, $(Meta.quot(defaultalg_symbol(alg)))), - cache.b) - - #= - retcode = if LinearAlgebra.issuccess(fact) - SciMLBase.ReturnCode.Success - else - SciMLBase.ReturnCode.Failure - end - SciMLBase.build_linear_solution(alg, y, nothing, cache; retcode = retcode) - =# - SciMLBase.build_linear_solution(alg, y, nothing, cache) - end -end - #RF Bad fallback: will fail if `A` is just a stand-in # This should instead just create the factorization type. function init_cacheval(alg::AbstractFactorization, A, b, u, Pl, Pr, maxiters::Int, abstol,