diff --git a/docs/src/basics/Preconditioners.md b/docs/src/basics/Preconditioners.md index 28304731..d2148de5 100644 --- a/docs/src/basics/Preconditioners.md +++ b/docs/src/basics/Preconditioners.md @@ -35,7 +35,6 @@ One way to specify preconditioners uses the `Pl` and `Pr` keyword arguments to and `Pr` for right preconditioner, respectively. By default, if no preconditioner is given, the preconditioner is assumed to be the identity ``I``. - In the following, we will use a left sided diagonal (Jacobi) preconditioner. ```@example precon1 @@ -45,7 +44,7 @@ n = 4 A = rand(n, n) b = rand(n) -Pl=Diagonal(A) +Pl = Diagonal(A) prob = LinearProblem(A, b) sol = solve(prob, KrylovJL_GMRES(), Pl = Pl) @@ -56,7 +55,6 @@ Alternatively, preconditioners can be specified via the `precs` argument to th an iterative solver specification. This argument shall deliver a factory method mapping `A` and a parameter `p` to a tuple `(Pl,Pr)` consisting a left and a right preconditioner. - ```@example precon2 using LinearSolve, LinearAlgebra n = 4 @@ -65,9 +63,10 @@ A = rand(n, n) b = rand(n) prob = LinearProblem(A, b) -sol = solve(prob, KrylovJL_GMRES(precs = (A,p)->(Diagonal(A),I)) ) +sol = solve(prob, KrylovJL_GMRES(precs = (A, p) -> (Diagonal(A), I))) sol.u ``` + This approach has the advantage that the specification of the preconditioner is possible without the knowledge of a concrete matrix `A`. It also allows to specify the preconditioner via a callable object and to pass parameters to the constructor of the preconditioner instances. The example below also shows how @@ -80,22 +79,23 @@ Base.@kwdef struct WeightedDiagonalPreconBuilder w::Float64 end -(builder::WeightedDiagonalPreconBuilder)(A,p) = (builder.w*Diagonal(A),I) +(builder::WeightedDiagonalPreconBuilder)(A, p) = (builder.w * Diagonal(A), I) n = 4 -A = n*I-rand(n, n) +A = n * I - rand(n, n) b = rand(n) prob = LinearProblem(A, b) -sol = solve(prob, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w=0.9)) ) +sol = solve(prob, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w = 0.9))) sol.u -B=A.+0.1 -cache=sol.cache -reinit!(cache,A=B, reuse_precs=true) -sol = solve!(cache, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w=0.9)) ) +B = A .+ 0.1 +cache = sol.cache +reinit!(cache, A = B, reuse_precs = true) +sol = solve!(cache, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w = 0.9))) sol.u ``` + ## Preconditioner Interface To define a new preconditioner you define a Julia type which satisfies the @@ -128,14 +128,14 @@ The following preconditioners match the interface of LinearSolve.jl. Implementations of the algebraic multigrid method. Must be converted to a preconditioner via `AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.precmethod(A))`. Requires `A` as a `AbstractMatrix`. Provides the following methods: - + + `AlgebraicMultigrid.ruge_stuben(A)` + `AlgebraicMultigrid.smoothed_aggregation(A)` - [PyAMG](https://github.com/cortner/PyAMG.jl): Implementations of the algebraic multigrid method. Must be converted to a preconditioner via `PyAMG.aspreconditioner(PyAMG.precmethod(A))`. Requires `A` as a `AbstractMatrix`. Provides the following methods: - + + `PyAMG.RugeStubenSolver(A)` + `PyAMG.SmoothedAggregationSolver(A)` - [ILUZero.ILU0Precon(A::SparseMatrixCSC{T,N}, b_type = T)](https://github.com/mcovalt/ILUZero.jl): @@ -154,7 +154,7 @@ The following preconditioners match the interface of LinearSolve.jl. and `HYPRE.BoomerAMG`. - [KrylovPreconditioners.jl](https://github.com/JuliaSmoothOptimizers/KrylovPreconditioners.jl/): Provides GPU-ready preconditioners via KernelAbstractions.jl. At the time of writing the package provides the following methods: - + + Incomplete Cholesky decomposition `KrylovPreconditioners.kp_ic0(A)` + Incomplete LU decomposition `KrylovPreconditioners.kp_ilu0(A)` + Block Jacobi `KrylovPreconditioners.BlockJacobiPreconditioner(A, nblocks, device)` diff --git a/test/resolve.jl b/test/resolve.jl index 5d0beb34..89240108 100644 --- a/test/resolve.jl +++ b/test/resolve.jl @@ -2,7 +2,7 @@ using LinearSolve, LinearAlgebra, SparseArrays, InteractiveUtils, Test using LinearSolve: AbstractDenseFactorization, AbstractSparseFactorization for alg in vcat(InteractiveUtils.subtypes(AbstractDenseFactorization), - InteractiveUtils.subtypes(AbstractSparseFactorization)) + InteractiveUtils.subtypes(AbstractSparseFactorization)) if alg in [PardisoJL] ## Pardiso has extra tests in test/pardiso/pardiso.jl continue