@@ -100,23 +100,29 @@ etc. all work.
100100
101101Now let's exploit sparsity. If we knew the sparsity pattern we could write it
102102down analytically as a sparse matrix, but let's assume we don't. Thus we can
103- use [ SparsityDetection .jl] ( https://github.com/JuliaDiffEq/SparsityDetection .jl )
103+ use [ SparseConnectivityTracer .jl] ( https://github.com/adrhill/SparseConnectivityTracer .jl )
104104to automatically get the sparsity pattern of the Jacobian as a sparse matrix:
105105
106106``` julia
107- using SparsityDetection , SparseArrays
107+ using SparseConnectivityTracer , SparseArrays
108108in = rand (10 )
109109out = similar (in)
110- sparsity_pattern = sparsity! (f,out,in)
110+
111+ detector = TracerSparsityDetector ()
112+ sparsity_pattern = jacobian_sparsity (f,out,in,detector)
113+
111114sparsejac = Float64 .(sparse (sparsity_pattern))
112115```
113116
114- Then we can use [ SparseDiffTools .jl] ( https://github.com/JuliaDiffEq/SparseDiffTools .jl )
117+ Then we can use [ SparseMatrixColorings .jl] ( https://github.com/gdalle/SparseMatrixColorings .jl )
115118to get the color vector:
116119
117120``` julia
118- using SparseDiffTools
119- colors = matrix_colors (sparsejac)
121+ using SparseMatrixColorings
122+ coloring_prob = ColoringProblem (; structure = :nonsymmetric , partition = :column )
123+ coloring_alg = GreedyColoringAlgorithm (; decompression = :direct )
124+ coloring_result = coloring (sparsejac, coloring_prob, coloring_alg)
125+ colors = column_colors (coloring_result)
120126```
121127
122128Now we can do sparse differentiation by passing the color vector and the sparsity
0 commit comments