Skip to content

Commit

Permalink
Minor fixes to documentation (#182)
Browse files Browse the repository at this point in the history
* Reexport ADTypes interface

* Fix typo

* Fix brackets on `typeof`
  • Loading branch information
adrhill authored Aug 25, 2024
1 parent c7355d3 commit 20ccec0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SparseConnectivityTracer
using ADTypes
using Documenter
using DocumenterMermaid

Expand All @@ -13,7 +14,7 @@ DocMeta.setdocmeta!(
)

makedocs(;
modules=[SparseConnectivityTracer],
modules=[SparseConnectivityTracer, ADTypes],
authors="Adrian Hill <[email protected]>",
sitename="SparseConnectivityTracer.jl",
format=Documenter.HTML(;
Expand Down
44 changes: 22 additions & 22 deletions docs/src/dev/adding_overloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ Depending on the type of function you're dealing with, you will have to specify

| Function | Meaning |
|:-------------------------------------------|:--------------------------------------------------------|
| `is_der1_zero_global(::typeof{f}) = false` | $\frac{\partial f}{\partial x} \neq 0$ for some $x$ |
| `is_der2_zero_global(::typeof{f}) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for some $x$ |
| `is_der1_zero_global(::typeof(f)) = false` | $\frac{\partial f}{\partial x} \neq 0$ for some $x$ |
| `is_der2_zero_global(::typeof(f)) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for some $x$ |

Optionally, to increase the sparsity of [`TracerLocalSparsityDetector`](@ref), you can additionally implement

| Function | Meaning |
|:---------------------------------------------|:---------------------------------------------------------|
| `is_der1_zero_local(::typeof{f}, x) = false` | $\frac{\partial f}{\partial x} \neq 0$ for given $x$ |
| `is_der2_zero_local(::typeof{f}, x) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for given $x$ |
| `is_der1_zero_local(::typeof(f), x) = false` | $\frac{\partial f}{\partial x} \neq 0$ for given $x$ |
| `is_der2_zero_local(::typeof(f), x) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for given $x$ |

These fall back to

Expand All @@ -66,21 +66,21 @@ Depending on the type of function you're dealing with, you will have to specify

| Function | Meaning |
|:------------------------------------------------|:-------------------------------------------------------------------|
| `is_der1_arg1_zero_global(::typeof{f}) = false` | $\frac{\partial f}{\partial x} \neq 0$ for some $x,y$ |
| `is_der2_arg1_zero_global(::typeof{f}) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for some $x,y$ |
| `is_der1_arg2_zero_global(::typeof{f}) = false` | $\frac{\partial f}{\partial y} \neq 0$ for some $x,y$ |
| `is_der2_arg2_zero_global(::typeof{f}) = false` | $\frac{\partial^2 f}{\partial y^2} \neq 0$ for some $x,y$ |
| `is_der_cross_zero_global(::typeof{f}) = false` | $\frac{\partial^2 f}{\partial x \partial y} \neq 0$ for some $x,y$ |
| `is_der1_arg1_zero_global(::typeof(f)) = false` | $\frac{\partial f}{\partial x} \neq 0$ for some $x,y$ |
| `is_der2_arg1_zero_global(::typeof(f)) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for some $x,y$ |
| `is_der1_arg2_zero_global(::typeof(f)) = false` | $\frac{\partial f}{\partial y} \neq 0$ for some $x,y$ |
| `is_der2_arg2_zero_global(::typeof(f)) = false` | $\frac{\partial^2 f}{\partial y^2} \neq 0$ for some $x,y$ |
| `is_der_cross_zero_global(::typeof(f)) = false` | $\frac{\partial^2 f}{\partial x \partial y} \neq 0$ for some $x,y$ |

Optionally, to increase the sparsity of [`TracerLocalSparsityDetector`](@ref), you can additionally implement

| Function | Meaning |
|:-----------------------------------------------------|:--------------------------------------------------------------------|
| `is_der1_arg1_zero_local(::typeof{f}, x, y) = false` | $\frac{\partial f}{\partial x} \neq 0$ for given $x,y$ |
| `is_der2_arg1_zero_local(::typeof{f}, x, y) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for given $x,y$ |
| `is_der1_arg2_zero_local(::typeof{f}, x, y) = false` | $\frac{\partial f}{\partial x} \neq 0$ for given $x,y$ |
| `is_der2_arg2_zero_local(::typeof{f}, x, y) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for given $x,y$ |
| `is_der_cross_zero_local(::typeof{f}, x, y) = false` | $\frac{\partial^2 f}{\partial x \partial y} \neq 0$ for given $x,y$ |
| `is_der1_arg1_zero_local(::typeof(f), x, y) = false` | $\frac{\partial f}{\partial x} \neq 0$ for given $x,y$ |
| `is_der2_arg1_zero_local(::typeof(f), x, y) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for given $x,y$ |
| `is_der1_arg2_zero_local(::typeof(f), x, y) = false` | $\frac{\partial f}{\partial x} \neq 0$ for given $x,y$ |
| `is_der2_arg2_zero_local(::typeof(f), x, y) = false` | $\frac{\partial^2 f}{\partial x^2} \neq 0$ for given $x,y$ |
| `is_der_cross_zero_local(::typeof(f), x, y) = false` | $\frac{\partial^2 f}{\partial x \partial y} \neq 0$ for given $x,y$ |


These fall back to
Expand All @@ -97,19 +97,19 @@ Depending on the type of function you're dealing with, you will have to specify

| Function | Meaning |
|:-----------------------------------------------|:----------------------------------------------------------|
| `is_der1_out1_zero_local(::typeof{f}) = false` | $\frac{\partial f_1}{\partial x} \neq 0$ for some $x$ |
| `is_der2_out1_zero_local(::typeof{f}) = false` | $\frac{\partial^2 f_1}{\partial x^2} \neq 0$ for some $x$ |
| `is_der1_out2_zero_local(::typeof{f}) = false` | $\frac{\partial f_2}{\partial x} \neq 0$ for some $x$ |
| `is_der2_out2_zero_local(::typeof{f}) = false` | $\frac{\partial^2 f_2}{\partial x^2} \neq 0$ for some $x$ |
| `is_der1_out1_zero_local(::typeof(f)) = false` | $\frac{\partial f_1}{\partial x} \neq 0$ for some $x$ |
| `is_der2_out1_zero_local(::typeof(f)) = false` | $\frac{\partial^2 f_1}{\partial x^2} \neq 0$ for some $x$ |
| `is_der1_out2_zero_local(::typeof(f)) = false` | $\frac{\partial f_2}{\partial x} \neq 0$ for some $x$ |
| `is_der2_out2_zero_local(::typeof(f)) = false` | $\frac{\partial^2 f_2}{\partial x^2} \neq 0$ for some $x$ |

Optionally, to increase the sparsity of [`TracerLocalSparsityDetector`](@ref), you can additionally implement

| Function | Meaning |
|:--------------------------------------------------|:-----------------------------------------------------------|
| `is_der1_out1_zero_local(::typeof{f}, x) = false` | $\frac{\partial f_1}{\partial x} \neq 0$ for given $x$ |
| `is_der2_out1_zero_local(::typeof{f}, x) = false` | $\frac{\partial^2 f_1}{\partial x^2} \neq 0$ for given $x$ |
| `is_der1_out2_zero_local(::typeof{f}, x) = false` | $\frac{\partial f_2}{\partial x} \neq 0$ for given $x$ |
| `is_der2_out2_zero_local(::typeof{f}, x) = false` | $\frac{\partial^2 f_2}{\partial x^2} \neq 0$ for given $x$ |
| `is_der1_out1_zero_local(::typeof(f), x) = false` | $\frac{\partial f_1}{\partial x} \neq 0$ for given $x$ |
| `is_der2_out1_zero_local(::typeof(f), x) = false` | $\frac{\partial^2 f_1}{\partial x^2} \neq 0$ for given $x$ |
| `is_der1_out2_zero_local(::typeof(f), x) = false` | $\frac{\partial f_2}{\partial x} \neq 0$ for given $x$ |
| `is_der2_out2_zero_local(::typeof(f), x) = false` | $\frac{\partial^2 f_2}{\partial x^2} \neq 0$ for given $x$ |

These fall back to

Expand Down
6 changes: 6 additions & 0 deletions docs/src/user/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ CollapsedDocStrings = true
SparseConnectivityTracer uses [ADTypes.jl](https://github.com/SciML/ADTypes.jl)'s [interface for sparsity detection](https://sciml.github.io/ADTypes.jl/stable/#Sparsity-detector).
In fact, the functions `jacobian_sparsity` and `hessian_sparsity` are re-exported from ADTypes.

```@docs
ADTypes.jacobian_sparsity
ADTypes.hessian_sparsity
```

To compute **global** sparsity patterns of `f(x)` over the entire input domain `x`, use
```@docs
TracerSparsityDetector
Expand All @@ -18,3 +23,4 @@ To compute **local** sparsity patterns of `f(x)` at a specific input `x`, use
```@docs
TracerLocalSparsityDetector
```

2 changes: 1 addition & 1 deletion docs/src/user/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ it must be written generically enough to accept numbers of type `T<:Real` as (or

Only [`TracerLocalSparsityDetector`](@ref) supports comparison operators (`<`, `==`, ...), indicator functions (`iszero`, `iseven`, ...) and control flow.

[`TracerSparsityDetector`](@ref) does not support any boolean functions and control flow (with the exception of `iselse`).
[`TracerSparsityDetector`](@ref) does not support any boolean functions and control flow (with the exception of `ifelse`).
This might seem unintuitive but follows from our policy stated above: SCT guarantees conservative sparsity patterns.
Using an approach based on operator-overloading, this means that global sparsity detection isn't allowed to hit any branching code.
`ifelse` is the only exception, since it allows us to evaluate both branches.
Expand Down

0 comments on commit 20ccec0

Please sign in to comment.