|
8 | 8 |
|
9 | 9 | Sparse matrix class with efficient successive insertion of entries and entry update.
|
10 | 10 |
|
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. |
| 11 | +Without an intermediate data structure, efficient successive insertion/update of possibly duplicate entries in random order into a standard compressed column 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 | 12 |
|
13 | 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. See also exercise P.3-16 in his [book](https://www-users.cs.umn.edu/~saad/IterMethBook_2ndEd.pdf).
|
14 | 14 |
|
15 | 15 | Any linear algebra method on `ExtendableSparseMatrix` starts with a `flush!` method which adds the LNK entries and the existing CSC entries into a new CSC struct and resets the LNK struct.
|
16 | 16 |
|
17 | 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 | 18 |
|
| 19 | +In particular, it cooperates with [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) when it comes to the assembly of a sparse jacobian. For a function 'f!(y,x)' returning it's result in a vector `y`, one can use e.g. |
| 20 | +```` |
| 21 | +x=... |
| 22 | +y=zeros(n) |
| 23 | +dresult=DiffResults.DiffResult(zeros(n),ExtendableSparseMatrix(n,n)) |
| 24 | +x=ForwardDiff.jacobian!(dresult,f!,y,x) |
| 25 | +jac=DiffResults.jacobian(dresult) |
| 26 | +h=jac\x |
| 27 | +```` |
| 28 | + |
19 | 29 | In addition, the package provides a method `updateindex!(A,op,v,i,j)` for both `SparseMatrixCSC` and for `ExtendableSparse` which allows to update a matrix element with one index search instead of two. It allows to replace e.g. `A[i,j]+=v` by `updateindex!(A,+,v,i,j)`. The former operation is lowered to
|
20 | 30 | ````
|
21 | 31 | %1 = Base.getindex(A, 1, 2)
|
22 | 32 | %2 = %1 + 3
|
23 | 33 | Base.setindex!(A, %2, 1, 2)
|
24 | 34 | ````
|
25 |
| - triggering two index searches, one for `getindex!` and another one for `setindex!`. |
| 35 | +triggering two index searches, one for `getindex!` and another one for `setindex!`. |
26 | 36 |
|
27 | 37 |
|
28 | 38 |
|
|
0 commit comments