Skip to content

Commit a07a096

Browse files
committed
modify extension algs
1 parent be1244e commit a07a096

File tree

8 files changed

+18
-15
lines changed

8 files changed

+18
-15
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ JET = "0.8.28"
8888
KLU = "0.6"
8989
KernelAbstractions = "0.9.16"
9090
Krylov = "0.9"
91+
KrylovPreconditioners = "0.2"
9192
KrylovKit = "0.8"
9293
LazyArrays = "1.8, 2"
9394
Libdl = "1.10"

docs/src/advanced/custom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The inputs to the function are as follows:
3333
- `p`, a set of parameters
3434
- `newA`, a `Bool` which is `true` if `A` has been modified since last solve
3535
- `Pl`, left-preconditioner
36-
- `Pr`, right-preconditioner
36+
- `Pr`, right-preconditionerz
3737
- `solverdata`, solver cache set to `nothing` if solver hasn't been initialized
3838
- `kwargs`, standard SciML keyword arguments such as `verbose`, `maxiters`, `abstol`, `reltol`
3939

docs/src/basics/FAQ.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ a few ways:
4545

4646
## How do I use IterativeSolvers solvers with a weighted tolerance vector?
4747

48-
IterativeSolvers.jl computes the norm after the application of the left preconditioner
49-
`Pl`. Thus, in order to use a vector tolerance `weights`, one can mathematically
48+
IterativeSolvers.jl computes the norm after the application of the left preconditioner.
49+
Thus, in order to use a vector tolerance `weights`, one can mathematically
5050
hack the system via the following formulation:
5151

5252
```@example FAQPrec
@@ -57,11 +57,10 @@ A = rand(n, n)
5757
b = rand(n)
5858
5959
weights = [1e-1, 1]
60-
Pl = LinearSolve.InvPreconditioner(Diagonal(weights))
61-
Pr = Diagonal(weights)
60+
precs = Returns(LinearSolve.InvPreconditioner(Diagonal(weights)), Diagonal(weights))
6261
6362
prob = LinearProblem(A, b)
64-
sol = solve(prob, KrylovJL_GMRES(), Pl = Pl, Pr = Pr)
63+
sol = solve(prob, KrylovJL_GMRES(precs))
6564
6665
sol.u
6766
```
@@ -84,5 +83,5 @@ Pl = LinearSolve.ComposePreconditioner(LinearSolve.InvPreconditioner(Diagonal(we
8483
Pr = Diagonal(weights)
8584
8685
prob = LinearProblem(A, b)
87-
sol = solve(prob, KrylovJL_GMRES(), Pl = Pl, Pr = Pr)
86+
sol = solve(prob, KrylovJL_GMRES(precs=Returns((Pl,Pr))))
8887
```

ext/LinearSolveIterativeSolversExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ end
1212

1313
function LinearSolve.IterativeSolversJL(args...;
1414
generate_iterator = IterativeSolvers.gmres_iterable!,
15-
gmres_restart = 0, kwargs...)
15+
gmres_restart = 0, precs = DEFAULT_PRECS, kwargs...)
1616
return IterativeSolversJL(generate_iterator, gmres_restart,
17-
args, kwargs)
17+
precs, args, kwargs)
1818
end
1919

2020
function LinearSolve.IterativeSolversJL_CG(args...; kwargs...)

ext/LinearSolveKrylovKitExt.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module LinearSolveKrylovKitExt
22

33
using LinearSolve, KrylovKit, LinearAlgebra
4-
using LinearSolve: LinearCache
4+
using LinearSolve: LinearCache, DEFAULT_PRECS
55

66
function LinearSolve.KrylovKitJL(args...;
77
KrylovAlg = KrylovKit.GMRES, gmres_restart = 0,
8+
precs = DEFAULT_PRECS,
89
kwargs...)
9-
return KrylovKitJL(KrylovAlg, gmres_restart, args, kwargs)
10+
return KrylovKitJL(KrylovAlg, gmres_restart, precs, args, kwargs)
1011
end
1112

1213
function LinearSolve.KrylovKitJL_CG(args...; kwargs...)

src/extension_algs.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ solvers.
259259
260260
Using this solver requires adding the package KrylovKit.jl, i.e. `using KrylovKit`
261261
"""
262-
struct KrylovKitJL{F, A, I, K} <: LinearSolve.AbstractKrylovSubspaceMethod
262+
struct KrylovKitJL{F, I, P, A, K} <: LinearSolve.AbstractKrylovSubspaceMethod
263263
KrylovAlg::F
264264
gmres_restart::I
265+
precs::P
265266
args::A
266267
kwargs::K
267268
end
@@ -306,9 +307,10 @@ A generic wrapper over the IterativeSolvers.jl solvers.
306307
307308
Using this solver requires adding the package IterativeSolvers.jl, i.e. `using IterativeSolvers`
308309
"""
309-
struct IterativeSolversJL{F, I, A, K} <: LinearSolve.AbstractKrylovSubspaceMethod
310+
struct IterativeSolversJL{F, I, P, A, K} <: LinearSolve.AbstractKrylovSubspaceMethod
310311
generate_iterator::F
311312
gmres_restart::I
313+
precs::P
312314
args::A
313315
kwargs::K
314316
end

src/iterative_wrappers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ KrylovJL(args...; KrylovAlg = Krylov.gmres!,
1010
1111
A generic wrapper over the Krylov.jl krylov-subspace iterative solvers.
1212
"""
13-
struct KrylovJL{F, I, A, P, K} <: AbstractKrylovSubspaceMethod
13+
struct KrylovJL{F, I, P, A, K} <: AbstractKrylovSubspaceMethod
1414
KrylovAlg::F
1515
gmres_restart::I
1616
window::I

test/static_arrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for alg in (nothing, LUFactorization(), SVDFactorization(), CholeskyFactorizatio
1919
@test norm(A * sol .- b) < 1e-10
2020

2121
if __non_native_static_array_alg(alg)
22-
@test_broken __solve_no_alloc(A, b, alg)
22+
@test_nowarn __solve_no_alloc(A, b, alg)
2323
else
2424
@test_nowarn __solve_no_alloc(A, b, alg)
2525
end

0 commit comments

Comments
 (0)