-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve performance with sparse matrices (#101)
* implement sparse optimization for out-of-place build_mprk_matrix! * fix broadcasting * format * format * add package versions to tutorial * add warning to docs * fix nonconservative systems * fix comment * mention KLUFactorization * add LinearSolve * skip broken tests * Update docs/src/faq.md Co-authored-by: Stefan Kopecz <[email protected]> --------- Co-authored-by: Stefan Kopecz <[email protected]>
- Loading branch information
Showing
9 changed files
with
468 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
[deps] | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | ||
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" | ||
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" | ||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
|
||
[compat] | ||
BenchmarkTools = "1" | ||
Documenter = "1" | ||
InteractiveUtils = "1" | ||
LinearSolve = "2.21" | ||
OrdinaryDiffEq = "6.59" | ||
Pkg = "1" | ||
Plots = "1" | ||
SparseArrays = "1.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Troubleshooting and frequently asked questions | ||
|
||
## Sparse matrices | ||
|
||
You can use sparse matrices for the linear systems arising in | ||
[PositiveIntegrators.jl](https://github.com/SKopecz/PositiveIntegrators.jl), | ||
as described, e.g., in the [tutorial on linear advection](@ref tutorial-linear-advection). | ||
However, you need to make sure that you do not change the sparsity pattern | ||
of the production term matrix since we assume that the structural nonzeros | ||
are kept fixed. This is a [known issue](https://github.com/JuliaSparse/SparseArrays.jl/issues/190). | ||
For example, you should avoid something like | ||
|
||
```@repl | ||
using SparseArrays | ||
p = spdiagm(0 => ones(4), 1 => zeros(3)) | ||
p .= 2 * p | ||
``` | ||
|
||
Instead, you should be able to use a pattern like the following, where the function `nonzeros` is used to modify the values of a sparse matrix. | ||
|
||
```@repl | ||
using SparseArrays | ||
p = spdiagm(0 => ones(4), 1 => zeros(3)) | ||
for j in axes(p, 2) | ||
for idx in nzrange(p, j) | ||
i = rowvals(p)[idx] | ||
nonzeros(p)[idx] = 10 * i + j # value p[i, j] | ||
end | ||
end; p | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.