This repository was archived by the owner on Aug 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343
4444For this function, we know that the sparsity pattern of the Jacobian is a
4545` Tridiagonal ` matrix. However, if we didn't know the sparsity pattern for
46- the Jacobian, we could use the ` jacobian_sparsity ` function to automatically
47- detect the sparsity pattern. This function is only available if you
48- load SparsityDetection.jl as well. We declare that the function ` f ` outputs a
49- vector of length 30 and takes in a vector of length 30, and ` jacobian_sparsity ` spits
50- out a ` Sparsity ` object which we can turn into a ` SparseMatrixCSC ` :
46+ the Jacobian, we could use the ` Symbolics.jacobian_sparsity ` function to automatically
47+ detect the sparsity pattern. We declare that the function ` f ` outputs a
48+ vector of length 30 and takes in a vector of length 30, and ` jacobian_sparsity ` returns
49+ a ` SparseMatrixCSC ` :
5150
5251``` julia
53- using Symbolics, SparseArrays
52+ using Symbolics
5453input = rand (30 )
5554output = similar (input)
5655sparsity_pattern = Symbolics. jacobian_sparsity (f,output,input)
57- jac = Float64 .(sparse ( sparsity_pattern) )
56+ jac = Float64 .(sparsity_pattern)
5857```
5958
6059Now we call ` matrix_colors ` to get the colorvec vector for that matrix:
You can’t perform that action at this time.
0 commit comments