@@ -4,6 +4,16 @@ struct Inplace <: HomotopySystemVariant end
4
4
struct OutOfPlace <: HomotopySystemVariant end
5
5
struct Scalar <: HomotopySystemVariant end
6
6
7
+ """
8
+ $(TYPEDEF)
9
+
10
+ A simple struct that wraps a polynomial function which takes complex input and returns
11
+ complex output in a form that supports automatic differentiation. If the wrapped
12
+ function if ``f: \\ mathbb{C}^n \\ rightarrow \\ mathbb{C}^n`` then it is assumed
13
+ the input arrays are real-valued and have length ``2n``. They are `reinterpret`ed
14
+ into complex arrays and passed into the function. This struct has an in-place signature
15
+ regardless of the signature of ``f``.
16
+ """
7
17
@concrete struct ComplexJacobianWrapper{variant <: HomotopySystemVariant }
8
18
f
9
19
end
@@ -32,14 +42,49 @@ function (cjw::ComplexJacobianWrapper{Scalar})(u::AbstractVector{T}, x::Abstract
32
42
return u
33
43
end
34
44
45
+ """
46
+ $(TYPEDEF)
47
+
48
+ A struct which implements the `HomotopyContinuation.AbstractSystem` interface for
49
+ polynomial systems specified using `NonlinearProblem`.
50
+
51
+ # Fields
52
+
53
+ $(FIELDS)
54
+ """
35
55
@concrete struct HomotopySystemWrapper{variant <: HomotopySystemVariant } <: HC.AbstractSystem
56
+ """
57
+ The wrapped polynomial function.
58
+ """
36
59
f
60
+ """
61
+ The jacobian function, if provided to the `NonlinearProblem` being solved. Otherwise,
62
+ a `ComplexJacobianWrapper` wrapping `f` used for automatic differentiation.
63
+ """
37
64
jac
65
+ """
66
+ The parameter object.
67
+ """
38
68
p
69
+ """
70
+ The ADType for automatic differentiation.
71
+ """
39
72
autodiff
73
+ """
74
+ The result from `DifferentiationInterface.prepare_jacobian`.
75
+ """
40
76
prep
77
+ """
78
+ HomotopyContinuation.jl's symbolic variables for the system.
79
+ """
41
80
vars
81
+ """
82
+ The `TaylorSeries.Taylor1` objects used to compute the taylor series of `f`.
83
+ """
42
84
taylorvars
85
+ """
86
+ Preallocated intermediate buffers used for calculating the jacobian.
87
+ """
43
88
jacobian_buffers
44
89
end
45
90
@@ -168,9 +213,38 @@ function HC.ModelKit.taylor!(u::AbstractVector, ::Val{N}, sys::HomotopySystemWra
168
213
return u
169
214
end
170
215
216
+ """
217
+ $(TYPEDEF)
218
+
219
+ A `HomotopyContinuation.AbstractHomotopy` which uses an inital guess ``x_0`` to construct
220
+ the start system for the homotopy. The homotopy is
221
+
222
+ ```math
223
+ \\ begin{aligned}
224
+ H(x, t) &= t * (F(x) - F(x_0)) + (1 - t) * F(x)
225
+ &= F(x) - t * F(x_0)
226
+ \\ end{aligned}
227
+ ```
228
+
229
+ Where ``F: \\ mathbb{R}^n \\ rightarrow \\ mathbb{R}^n`` is the polynomial system and
230
+ ``x_0 \\ in \\ mathbb{R}^n`` is the guess provided to the `NonlinearProblem`.
231
+
232
+ # Fields
233
+
234
+ $(TYPEDFIELDS)
235
+ """
171
236
@concrete struct GuessHomotopy <: HC.AbstractHomotopy
237
+ """
238
+ The `HomotopyContinuation.AbstractSystem` to solve.
239
+ """
172
240
sys <: HC.AbstractSystem
241
+ """
242
+ The residual of the initial guess, i.e. ``F(x_0)``.
243
+ """
173
244
fu0
245
+ """
246
+ A preallocated `TaylorVector` for efficient `taylor!` implementation.
247
+ """
174
248
taylorbuffer:: HC.ModelKit.TaylorVector{5, ComplexF64}
175
249
end
176
250
180
254
181
255
Base. size (h:: GuessHomotopy ) = size (h. sys)
182
256
183
- # H(x, t) = (1 - t) * F(x) + t * (F(x) - F(x0))
184
- # = F(x) - t * F(x0)
185
257
function HC. ModelKit. evaluate! (u, h:: GuessHomotopy , x, t, p = nothing )
186
258
HC. ModelKit. evaluate! (u, h. sys, x, p)
187
259
@inbounds for i in eachindex (u)
0 commit comments