2626 - 1 0 1 - 2 - 1 0
2727 - 1 0 1 - 2 - 2 - 1
2828 ]
29- @test sort .( SemialgebraicSets. clusterordschur (A, sqrt (eps (Float64)))[2 ]) ==
30- [[2 ], [ 1 , 5 , 6 ]]
29+ clusters = SemialgebraicSets. clusterordschur (A, sqrt (eps (Float64)))[2 ]
30+ @test sort ( sort .(clusters); by = first) == [[1 , 5 , 6 ], [ 2 ]]
3131end
3232
3333function testelements (X, Y; atol = Base. rtoldefault (Float64), kwargs... )
@@ -61,39 +61,43 @@ newton_solver = NewtonTypeDiagonalization()
6161
6262function zero_dimensional_ideal (solver)
6363 Mod. @polyvar x y z
64+
6465 V = @set x == y
6566 @test ! is_zero_dimensional (V)
6667 @test_throws ErrorException iterate (V)
6768 @test_throws ErrorException length (V)
69+
6870 V = @set 4 x^ 2 == - 5 x && 3 x^ 3 == 0 solver
6971 @test V. solver. solver === solver
7072 @test is_zero_dimensional (V)
7173 testelementstypes (V, [[0 ]])
74+
7275 V = @set y == x^ 2 && z == x^ 3 solver
7376 @test ! is_zero_dimensional (V)
74- if solver isa ReorderedSchurMultiplicationMatricesSolver
75- # FIXME NewtonType should cluster, it finds `(0, 0)` 3 times
77+
78+ if ! (solver isa NewtonTypeDiagonalization)
7679 V = @set x^ 3 == 2 x * y && x^ 2 * y == 2 y^ 2 + x solver
7780 @test is_zero_dimensional (V)
7881 testelementstypes (V, [[0 , 0 ]])
7982 end
83+
8084 V = @set x == 1 solver
8185 @test is_zero_dimensional (V)
8286 testelementstypes (V, [[1 ]])
87+
8388 V = @set x == 1 && y == 2 solver
8489 @test is_zero_dimensional (V)
8590 testelementstypes (V, [[1 , 2 ]])
91+
8692 V = @set x == 4 && y^ 2 == x solver
8793 @test is_zero_dimensional (V)
8894 testelementstypes (V, [[4 , 2 ], [4 , - 2 ]])
95+
8996 V = @set x^ 2 + x == 6 && y == x + 1 solver
9097 @test is_zero_dimensional (V)
9198 testelements (V, [[2 , 3 ], [- 3 , - 2 ]])
92- if solver isa ReorderedSchurMultiplicationMatricesSolver
93- # FIXME NewtonType finds:`
94- # [[2, √2], [-3, 0], [-3, 0], [2, -√2]]
95- # The `[-3, 0]` should be removed, it corresponds
96- # `[-3, √3 im]`, `[-3, -√3 im]` which is a complex pair
99+
100+ if ! (solver isa NewtonTypeDiagonalization)
97101 V = @set x^ 2 + x == 6 && y^ 2 == x solver
98102 @test is_zero_dimensional (V)
99103 testelements (V, [[2 , √ 2 ], [2 , -√ 2 ]])
@@ -107,30 +111,37 @@ end
107111
108112function projective_zero_dimensional_ideal (solver)
109113 Mod. @polyvar x y z
114+
110115 V = projective_algebraic_set ([x - y], solver)
111116 @test is_zero_dimensional (V)
112117 testelementstypes (V, [[1 , 1 ]])
118+
113119 V = @set x + y == z solver
114120 V. projective = true
115121 @test ! is_zero_dimensional (V)
122+
116123 V = @set y == 2 x solver
117124 V. projective = true
118125 @test is_zero_dimensional (V)
119126 testelementstypes (V, [[1 , 2 ]])
127+
120128 V = @set x + y == y solver
121129 V. projective = true
122130 @test is_zero_dimensional (V)
123131 testelementstypes (V, [[0 , 1 ]])
132+
124133 V = projective_algebraic_set ([x + y - x])
125134 @test is_zero_dimensional (V)
126- return testelementstypes (V, [[1 , 0 ]])
135+ testelementstypes (V, [[1 , 0 ]])
136+ return
127137end
128138
129139@testset " Projective zero-dimensional ideal" begin
130140 projective_zero_dimensional_ideal (schur_solver)
141+ projective_zero_dimensional_ideal (newton_solver)
131142end
132143
133- @testset " Example 5.1 of CGT97 " begin
144+ function cgt96_e51 (solver)
134145 ɛ = 1e-4
135146 Iɛ = [
136147 1 - ɛ 0
@@ -150,24 +161,33 @@ end
150161 Z Iɛ
151162 ]
152163 α = 0.219
153- testelements (
164+ return testelements (
154165 SemialgebraicSets. _solve_multiplication_matrices (
155166 [A, B],
156167 [α, 1 - α],
157- ReorderedSchurMultiplicationMatricesSolver {Float64} () ,
168+ solver ,
158169 ),
159170 [[1.0 , - 1.0 ], [1.0 , 1.0 ], [- 1.0 , 1.0 ]];
160171 rtol = 1e-7 ,
161172 )
162173end
163174
164- @testset " Example 4.3 of MD95" begin
175+ @testset " Example 5.1 of CGT97" begin
176+ @testset " Schur" begin
177+ cgt96_e51 (schur_solver)
178+ end
179+ # @testset "Newton" begin
180+ # cgt96_e51(newton_solver)
181+ # end
182+ end
183+
184+ function md95_e43 (solver)
165185 Mod. @polyvar x y
166- V = @set x^ 2 + 4 y^ 4 == 4 y^ 2 && 3 x^ 4 + y^ 2 == 5 x^ 3 schur_solver
186+ V = @set x^ 2 + 4 y^ 4 == 4 y^ 2 && 3 x^ 4 + y^ 2 == 5 x^ 3 solver
167187 # This test is tricky because in the schur decomposition, the 4 last eigenvalues are e.g. 3.4e-7, -1.7e-7+3e-7im, -1.7e-7-3e-7im, -6e-16
168188 # the second and third do not seem that close but when the three first are averaged it is very close to zero.
169189 @test is_zero_dimensional (V)
170- testelementstypes (
190+ return testelementstypes (
171191 V,
172192 [
173193 [0.66209555 , 0.935259169 ],
179199 )
180200end
181201
202+ @testset " Example 4.3 of MD95" begin
203+ md95_e43 (schur_solver)
204+ end
205+
182206@testset " Example 5.2 of CGT97" begin
183207 Mod. @polyvar x y z
184208 V =
0 commit comments