Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ Coloring vectors are allowed to be supplied to the Jacobian routines, and these
the directional derivatives for constructing the Jacobian. For example, an accurate
NxN tridiagonal Jacobian can be computed in just 4 `f` calls by using
`colorvec=repeat(1:3,N÷3)`. For information on automatically generating coloring
vectors of sparse matrices, see [SparseDiffTools.jl](https://github.com/JuliaDiff/SparseDiffTools.jl).

Hessian coloring support is coming soon!
vectors of sparse matrices, see [SparseMatrixColorings.jl](https://github.com/gdalle/SparseMatrixColorings.jl) and
the now deprecated [SparseDiffTools.jl](https://github.com/JuliaDiff/SparseDiffTools.jl).

## Contributing

Expand Down
3 changes: 2 additions & 1 deletion docs/src/jacobians.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Jacobians support the following function signatures:
FiniteDiff.jl provides efficient sparse Jacobian computation using graph coloring:

- Pass a `colorvec` of matrix colors to enable column compression
- Provide `sparsity` as a sparse or structured matrix (`Tridiagonal`, `Banded`, etc.)
- Provide `sparsity` as a sparse (e.g. the default `SparseMatrixCSC`)
or structured matrix (`Tridiagonal`, `Banded`, etc.)
- Supports automatic sparsity pattern detection via ArrayInterfaceCore.jl
- Results are automatically decompressed unless `sparsity=nothing`

Expand Down
18 changes: 12 additions & 6 deletions docs/src/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,29 @@ etc. all work.

Now let's exploit sparsity. If we knew the sparsity pattern we could write it
down analytically as a sparse matrix, but let's assume we don't. Thus we can
use [SparsityDetection.jl](https://github.com/JuliaDiffEq/SparsityDetection.jl)
use [SparseConnectivityTracer.jl](https://github.com/adrhill/SparseConnectivityTracer.jl)
to automatically get the sparsity pattern of the Jacobian as a sparse matrix:

```julia
using SparsityDetection, SparseArrays
using SparseConnectivityTracer, SparseArrays
in = rand(10)
out = similar(in)
sparsity_pattern = sparsity!(f,out,in)

detector = TracerSparsityDetector()
sparsity_pattern = jacobian_sparsity(f,out,in,detector)

sparsejac = Float64.(sparse(sparsity_pattern))
```

Then we can use [SparseDiffTools.jl](https://github.com/JuliaDiffEq/SparseDiffTools.jl)
Then we can use [SparseMatrixColorings.jl](https://github.com/gdalle/SparseMatrixColorings.jl)
to get the color vector:

```julia
using SparseDiffTools
colors = matrix_colors(sparsejac)
using SparseMatrixColorings
coloring_prob = ColoringProblem(; structure = :nonsymmetric, partition = :column)
coloring_alg = GreedyColoringAlgorithm(; decompression = :direct)
coloring_result = coloring(sparsejac, coloring_prob, coloring_alg)
colors = column_colors(coloring_result)
```

Now we can do sparse differentiation by passing the color vector and the sparsity
Expand Down
Loading