Skip to content

Commit 97b4dd8

Browse files
committed
small fixes
1 parent 2e3c3f1 commit 97b4dd8

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

docs/src/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ Newton Method using Krylov.jl (montoison-orban-2023)[@cite]
44

55
## API
66

7+
#### Newton-Krylov
8+
79
```@docs
810
newton_krylov!
911
newton_krylov
1012
```
1113

14+
#### Halley-Krylov
15+
16+
```@docs
17+
halley_krylov!
18+
halley_krylov
19+
```
20+
1221
### Parameters
1322

1423
```@docs

src/NewtonKrylov.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,46 @@ function newton_krylov!(
315315
return u, (; solved = n_res <= tol, stats, t)
316316
end
317317

318+
"""
319+
halley_krylov(F, u₀::AbstractArray, M::Int = length(u₀))
320+
321+
## Arguments
322+
- `F`: `F(u)` solves `res = F(u) = 0`
323+
- `u`: Initial guess
324+
- `M`: Length of the output of `F`. Defaults to `length(u₀)`.
325+
326+
$(KWARGS_DOCS)
327+
"""
318328
function halley_krylov(F, u₀::AbstractArray, M::Int = length(u₀); kwargs...)
319329
F!(res, u) = (res .= F(u); nothing)
320330
return halley_krylov!(F!, u₀, M; kwargs...)
321331
end
322332

333+
"""
334+
halley_krylov!(F!, u₀::AbstractArray, M::Int = length(u₀))
335+
336+
## Arguments
337+
- `F!`: `F!(res, u)` solves `res = F(u) = 0`
338+
- `u`: Initial guess
339+
- `M`: Length of the output of `F!`. Defaults to `length(u₀)`.
340+
341+
$(KWARGS_DOCS)
342+
"""
323343
function halley_krylov!(F!, u₀::AbstractArray, M::Int = length(u₀); kwargs...)
324344
res = similar(u₀, M)
325345
return halley_krylov!(F!, u₀, res; kwargs...)
326346
end
327347

348+
"""
349+
halley_krylov!(F!, u::AbstractArray, res::AbstractArray)
350+
351+
## Arguments
352+
- `F!`: `F!(res, u)` solves `res = F(u) = 0`
353+
- `u`: Initial guess
354+
- `res`: Temporary for residual
355+
356+
$(KWARGS_DOCS)
357+
"""
328358
function halley_krylov!(
329359
F!, u::AbstractArray, res::AbstractArray;
330360
tol_rel = 1.0e-6,

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ end
5858
@test jvp J_Enz * v
5959
end
6060

61+
import NewtonKrylov: HessianOperator
62+
6163
# Differentiate F with respect to x twice.
6264
function ddf(x, a)
6365
return autodiff(Forward, df, DuplicatedNoNeed(x, a), Const(a)) |> first

0 commit comments

Comments
 (0)