Skip to content

Commit 02cf5cf

Browse files
committed
udate docs
1 parent d900f7c commit 02cf5cf

File tree

3 files changed

+72
-21
lines changed

3 files changed

+72
-21
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExtendableSparse"
22
uuid = "95c220a8-a1cf-11e9-0c77-dbfce5f500b3"
33
authors = ["Juergen Fuhrmann <[email protected]>"]
4-
version = "1.6.0-dev"
4+
version = "1.6.0"
55

66
[deps]
77
AMGCLWrap = "4f76b812-4ba5-496d-b042-d70715554288"

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ILUZero = "88f59080-6952-5380-9ea5-54057fb9a43f"
99
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
1010
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
1111
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
12+
MultiFloats = "bdf0d083-296b-4888-a5b6-7498122e68a5"
1213
Sparspak = "e56a9233-b9d6-4f03-8d0f-1825330902ac"
1314

1415
[compat]

docs/src/linearsolve.md

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,72 @@
1-
# Integration with LinearSolve.jl
1+
# Linear System solution
22

3-
Starting with version 0.9.6, ExtendableSparse is compatible
4-
with [LinearSolve.jl](https://github.com/SciML/LinearSolve.jl).
5-
Since version 0.9.7, this is facilitated via the
6-
AbstractSparseMatrixCSC interface. Since version 1.6,
7-
preconditioner constructors can be passed to iterative solvers via the [`precs`
8-
keyword argument](https://docs.sciml.ai/LinearSolve/stable/basics/Preconditioners/#prec).
9-
10-
We can create a test problem and solve it with the `\` operator.
3+
## The `\` operator
4+
The packages overloads `\` for the ExtendableSparseMatrix type.
5+
The following example uses [`fdrand`](@ref) to create a test matrix and solve
6+
the corresponding linear system of equations.
117

128
```@example
13-
using ExtendableSparse # hide
9+
using ExtendableSparse
1410
A = fdrand(10, 10, 10; matrixtype = ExtendableSparseMatrix)
1511
x = ones(1000)
1612
b = A * x
1713
y = A \ b
1814
sum(y)
1915
```
2016

17+
This works as well for number types besides `Float64` and related, in this case,
18+
by default a LU factorization based on Sparspak ist used.
19+
20+
```@example
21+
using ExtendableSparse
22+
using MultiFloats
23+
A = fdrand(Float64x2, 10, 10, 10; matrixtype = ExtendableSparseMatrix)
24+
x = ones(Float64x2,1000)
25+
b = A * x
26+
y = A \ b
27+
sum(y)
28+
```
29+
30+
## Solving with LinearSolve.jl
31+
32+
Starting with version 0.9.6, ExtendableSparse is compatible
33+
with [LinearSolve.jl](https://github.com/SciML/LinearSolve.jl).
34+
Since version 0.9.7, this is facilitated via the
35+
AbstractSparseMatrixCSC interface.
36+
37+
2138
The same problem can be solved via `LinearSolve.jl`:
2239

2340
```@example
24-
using ExtendableSparse # hide
25-
using LinearSolve # hide
41+
using ExtendableSparse
42+
using LinearSolve
2643
A = fdrand(10, 10, 10; matrixtype = ExtendableSparseMatrix)
2744
x = ones(1000)
2845
b = A * x
29-
y = solve(LinearProblem(A, b), SparspakFactorization()).u
46+
y = solve(LinearProblem(A, b)).u
3047
sum(y)
3148
```
3249

50+
```@example
51+
using ExtendableSparse
52+
using LinearSolve
53+
using MultiFloats
54+
A = fdrand(Float64x2, 10, 10, 10; matrixtype = ExtendableSparseMatrix)
55+
x = ones(Float64x2,1000)
56+
b = A * x
57+
y = solve(LinearProblem(A, b), SparspakFactorization()).u
58+
sum(y)
59+
```
3360

34-
## Preconditioning
61+
## Preconditioned Krylov solvers with LinearSolve.jl
3562

36-
LinearSolve allows to pass preconditioner constructors via the `precs` keyword
63+
Since version 1.6, preconditioner constructors can be passed to iterative solvers via the [`precs`
64+
keyword argument](https://docs.sciml.ai/LinearSolve/stable/basics/Preconditioners/#prec)
3765
to the iterative solver specification.
3866

3967
```@example
40-
using ExtendableSparse # hide
41-
using LinearSolve # hide
68+
using ExtendableSparse
69+
using LinearSolve
4270
using ExtendableSparse: ILUZeroPreconBuilder
4371
A = fdrand(10, 10, 10; matrixtype = ExtendableSparseMatrix)
4472
x = ones(1000)
@@ -48,6 +76,7 @@ y = LinearSolve.solve(LinearProblem(A, b),
4876
sum(y)
4977
```
5078

79+
## Available preconditioners
5180
ExtendableSparse provides constructors for preconditioners wich can be used as `precs`.
5281
These generally return a tuple `(Pl,I)` of a left preconditioner and a trivial right preconditioner.
5382

@@ -75,11 +104,32 @@ which wraps sparse LU factorizations supported by LinearSolve.jl
75104
ExtendableSparse.LinearSolvePreconBuilder
76105
```
77106

107+
78108
Block preconditioner constructors are provided as well
79109
```@docs; canonical=false
80110
ExtendableSparse.BlockPreconBuilder
81111
```
82112

113+
114+
The example beloww shows how to create a block Jacobi preconditioner where the blocks are defined by even and odd
115+
degrees of freedom, and the diagonal blocks are solved using UMFPACK.
116+
```@example
117+
using ExtendableSparse
118+
using LinearSolve
119+
using ExtendableSparse: LinearSolvePreconBuilder, BlockPreconBuilder
120+
A = fdrand(10, 10, 10; matrixtype = ExtendableSparseMatrix)
121+
x = ones(1000)
122+
b = A * x
123+
partitioning=A->[1:2:size(A,1), 2:2:size(A,1)]
124+
umfpackprecs=LinearSolvePreconBuilder(UMFPACKFactorization())
125+
blockprecs=BlockPreconBuilder(;precs=umfpackprecs, partitioning)
126+
y = LinearSolve.solve(LinearProblem(A, b), KrylovJL_CG(; precs=blockprecs)).u
127+
sum(y)
128+
```
129+
`umpfackpreconbuilder` e.g. could be replaced by `SmoothedAggregationPreconBuilder()`. Moreover, this approach
130+
works for any `AbstractSparseMatrixCSC`.
131+
132+
83133
## Deprecated API
84134
Passing a preconditioner via the `Pl` or `Pr` keyword arguments
85135
will be deprecated in LinearSolve. ExtendableSparse used to
@@ -88,9 +138,9 @@ for this purpose. This approach is deprecated as of v1.6 and will be removed
88138
with v2.0.
89139

90140
```@example
91-
using ExtendableSparse # hide
92-
using LinearSolve # hide
93-
using SparseArrays # hide
141+
using ExtendableSparse
142+
using LinearSolve
143+
using SparseArray
94144
using ILUZero
95145
A = fdrand(10, 10, 10; matrixtype = ExtendableSparseMatrix)
96146
x = ones(1000)

0 commit comments

Comments
 (0)