Skip to content

Commit 0cd3d73

Browse files
authored
Fix doc build (#12)
1 parent b683825 commit 0cd3d73

File tree

4 files changed

+75
-9
lines changed

4 files changed

+75
-9
lines changed

.github/workflows/Documentation.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,26 @@ on:
55
branches:
66
- main
77
tags: "*"
8+
9+
# needed to allow julia-actions/cache to delete old caches that it has created
10+
permissions:
11+
actions: write
12+
contents: read
13+
814
jobs:
915
docs:
1016
name: Documentation
1117
runs-on: ubuntu-latest
1218
steps:
13-
- uses: actions/checkout@v2
14-
- uses: julia-actions/setup-julia@v1
19+
- uses: actions/checkout@v4
20+
- uses: julia-actions/setup-julia@v2
1521
with:
1622
version: "1"
23+
- uses: julia-actions/cache@v2
1724
- name: instantiate docs
1825
run: |
1926
julia --project=docs -e '
2027
using Pkg
21-
Pkg.develop(PackageSpec(path=pwd()))
2228
Pkg.instantiate()
2329
'
2430
- name: run doctests

docs/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
66
KrylovPreconditioners = "45d422c2-293f-44ce-8315-2cb988662dec"
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
88
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
9+
NewtonKrylov = "0be81120-40bf-4f8b-adf0-26103efb66f1"
910
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
11+
12+
[sources.NewtonKrylov]
13+
path = ".."

src/NewtonKrylov.jl

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ function maybe_duplicated(f, df)
1919
end
2020
end
2121

22+
"""
23+
JacobianOperator
24+
25+
Efficient implementation of `J(f,x) * v` and `v * J(f, x)'`
26+
"""
2227
struct JacobianOperator{F, A}
2328
f::F # F!(res, u)
2429
f_cache::F
@@ -89,7 +94,22 @@ end
8994
##
9095
import Base: @kwdef
9196

97+
"""
98+
Forcing
99+
100+
Implements forcing for inexact Newton-Krylov.
101+
The equation ``‖F′(u)d + F(u)‖ <= η * ‖F(u)‖`` gives
102+
the inexact Newton termination criterion.
103+
104+
## Implemented variants
105+
- [`Fixed`](@ref)
106+
- [`EisenstatWalker`](@ref)
107+
"""
92108
abstract type Forcing end
109+
110+
"""
111+
Fixed(η = 0.1)
112+
"""
93113
@kwdef struct Fixed <: Forcing
94114
η::Float64 = 0.1
95115
end
@@ -99,6 +119,9 @@ function (F::Fixed)(args...)
99119
end
100120
inital(F::Fixed) = F.η
101121

122+
"""
123+
EisenstatWalker(η_max = 0.999, γ = 0.9)
124+
"""
102125
@kwdef struct EisenstatWalker <: Forcing
103126
η_max::Float64 = 0.999
104127
γ::Float64 = 0.9
@@ -121,11 +144,44 @@ function (F::EisenstatWalker)(η, tol, n_res, n_res_prior)
121144
end
122145
inital(F::EisenstatWalker) = F.η_max
123146

147+
const KWARGS_DOCS = """
148+
## Keyword Arguments
149+
- `tol_rel`: Relative tolerance
150+
- `tol_abs`: Absolute tolerance
151+
- `max_niter`: Maximum number of iterations
152+
- `forcing`: Maximum forcing term for inexact Newton.
153+
If `nothing` an exact Newton method is used.
154+
- `verbose`:
155+
- `Solver`:
156+
- `M`:
157+
- `N`:
158+
- `krylov_kwarg`
159+
- `callback`:
160+
"""
161+
162+
"""
163+
newton_krylov(F, u₀::AbstractArray, M::Int = length(u₀); kwargs...)
164+
165+
## Arguments
166+
- `F`: `res = F(u₀)` solves `res = F(u₀) = 0`
167+
- `u₀`: Initial guess
168+
- `M`: Length of the output of `F`. Defaults to `length(u₀)`.
169+
170+
$(KWARGS_DOCS)
171+
"""
124172
function newton_krylov(F, u₀::AbstractArray, M::Int = length(u₀); kwargs...)
125173
F!(res, u) = (res .= F(u); nothing)
126174
return newton_krylov!(F!, u₀, M; kwargs...)
127175
end
128176

177+
"""
178+
## Arguments
179+
- `F!`: `F!(res, u)` solves `res = F(u) = 0`
180+
- `u₀`: Initial guess
181+
- `M`: Length of the output of `F!`. Defaults to `length(u₀)`
182+
183+
$(KWARGS_DOCS)
184+
"""
129185
function newton_krylov!(F!, u₀::AbstractArray, M::Int = length(u₀); kwargs...)
130186
res = similar(u₀, M)
131187
return newton_krylov!(F!, u₀, res; kwargs...)
@@ -148,12 +204,8 @@ end
148204
- `F!`: `F!(res, u)` solves `res = F(u) = 0`
149205
- `u`: Initial guess
150206
- `res`: Temporary for residual
151-
## Keyword Arguments
152-
- `tol_rel`: Relative tolerance
153-
- `tol_abs`: Absolute tolerance
154-
- `max_niter`: Maximum number of iterations
155-
- `forcing`: Maximum forcing term for inexact Newton.
156-
If `nothing` an exact Newton method is used.
207+
208+
$(KWARGS_DOCS)
157209
"""
158210
function newton_krylov!(
159211
F!, u::AbstractArray, res::AbstractArray;

test/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
33
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
44
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
5+
NewtonKrylov = "0be81120-40bf-4f8b-adf0-26103efb66f1"
6+
7+
[sources.NewtonKrylov]
8+
path = ".."

0 commit comments

Comments
 (0)