Skip to content

Commit 6615393

Browse files
committed
SparseMatrixExtension -> SparseMatrixLNK
Tried to document the source of the idea.
1 parent cf8f91e commit 6615393

File tree

10 files changed

+121
-274
lines changed

10 files changed

+121
-274
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@
88

99
Sparse matrix class with efficient successive insertion of entries.
1010

11-
Without an intermediate data structure, efficient successive insertion/update of entries in random order into a standard compressed colume storage structure appears to be not possible. The package introduces `ExtendableSparseMatrix`, a delegating wrapper around the Julia standard `SparseMatrixCSC` struct which contains an additional linked list based (but realised in vectors) temporary extension structure.
11+
Without an intermediate data structure, efficient successive insertion/update of possibly duplicate entries in random order into a standard compressed colume storage structure appears to be not possible. The package introduces `ExtendableSparseMatrix`, a delegating wrapper containing a Julia standard `SparseMatrixCSC` struct for performing linear algebra operations and a `SparseMatrixLNK` struct realising a linked list based (but realised in vectors) format collecting new entries.
12+
13+
The later is modeled after the linked list sparse matrix format described in the [whitepaper](https://www-users.cs.umn.edu/~saad/software/SPARSKIT/paper.ps) by Y. Saad.
14+
15+
Any linear algebra method on `ExtendableSparseMatrix` starts with a `flush!` method which splices the LNK entries and the existing CSC entries into a new CSC struct and resets the LNK struct.
16+
17+
`ExtendableSparseMatrix` is aimed to work as a drop-in replacement to `SparseMatrixCSC` in finite element and finite volume codes especally in those cases where the sparsity structure is hard to detect a priori and where working with an intermediadte COO representation appears to be not convenient.
18+
19+
20+
1221

13-
`ExtendableSparseMatrix` is aimed to work as a drop-in replacement to `SparseMatrixCSC` in finite element and finite volume codes.
1422

1523

docs/src/api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
```@autodocs
77
Modules = [ExtendableSparse]
8-
Pages = ["extension.jl","extendable.jl"]
8+
Pages = ["sparsematrixlnk.jl","extendable.jl"]
99
Order = [:type]
1010
```
1111

1212
```@autodocs
1313
Modules = [ExtendableSparse]
14-
Pages = ["extension.jl","extendable.jl"]
14+
Pages = ["sparsematrixlnk.jl","extendable.jl"]
1515
Order = [:constant]
1616
```
1717
## Methods
1818

1919
```@autodocs
2020
Modules = [ExtendableSparse]
21-
Pages = ["extension.jl","extendable.jl", "sprand.jl"]
21+
Pages = ["sparsematrixlnk.jl","extendable.jl", "sprand.jl"]
2222
Order = [:function]
2323
```

docs/src/changes.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Changes
22
## dev
3+
- Tried to track down the source from which I learned the linked list based struct in order
4+
to document this. Ended up with SPARSEKIT of Y.Saad, however I believe this
5+
already was in SPARSEPAK by Chu,George,Liu.
6+
- Internal rename of SparseMatrixExtension to SparseMatrixLNK.
7+
8+
## v0.2 Dec 2019
39
- more interface methods delegating to csc, in particular mul! and ldiv!
410
- lazy creation of extendable part: don't create idle memory
511
- nicer constructors
612

713
## V0.1, July 2019
8-
914
- Initial release
1015

docs/src/example.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,29 @@
33
An `ExtendableSparseMatrix` can serve as a drop-in replacement for
44
`SparseMatrixCSC`, albeit with faster assembly.
55

6-
The code below provides a small benchmark example.
6+
The code below provides a small benchmark example.
77
```julia
88
using ExtendableSparse
99
using SparseArrays
1010

11-
function ext_create(n, row_nz)
11+
function ext_create(n)
1212
A=ExtendableSparseMatrix(n,n)
13-
sprand_sdd!(A,row_nz);
13+
sprand_sdd!(A);
1414
end
1515

16-
function csc_create(n, row_nz)
16+
function csc_create(n)
1717
A=spzeros(n,n)
18-
sprand_sdd!(A,row_nz);
18+
sprand_sdd!(A);
1919
end
2020

21-
csc_create(10,2);
22-
ext_create(10,2);
23-
n=65536
24-
row_nz=5
25-
@time Acsc=csc_create(n,row_nz);
21+
# Trigger JIT compilation before timing
22+
csc_create(10);
23+
ext_create(10);
24+
25+
n=90000
26+
@time Acsc=csc_create(n);
2627
nnz(Acsc)
27-
@time Aext=ext_create(n,row_nz);
28+
@time Aext=ext_create(n);
2829
nnz(Aext)
2930
b=rand(n);
3031
@time Acsc*(Acsc\b)b
@@ -38,6 +39,8 @@ its rows. Its bandwidth is bounded by 2*sqrt(n), therefore it
3839
resembles a typical matrix of a 2D piecewise linear FEM discretization.
3940
For filling a matrix a, the method conveniently albeit naively
4041
uses just `a[i,j]=value`. This approach is considerably faster with
41-
the [`ExtendableSparseMatrix`](@ref).
42+
the [`ExtendableSparseMatrix`](@ref) which uses a linked list based
43+
structure [`SparseMatrixLNK`](@ref) to grab new entries.
44+
4245

4346

docs/src/index.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# ExtendableSparse
2-
3-
Sparse matrix class with efficient successive insertion of entries.
4-
5-
Without an intermediate data structure, efficient successive insertion/update of entries in random order into a standard compressed colume storage structure appears to be not possible. The package introduces `ExtendableSparseMatrix`, a delegating wrapper around the Julia standard `SparseMatrixCSC` struct which contains an additional linked list based (but realised in vectors) temporary extension structure.
6-
7-
`ExtendableSparseMatrix` is aimed to work as a drop-in replacement to `SparseMatrixCSC` in finite element and finite volume codes.
8-
9-
Currently it has the methods required for `AbstractSparseMatrix` (`getindex`, `setindex!`,`size`,`nnz`), as well as `lufact` and `mul!`, which is already sufficient for a number of interesting applications.
10-
1+
````@eval
2+
using Markdown
3+
Markdown.parse("""
4+
$(read("../../README.md",String))
5+
""")
6+
````

src/ExtendableSparse.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ using DocStringExtensions
33
using SparseArrays
44
using LinearAlgebra
55

6-
include("extension.jl")
6+
include("sparsematrixlnk.jl")
77
include("extendable.jl")
88
include("sprand.jl")
99

10-
export SparseMatrixExtension,ExtendableSparseMatrix,flush!,nnz, sprand!,sprand_sdd!
10+
export SparseMatrixLNK,ExtendableSparseMatrix,flush!,nnz, sprand!,sprand_sdd!
1111

1212
export colptrs
1313
end # module

0 commit comments

Comments
 (0)