@@ -6,6 +6,34 @@ to use this in an actual problem, see
66
77Notation wise we are trying to solve for ` x ` such that ` nlfunc(x) = 0 ` .
88
9+ ## Big Table for Determining Sparsity Detection and Coloring Algorithms
10+
11+ | ` f.sparsity ` | ` f.jac_prototype ` | ` f.colorvec ` | Sparsity Detection | Coloring Algorithm |
12+ | :------------------------- | :---------------- | :----------- | :----------------------------------------------- | :---------------------------------------- |
13+ | ❌ | ❌ | ` Any ` | ` NoSparsityDetector() ` | ` NoColoringAlgorithm() ` |
14+ | ❌ | Not Structured | ` Any ` | ` NoSparsityDetector() ` | ` NoColoringAlgorithm() ` |
15+ | ❌ | Structured | ✅ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
16+ | ❌ | Structured | ❌ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
17+ | - | - | - | - | - |
18+ | ` AbstractMatrix ` | ❌ | ✅ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
19+ | ` AbstractMatrix ` | ❌ | ❌ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
20+ | ` AbstractMatrix ` | Not Structured | ✅ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
21+ | ` AbstractMatrix ` | Not Structured | ❌ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
22+ | ` AbstractMatrix ` | Structured | ` Any ` | 🔴 | 🔴 |
23+ | - | - | - | - | - |
24+ | ` AbstractSparsityDetector ` | ❌ | ` Any ` | ` f.sparsity ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
25+ | ` AbstractSparsityDetector ` | Not Structured | ✅ | ` f.sparsity ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
26+ | ` AbstractSparsityDetector ` | Not Structured | ❌ | ` f.sparsity ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
27+ | ` AbstractSparsityDetector ` | Structured | ✅ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
28+ | ` AbstractSparsityDetector ` | Structured | ❌ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
29+
30+ 1 . ` Structured ` means either a ` AbstractSparseMatrix ` or ` ArrayInterface.isstructured(x) ` is true.
31+ 2 . ❌ means not provided (default)
32+ 3 . ✅ means provided
33+ 4 . 🔴 means an error will be thrown
34+ 5 . Providing a colorvec without specifying either sparsity or jac_prototype with a sparse or structured matrix will cause us to ignore the colorvec.
35+ 6 . The function calls demonstrated above are simply pseudo-code to show the general idea.
36+
937## Case I: Sparse Jacobian Prototype is Provided
1038
1139Let's say you have a Sparse Jacobian Prototype ` jac_prototype ` , in this case you can
@@ -27,19 +55,12 @@ prob = NonlinearProblem(
2755If the ` colorvec ` is not provided, then it is computed on demand.
2856
2957!!! note
30-
58+
3159 One thing to be careful about in this case is that `colorvec` is dependent on the
3260 autodiff backend used. `ADTypes.mode(ad) isa ADTypes.ForwardMode` will assume that the
3361 colorvec is the column colorvec, otherwise we will assume that the colorvec is the
3462 row colorvec.
3563
36- !!! warning
37-
38- Previously you could provide a ` sparsity ` argument to ` NonlinearFunction ` to specify
39- the jacobian prototype. However, to avoid confusion, this is now deprecated. Instead,
40- use the ` jac_prototype ` argument. ` sparsity ` must be used to exclusively specify the
41- sparsity detection algorithm.
42-
4364## Case II: Sparsity Detection algorithm is provided
4465
4566If you don't have a Sparse Jacobian Prototype, but you know the which sparsity detection
@@ -59,7 +80,7 @@ for more information on sparsity detection algorithms.
5980## Case III: Sparse AD Type is being Used
6081
6182!!! warning
62-
83+
6384 This is now deprecated. Please use the previous two cases instead.
6485
6586If you constructed a Nonlinear Solver with a sparse AD type, for example
0 commit comments