@@ -22,12 +22,19 @@ import HomotopyContinuation
2222 0 ~ x^ 2 + 4 x + 4
2323 0 ~ y * z + 4 x^ 2 ]
2424 @mtkbuild sys = NonlinearSystem (eqs)
25- prob = HomotopyContinuationProblem (sys, [x => 1.0 , y => 1.0 , z => 1.0 ], [])
25+ u0 = [x => 1.0 , y => 1.0 , z => 1.0 ]
26+ prob = HomotopyContinuationProblem (sys, u0)
2627 @test prob[x] == prob[y] == prob[z] == 1.0
2728 @test prob[x + y] == 2.0
2829 sol = solve (prob; threading = false )
2930 @test SciMLBase. successful_retcode (sol)
3031 @test norm (sol. resid)≈ 0.0 atol= 1e-10
32+
33+ prob2 = NonlinearProblem (sys, u0)
34+ @test prob2 isa HomotopyContinuationProblem
35+ sol = solve (prob2; threading = false )
36+ @test SciMLBase. successful_retcode (sol)
37+ @test norm (sol. resid)≈ 0.0 atol= 1e-10
3138end
3239
3340struct Wrapper
9299 " Exponent" , " not an integer" , " not a polynomial" ] HomotopyContinuationProblem (
93100 sys, [])
94101 @test MTK. safe_HomotopyContinuationProblem (sys, []) isa MTK. NotPolynomialError
102+ @test NonlinearProblem (sys, []) isa NonlinearProblem
103+
95104 @mtkbuild sys = NonlinearSystem ([x^ x - x ~ 0 ])
96105 @test_throws [" Cannot convert" , " Unable" , " symbolically solve" ,
97106 " Exponent" , " unknowns" , " not a polynomial" ] HomotopyContinuationProblem (
98107 sys, [])
99108 @test MTK. safe_HomotopyContinuationProblem (sys, []) isa MTK. NotPolynomialError
109+ @test NonlinearProblem (sys, []) isa NonlinearProblem
100110 @mtkbuild sys = NonlinearSystem ([((x^ 2 ) / sin (x))^ 2 + x ~ 0 ])
101111 @test_throws [" Cannot convert" , " both polynomial" , " non-polynomial" ,
102112 " recognized" , " sin" , " not a polynomial" ] HomotopyContinuationProblem (
103113 sys, [])
104114 @test MTK. safe_HomotopyContinuationProblem (sys, []) isa MTK. NotPolynomialError
115+ @test NonlinearProblem (sys, []) isa NonlinearProblem
105116
106117 @variables y = 2.0
107118 @mtkbuild sys = NonlinearSystem ([x^ 2 + y^ 2 + 2 ~ 0 , y ~ sin (x)])
108119 @test_throws [" Cannot convert" , " recognized" , " sin" , " not a polynomial" ] HomotopyContinuationProblem (
109120 sys, [])
110121 @test MTK. safe_HomotopyContinuationProblem (sys, []) isa MTK. NotPolynomialError
122+ @test NonlinearProblem (sys, []) isa NonlinearProblem
111123
112124 @mtkbuild sys = NonlinearSystem ([x^ 2 + y^ 2 - 2 ~ 0 , sin (x + y) ~ 0 ])
113125 @test_throws [" Cannot convert" , " function of multiple unknowns" ] HomotopyContinuationProblem (
114126 sys, [])
115127 @test MTK. safe_HomotopyContinuationProblem (sys, []) isa MTK. NotPolynomialError
128+ @test NonlinearProblem (sys, []) isa NonlinearProblem
116129
117130 @mtkbuild sys = NonlinearSystem ([sin (x)^ 2 + 1 ~ 0 , cos (y) - cos (x) - 1 ~ 0 ])
118131 @test_throws [" Cannot convert" , " multiple non-polynomial terms" , " same unknown" ] HomotopyContinuationProblem (
119132 sys, [])
120133 @test MTK. safe_HomotopyContinuationProblem (sys, []) isa MTK. NotPolynomialError
134+ @test NonlinearProblem (sys, []) isa NonlinearProblem
121135
122136 @mtkbuild sys = NonlinearSystem ([sin (x^ 2 )^ 2 + sin (x^ 2 ) - 1 ~ 0 ])
123137 @test_throws [" import Nemo" ] HomotopyContinuationProblem (sys, [])
124138 @test MTK. safe_HomotopyContinuationProblem (sys, []) isa MTK. NotPolynomialError
139+ @test NonlinearProblem (sys, []) isa NonlinearProblem
125140end
126141
127142import Nemo
0 commit comments