@@ -4,6 +4,16 @@ struct Inplace <: HomotopySystemVariant end
44struct  OutOfPlace <:  HomotopySystemVariant  end 
55struct  Scalar <:  HomotopySystemVariant  end 
66
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+ """ 
717@concrete  struct  ComplexJacobianWrapper{variant <:  HomotopySystemVariant }
818    f
919end 
@@ -32,14 +42,49 @@ function (cjw::ComplexJacobianWrapper{Scalar})(u::AbstractVector{T}, x::Abstract
3242    return  u
3343end 
3444
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+ """ 
3555@concrete  struct  HomotopySystemWrapper{variant <:  HomotopySystemVariant } <:  HC.AbstractSystem 
56+     """ 
57+     The wrapped polynomial function. 
58+     """  
3659    f
60+     """ 
61+     The jacobian function, if provided to the `NonlinearProblem` being solved. Otherwise, 
62+     a `ComplexJacobianWrapper` wrapping `f` used for automatic differentiation. 
63+     """  
3764    jac
65+     """ 
66+     The parameter object. 
67+     """  
3868    p
69+     """ 
70+     The ADType for automatic differentiation. 
71+     """  
3972    autodiff
73+     """ 
74+     The result from `DifferentiationInterface.prepare_jacobian`. 
75+     """  
4076    prep
77+     """ 
78+     HomotopyContinuation.jl's symbolic variables for the system. 
79+     """  
4180    vars
81+     """ 
82+     The `TaylorSeries.Taylor1` objects used to compute the taylor series of `f`. 
83+     """  
4284    taylorvars
85+     """ 
86+     Preallocated intermediate buffers used for calculating the jacobian. 
87+     """  
4388    jacobian_buffers
4489end 
4590
@@ -168,9 +213,38 @@ function HC.ModelKit.taylor!(u::AbstractVector, ::Val{N}, sys::HomotopySystemWra
168213    return  u
169214end 
170215
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+ """ 
171236@concrete  struct  GuessHomotopy <:  HC.AbstractHomotopy 
237+     """ 
238+     The `HomotopyContinuation.AbstractSystem` to solve. 
239+     """  
172240    sys <:  HC.AbstractSystem 
241+     """ 
242+     The residual of the initial guess, i.e. ``F(x_0)``. 
243+     """  
173244    fu0
245+     """ 
246+     A preallocated `TaylorVector` for efficient `taylor!` implementation. 
247+     """  
174248    taylorbuffer:: HC.ModelKit.TaylorVector{5, ComplexF64} 
175249end 
176250
180254
181255Base. size (h:: GuessHomotopy ) =  size (h. sys)
182256
183- #  H(x, t) = (1 - t) * F(x) + t * (F(x) - F(x0))
184- #          = F(x) - t * F(x0)
185257function  HC. ModelKit. evaluate! (u, h:: GuessHomotopy , x, t, p =  nothing )
186258    HC. ModelKit. evaluate! (u, h. sys, x, p)
187259    @inbounds  for  i in  eachindex (u)
0 commit comments