more documentation
This commit is contained in:
parent
d8fa36efe1
commit
66cb9f6555
2 changed files with 28 additions and 6 deletions
14
README.md
14
README.md
|
@ -5,15 +5,23 @@ Simple package to check derivatives
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
check(f, Jf, x[, constant_components]; f_kwargs...)
|
check(f, Jf, x[, constant_components]; taylortestplot=false, taylortestdirection=nothing, f_kwargs...)
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns true if `Jf` approximates the derivative/gradient/Jacobian of `f` at point `x` (along a random direction).
|
Returns true if `Jf` approximates the derivative/gradient/Jacobian of `f` at point `x` (along a random direction unless specified using `taylortestdirection`).
|
||||||
`f_kwargs` are keywords arguments to be passed to `f` and `Jf`.
|
`f_kwargs` are keywords arguments to be passed to `f` and `Jf`.
|
||||||
`constant_components` is an optional `Vector{Int}` corresponding to components of the direction which should be set to zero,
|
`constant_components` is an optional `Vector{Int}` corresponding to components of the direction which should be set to zero,
|
||||||
effectively ignoring the dependency of `f` on these components.
|
effectively ignoring the dependency of `f` on these components.
|
||||||
|
If `taylortestplot` is `true`, a log-log plot of the error against the perturbation size will be shown.
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
```
|
||||||
|
check!(f!, Jf!, x, size_f_x, size_Jf_x, [, constant_components]; taylortestplot=false, taylortestdirection=nothing, f_kwargs...)
|
||||||
|
```
|
||||||
|
|
||||||
|
Like `check` but handling non-allocating functions. Output size for both `f!` and the Jacobian `Jf!` must be provided (as `Tuple`s) via `size_f_x` and `size_Jf_x`.
|
||||||
|
|
||||||
|
## Examples (see `test` directory for more)
|
||||||
```julia
|
```julia
|
||||||
import TaylorTest
|
import TaylorTest
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,17 @@ import TensorOperations: @tensor
|
||||||
import UnicodePlots
|
import UnicodePlots
|
||||||
|
|
||||||
"""
|
"""
|
||||||
`check(f, Jf, x[, constant_components]; f_kwargs...)`
|
```
|
||||||
|
check(f, Jf, x[, constant_components]; taylortestplot=false, taylortestdirection=nothing, f_kwargs...)
|
||||||
|
```
|
||||||
|
|
||||||
Returns true if `Jf` approximates the derivative/gradient/Jacobian of `f` at point `x` (along a random direction).
|
Returns true if `Jf` approximates the derivative/gradient/Jacobian of `f` at point `x` (along a random direction unless specified using `taylortestdirection`).
|
||||||
`f_kwargs` are keywords arguments to be passed to `f` and `Jf`.
|
`f_kwargs` are keywords arguments to be passed to `f` and `Jf`.
|
||||||
`constant_components` is an optional `Vector{Int}` corresponding to components of the direction which should be set to zero,
|
`constant_components` is an optional `Vector{Int}` corresponding to components of the direction which should be set to zero,
|
||||||
effectively ignoring the dependency of `f` on these components.
|
effectively ignoring the dependency of `f` on these components.
|
||||||
|
If `taylortestplot` is `true`, a log-log plot of the error against the perturbation size will be shown.
|
||||||
|
|
||||||
|
See also: `check!`
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
```julia-repl
|
```julia-repl
|
||||||
|
@ -70,7 +75,16 @@ function check(f, Jf, x, constant_components::Vector{Int}=Int[]; taylortestplot:
|
||||||
return isapprox(order, 1; atol=0.5)
|
return isapprox(order, 1; atol=0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
function check!(f!, Jf!, x, size_f_x, size_Jf_x, constant_components::Vector{Int}=Int[];
|
"""
|
||||||
|
```
|
||||||
|
check!(f!, Jf!, x, size_f_x, size_Jf_x, [, constant_components]; taylortestplot=false, taylortestdirection=nothing, f_kwargs...)
|
||||||
|
```
|
||||||
|
|
||||||
|
Like `check` but handling non-allocating functions. Output size for both `f!` and the Jacobian `Jf!` must be provided (as `Tuple`s) via `size_f_x` and `size_Jf_x`.
|
||||||
|
|
||||||
|
See also: `check`
|
||||||
|
"""
|
||||||
|
function check!(f!, Jf!, x, size_f_x::Tuple, size_Jf_x::Tuple, constant_components::Vector{Int}=Int[];
|
||||||
taylortestdirection=nothing, taylortestplot::Bool=false, f_kwargs...)
|
taylortestdirection=nothing, taylortestplot::Bool=false, f_kwargs...)
|
||||||
|
|
||||||
f = x -> begin
|
f = x -> begin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue