Skip to content

Commit 9bf951d

Browse files
authored
Fix escaping in docstrings (#141)
1 parent f41651f commit 9bf951d

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

docs/src/faq.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,32 @@ To differentiate through an `ImplicitFunction`, the following backends are suppo
1212

1313
By default, the conditions are differentiated using the same "outer" backend that is trying to differentiate the `ImplicitFunction`.
1414
However, this can be switched to any other "inner" backend compatible with [DifferentiationInterface.jl](https://github.com/gdalle/DifferentiationInterface.jl) (i.e. a subtype of `ADTypes.AbstractADType`).
15-
You can override the default with the `conditions_x_backend` and `conditions_y_backend` keyword arguments when constructing an `ImplicitFunction`.
1615

1716
## Input and output types
1817

19-
### Arrays
18+
### Vectors
2019

2120
Functions that eat or spit out arbitrary vectors are supported, as long as the forward mapping _and_ conditions return vectors of the same size.
2221

2322
If you deal with small vectors (say, less than 100 elements), consider using [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) for increased performance.
2423

24+
### Arrays
25+
26+
Functions that eat or spit out matrices and higher-order tensors are not supported.
27+
You can use `vec` and `reshape` for the conversion to and from vectors.
28+
2529
### Scalars
2630

2731
Functions that eat or spit out a single number are not supported.
2832
The forward mapping _and_ conditions need vectors: instead of returning `val` you should return `[val]` (a 1-element `Vector`).
2933
Or better yet, wrap it in a static vector: `SVector(val)`.
3034

31-
### Sparse vectors
35+
### Sparse arrays
3236

3337
!!! danger "Danger"
34-
Sparse vectors are not supported and might give incorrect values or `NaN`s!
38+
Sparse arrays are not supported out of the box and might yield incorrect values!
3539

36-
With ForwardDiff.jl, differentiation of sparse vectors will often give wrong results due to [sparsity pattern cancellation](https://github.com/JuliaDiff/ForwardDiff.jl/issues/658).
37-
That is why we do not test behavior for sparse inputs.
40+
If your use case involves sparse arrays, it is best to differentiate with respect to the dense vector of values and only construct the sparse array inside of the `forward` and `conditions` functions.
3841

3942
## Number of inputs and outputs
4043

src/implicit_function.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
KrylovLinearSolver
33
4-
Callable object that can solve linear systems `As = b` and `AS = b` in the same way that `\`.
4+
Callable object that can solve linear systems `As = b` and `AS = b` in the same way as the built-in `\\`.
55
Uses an iterative solver from [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl) under the hood.
66
77
# Note
@@ -81,7 +81,7 @@ The provided `linear_solver` objects needs to be callable, with two methods:
8181
- `(A, b::AbstractVector) -> s::AbstractVector` such that `A * s = b`
8282
- `(A, B::AbstractVector) -> S::AbstractMatrix` such that `A * S = B`
8383
84-
It can be either a direct solver (like `\`) or an iterative one (like [`KrylovLinearSolver`](@ref)).
84+
It can be either a direct solver (like `\\`) or an iterative one (like [`KrylovLinearSolver`](@ref)).
8585
Typically, direct solvers work best with dense Jacobians (`lazy = false`) while iterative solvers work best with operators (`lazy = true`).
8686
8787
# Condition backends
@@ -103,11 +103,7 @@ end
103103
"""
104104
ImplicitFunction{lazy}(
105105
forward, conditions;
106-
linear_solver=if lazy
107-
KrylovLinearSolver()
108-
else
109-
\
110-
end,
106+
linear_solver=lazy ? KrylovLinearSolver() : \\,
111107
conditions_x_backend=nothing,
112108
conditions_x_backend=nothing,
113109
)
@@ -138,9 +134,7 @@ end
138134
conditions_x_backend=nothing,
139135
)
140136
141-
Constructor for an [`ImplicitFunction`](@ref) which picks the `lazy` parameter automatically based on the `linear_solver`, using the following heuristic:
142-
143-
lazy = linear_solver != \
137+
Constructor for an [`ImplicitFunction`](@ref) which picks the `lazy` parameter automatically based on the `linear_solver`, using the following heuristic: `lazy = linear_solver != \\`.
144138
"""
145139
function ImplicitFunction(
146140
forward,

0 commit comments

Comments
 (0)