From cfa0c68fa266329dbba13ed66f23d99e32fde2c9 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 26 Aug 2025 10:58:11 +0200 Subject: [PATCH 1/2] Update Docs: Replace `SparseDiffTools.jl` with `SparseConnectivityTracer.jl` and `SparseMatrixColorings.jl` --- README.md | 5 ++--- docs/src/jacobians.md | 2 +- docs/src/tutorials.md | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d39b011..4de29ee 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/src/jacobians.md b/docs/src/jacobians.md index 3e9333b..d787d55 100644 --- a/docs/src/jacobians.md +++ b/docs/src/jacobians.md @@ -14,7 +14,7 @@ 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 (`SparseMatrixCSC`) or structured matrix (`Tridiagonal`, `Banded`, etc.) - Supports automatic sparsity pattern detection via ArrayInterfaceCore.jl - Results are automatically decompressed unless `sparsity=nothing` diff --git a/docs/src/tutorials.md b/docs/src/tutorials.md index 44f797d..e3a2989 100644 --- a/docs/src/tutorials.md +++ b/docs/src/tutorials.md @@ -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 From 1f79574272311110fc2072a8b06a64547bd02886 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 26 Aug 2025 11:01:00 +0200 Subject: [PATCH 2/2] eg --- docs/src/jacobians.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/jacobians.md b/docs/src/jacobians.md index d787d55..1be2b2e 100644 --- a/docs/src/jacobians.md +++ b/docs/src/jacobians.md @@ -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 (`SparseMatrixCSC`) 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`