Skip to content

Commit 7b8bbbf

Browse files
document all of the hacks and proposed interface
1 parent 6a174ed commit 7b8bbbf

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

docs/src/basics/FAQ.md

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
# Frequently Asked Questions
22

33
Ask more questions.
4+
5+
## How do I use IterativeSolvers solvers with a weighted tolerance vector?
6+
7+
IterativeSolvers.jl computes the norm after the application of the left precondtioner
8+
`Pl`. Thus in order to use a vector tolerance `weights`, one can mathematically
9+
hack the system via the following formulation:
10+
11+
```julia
12+
Pl = LinearSolve.DiagonalPreconditioner(1 ./ weights)
13+
Pr = LinearSolve.DiagonalPreconditioner(weights)
14+
15+
A = rand(n,n)
16+
b = rand(n)
17+
18+
prob = LinearProblem(A,b)
19+
sol = solve(prob,IterativeSolvers_GMRES(),Pl=Pl,Pr=Pr)
20+
```
21+
22+
If you want to use a "real" preconditioner under the norm `weights`, then one
23+
can use `ComposePreconditioner` to apply the preconditioner after the application
24+
of the weights like as follows:
25+
26+
```julia
27+
Pl = ComposePreconitioner(LinearSolve.DiagonalPreconditioner(1 ./ weights),realprec)
28+
Pr = LinearSolve.DiagonalPreconditioner(weights)
29+
30+
A = rand(n,n)
31+
b = rand(n)
32+
33+
prob = LinearProblem(A,b)
34+
sol = solve(prob,IterativeSolvers_GMRES(),Pl=Pl,Pr=Pr)
35+
```

docs/src/basics/Preconditioners.md

+8-15
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,13 @@ of random, `s` is an approximation to the eigenvalues of a system.
4343

4444
```julia
4545
s = rand(n)
46-
47-
# Pr applies 1 ./ s .* vec
48-
Pr = LinearSolve.DiagonalPreconditioner(s)
49-
# Pl applies s .* vec
5046
Pl = LinearSolve.DiagonalPreconditioner(s)
5147

5248
A = rand(n,n)
5349
b = rand(n)
5450

5551
prob = LinearProblem(A,b)
56-
sol = solve(prob,IterativeSolvers_GMRES(),Pl=Pl,Pr=Pr)
52+
sol = solve(prob,IterativeSolvers_GMRES(),Pl=Pl)
5753
```
5854

5955
## Pre-Defined Preconditioners
@@ -63,6 +59,11 @@ preconditioners written to match the required interface.
6359

6460
- `DiagonalPreconditioner(s::Union{Number,AbstractVector})`: the diagonal
6561
preconditioner, defined as a diagonal matrix `Diagonal(s)`.
62+
- `InvDiagonalPreconditioner(s::Union{Number,AbstractVector})`: the diagonal
63+
preconditioner, defined as a diagonal matrix `Diagonal(1./s)`.
64+
- `ComposePreconditioner(prec1,prec2)`: composes the preconditioners to apply
65+
`prec1` before `prec2`.
66+
- `InvComposePreconditioner(prec1,prec2)`: only god knows what this is for.
6667

6768
## Preconditioner Interface
6869

@@ -73,14 +74,6 @@ following interface:
7374

7475
- `Base.eltype(::Preconditioner)`
7576
- `Base.adjoint(::Preconditioner)`
76-
- `Base.inv(::Preconditioner)` (Optional?)
77-
78-
### Required for Right Preconditioners
79-
80-
- `Base.\(::Preconditioner,::AbstractVector)`
8177
- `LinearAlgebra.ldiv!(::AbstractVector,::Preconditioner,::AbstractVector)`
82-
83-
### Required for Left Preconditioners
84-
85-
- `Base.*(::Preconditioner,::AbstractVector)`
86-
- `LinearAlgebra.mul!(::AbstractVector,::Preconditioner,::AbstractVector)`
78+
- `Base.inv(::Preconditioner)` (Dear Jesus Krylov.jl, why?)
79+
- `LinearAlgebra.mul!(::AbstractVector,::Preconditioner,::AbstractVector)` (Required for Krylov.jl)

0 commit comments

Comments
 (0)