@@ -35,7 +35,6 @@ One way to specify preconditioners uses the `Pl` and `Pr` keyword arguments to
3535and ` Pr ` for right preconditioner, respectively. By default, if no preconditioner is given, the preconditioner is assumed to be
3636the identity `` I `` .
3737
38-
3938In the following, we will use a left sided diagonal (Jacobi) preconditioner.
4039
4140``` @example precon1
4544A = rand(n, n)
4645b = rand(n)
4746
48- Pl= Diagonal(A)
47+ Pl = Diagonal(A)
4948
5049prob = LinearProblem(A, b)
5150sol = solve(prob, KrylovJL_GMRES(), Pl = Pl)
@@ -56,7 +55,6 @@ Alternatively, preconditioners can be specified via the `precs` argument to th
5655an iterative solver specification. This argument shall deliver a factory method mapping ` A ` and a
5756parameter ` p ` to a tuple ` (Pl,Pr) ` consisting a left and a right preconditioner.
5857
59-
6058``` @example precon2
6159using LinearSolve, LinearAlgebra
6260n = 4
@@ -65,9 +63,10 @@ A = rand(n, n)
6563b = rand(n)
6664
6765prob = LinearProblem(A, b)
68- sol = solve(prob, KrylovJL_GMRES(precs = (A,p)-> (Diagonal(A),I)) )
66+ sol = solve(prob, KrylovJL_GMRES(precs = (A, p) -> (Diagonal(A), I)))
6967sol.u
7068```
69+
7170This approach has the advantage that the specification of the preconditioner is possible without
7271the knowledge of a concrete matrix ` A ` . It also allows to specify the preconditioner via a callable object
7372and to pass parameters to the constructor of the preconditioner instances. The example below also shows how
@@ -80,22 +79,23 @@ Base.@kwdef struct WeightedDiagonalPreconBuilder
8079 w::Float64
8180end
8281
83- (builder::WeightedDiagonalPreconBuilder)(A,p) = (builder.w* Diagonal(A),I)
82+ (builder::WeightedDiagonalPreconBuilder)(A, p) = (builder.w * Diagonal(A), I)
8483
8584n = 4
86- A = n*I- rand(n, n)
85+ A = n * I - rand(n, n)
8786b = rand(n)
8887
8988prob = LinearProblem(A, b)
90- sol = solve(prob, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w= 0.9)) )
89+ sol = solve(prob, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w = 0.9)))
9190sol.u
9291
93- B=A.+ 0.1
94- cache= sol.cache
95- reinit!(cache,A= B, reuse_precs= true)
96- sol = solve!(cache, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w= 0.9)) )
92+ B = A .+ 0.1
93+ cache = sol.cache
94+ reinit!(cache, A = B, reuse_precs = true)
95+ sol = solve!(cache, KrylovJL_GMRES(precs = WeightedDiagonalPreconBuilder(w = 0.9)))
9796sol.u
9897```
98+
9999## Preconditioner Interface
100100
101101To 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.
128128 Implementations of the algebraic multigrid method. Must be converted to a
129129 preconditioner via ` AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.precmethod(A)) ` .
130130 Requires ` A ` as a ` AbstractMatrix ` . Provides the following methods:
131-
131+
132132 + ` AlgebraicMultigrid.ruge_stuben(A) `
133133 + ` AlgebraicMultigrid.smoothed_aggregation(A) `
134134 - [ PyAMG] ( https://github.com/cortner/PyAMG.jl ) :
135135 Implementations of the algebraic multigrid method. Must be converted to a
136136 preconditioner via ` PyAMG.aspreconditioner(PyAMG.precmethod(A)) ` .
137137 Requires ` A ` as a ` AbstractMatrix ` . Provides the following methods:
138-
138+
139139 + ` PyAMG.RugeStubenSolver(A) `
140140 + ` PyAMG.SmoothedAggregationSolver(A) `
141141 - [ 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.
154154 and ` HYPRE.BoomerAMG ` .
155155 - [ KrylovPreconditioners.jl] ( https://github.com/JuliaSmoothOptimizers/KrylovPreconditioners.jl/ ) : Provides GPU-ready
156156 preconditioners via KernelAbstractions.jl. At the time of writing the package provides the following methods:
157-
157+
158158 + Incomplete Cholesky decomposition ` KrylovPreconditioners.kp_ic0(A) `
159159 + Incomplete LU decomposition ` KrylovPreconditioners.kp_ilu0(A) `
160160 + Block Jacobi ` KrylovPreconditioners.BlockJacobiPreconditioner(A, nblocks, device) `
0 commit comments