@@ -35,7 +35,6 @@ One way to specify preconditioners uses the `Pl` and `Pr` keyword arguments to
35
35
and ` Pr ` for right preconditioner, respectively. By default, if no preconditioner is given, the preconditioner is assumed to be
36
36
the identity `` I `` .
37
37
38
-
39
38
In the following, we will use a left sided diagonal (Jacobi) preconditioner.
40
39
41
40
``` @example precon1
45
44
A = rand(n, n)
46
45
b = rand(n)
47
46
48
- Pl= Diagonal(A)
47
+ Pl = Diagonal(A)
49
48
50
49
prob = LinearProblem(A, b)
51
50
sol = solve(prob, KrylovJL_GMRES(), Pl = Pl)
@@ -56,7 +55,6 @@ Alternatively, preconditioners can be specified via the `precs` argument to th
56
55
an iterative solver specification. This argument shall deliver a factory method mapping ` A ` and a
57
56
parameter ` p ` to a tuple ` (Pl,Pr) ` consisting a left and a right preconditioner.
58
57
59
-
60
58
``` @example precon2
61
59
using LinearSolve, LinearAlgebra
62
60
n = 4
@@ -65,9 +63,10 @@ A = rand(n, n)
65
63
b = rand(n)
66
64
67
65
prob = 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)))
69
67
sol.u
70
68
```
69
+
71
70
This approach has the advantage that the specification of the preconditioner is possible without
72
71
the knowledge of a concrete matrix ` A ` . It also allows to specify the preconditioner via a callable object
73
72
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
80
79
w::Float64
81
80
end
82
81
83
- (builder::WeightedDiagonalPreconBuilder)(A,p) = (builder.w* Diagonal(A),I)
82
+ (builder::WeightedDiagonalPreconBuilder)(A, p) = (builder.w * Diagonal(A), I)
84
83
85
84
n = 4
86
- A = n*I- rand(n, n)
85
+ A = n * I - rand(n, n)
87
86
b = rand(n)
88
87
89
88
prob = 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)))
91
90
sol.u
92
91
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)))
97
96
sol.u
98
97
```
98
+
99
99
## Preconditioner Interface
100
100
101
101
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.
128
128
Implementations of the algebraic multigrid method. Must be converted to a
129
129
preconditioner via ` AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.precmethod(A)) ` .
130
130
Requires ` A ` as a ` AbstractMatrix ` . Provides the following methods:
131
-
131
+
132
132
+ ` AlgebraicMultigrid.ruge_stuben(A) `
133
133
+ ` AlgebraicMultigrid.smoothed_aggregation(A) `
134
134
- [ PyAMG] ( https://github.com/cortner/PyAMG.jl ) :
135
135
Implementations of the algebraic multigrid method. Must be converted to a
136
136
preconditioner via ` PyAMG.aspreconditioner(PyAMG.precmethod(A)) ` .
137
137
Requires ` A ` as a ` AbstractMatrix ` . Provides the following methods:
138
-
138
+
139
139
+ ` PyAMG.RugeStubenSolver(A) `
140
140
+ ` PyAMG.SmoothedAggregationSolver(A) `
141
141
- [ 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.
154
154
and ` HYPRE.BoomerAMG ` .
155
155
- [ KrylovPreconditioners.jl] ( https://github.com/JuliaSmoothOptimizers/KrylovPreconditioners.jl/ ) : Provides GPU-ready
156
156
preconditioners via KernelAbstractions.jl. At the time of writing the package provides the following methods:
157
-
157
+
158
158
+ Incomplete Cholesky decomposition ` KrylovPreconditioners.kp_ic0(A) `
159
159
+ Incomplete LU decomposition ` KrylovPreconditioners.kp_ilu0(A) `
160
160
+ Block Jacobi ` KrylovPreconditioners.BlockJacobiPreconditioner(A, nblocks, device) `
0 commit comments