Skip to content

Commit bd0d087

Browse files
committed
... format
1 parent 020ea8c commit bd0d087

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

docs/src/basics/Preconditioners.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ One way to specify preconditioners uses the `Pl` and `Pr` keyword arguments to
3535
and `Pr` for right preconditioner, respectively. By default, if no preconditioner is given, the preconditioner is assumed to be
3636
the identity ``I``.
3737

38-
3938
In the following, we will use a left sided diagonal (Jacobi) preconditioner.
4039

4140
```@example precon1
@@ -45,7 +44,7 @@ n = 4
4544
A = rand(n, n)
4645
b = rand(n)
4746
48-
Pl=Diagonal(A)
47+
Pl = Diagonal(A)
4948
5049
prob = LinearProblem(A, b)
5150
sol = solve(prob, KrylovJL_GMRES(), Pl = Pl)
@@ -56,7 +55,6 @@ Alternatively, preconditioners can be specified via the `precs` argument to th
5655
an iterative solver specification. This argument shall deliver a factory method mapping `A` and a
5756
parameter `p` to a tuple `(Pl,Pr)` consisting a left and a right preconditioner.
5857

59-
6058
```@example precon2
6159
using LinearSolve, LinearAlgebra
6260
n = 4
@@ -65,9 +63,10 @@ A = rand(n, n)
6563
b = rand(n)
6664
6765
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)))
6967
sol.u
7068
```
69+
7170
This approach has the advantage that the specification of the preconditioner is possible without
7271
the knowledge of a concrete matrix `A`. It also allows to specify the preconditioner via a callable object
7372
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
8079
w::Float64
8180
end
8281
83-
(builder::WeightedDiagonalPreconBuilder)(A,p) = (builder.w*Diagonal(A),I)
82+
(builder::WeightedDiagonalPreconBuilder)(A, p) = (builder.w * Diagonal(A), I)
8483
8584
n = 4
86-
A = n*I-rand(n, n)
85+
A = n * I - rand(n, n)
8786
b = rand(n)
8887
8988
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)))
9190
sol.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)))
9796
sol.u
9897
```
98+
9999
## Preconditioner Interface
100100

101101
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.
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)`

test/resolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using LinearSolve, LinearAlgebra, SparseArrays, InteractiveUtils, Test
22
using LinearSolve: AbstractDenseFactorization, AbstractSparseFactorization
33

44
for alg in vcat(InteractiveUtils.subtypes(AbstractDenseFactorization),
5-
InteractiveUtils.subtypes(AbstractSparseFactorization))
5+
InteractiveUtils.subtypes(AbstractSparseFactorization))
66
if alg in [PardisoJL]
77
## Pardiso has extra tests in test/pardiso/pardiso.jl
88
continue

0 commit comments

Comments
 (0)