Skip to content

Commit aff1f83

Browse files
committed
fix a bug in nid
1 parent 5b5221b commit aff1f83

File tree

3 files changed

+57
-15
lines changed

3 files changed

+57
-15
lines changed

docs/src/witness_sets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ NumericalIrreducibleDecomposition
4242
```
4343

4444
```@docs
45-
n_components
45+
ncomponents
4646
witness_sets
4747
degrees
4848
```

src/numerical_irreducible_decomposition.jl

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export NumericalIrreducibleDecomposition,
44
regeneration,
55
witness_sets,
66
decompose,
7-
n_components,
7+
ncomponents,
88
seed
99

1010
"""
@@ -147,7 +147,7 @@ This is the core routine of the regeneration algorithm. It intersects a set of [
147147
"""
148148
function intersect_with_hypersurface!(
149149
W::WitnessPoints{T1,T2,Vector{ComplexF64}},
150-
X::WitnessPoints{T3,T4,Vector{ComplexF64}},
150+
X::Union{WitnessPoints{T3,T4,Vector{ComplexF64}},Nothing},
151151
F::AS,
152152
H::WitnessSet{T5,T6,Vector{ComplexF64}},
153153
u::Variable,
@@ -174,6 +174,11 @@ function intersect_with_hypersurface!(
174174
deleteat!(P, m)
175175
update_progress!(progress, W)
176176

177+
if isnothing(X)
178+
return nothing
179+
end
180+
181+
177182
# Step 2:
178183
# the points in P_next are used as starting points for a homotopy.
179184
# where u^d-1 (u is the extra variable in u-regeneration) is deformed into g
@@ -203,10 +208,12 @@ function intersect_with_hypersurface!(
203208

204209
# here comes the loop for tracking
205210
l_start = length(start)
211+
206212
for (i, s) in enumerate(start)
207213
p = s[1]
208214
p[end] = s[2] # the last entry of s[1] is zero. we replace it with a d-th root of unity.
209215

216+
210217
res = track(tracker, p, 1)
211218
if is_success(res) && is_finite(res) && is_nonsingular(res)
212219
new = copy(tracker.state.solution)
@@ -217,6 +224,7 @@ function intersect_with_hypersurface!(
217224
end
218225

219226

227+
220228
nothing
221229
end
222230

@@ -330,6 +338,7 @@ function is_contained!(
330338
end
331339
# check if x is among the points in U
332340
_, added = add!(U, x, 0)
341+
333342
if added
334343
return false
335344
else
@@ -556,10 +565,28 @@ function regeneration!(
556565
)
557566
update_progress!(progress, W)
558567
update_progress!(progress, X)
568+
569+
elseif i >= n && k == n
570+
intersect_with_hypersurface!(
571+
W,
572+
nothing,
573+
Fᵢ,
574+
Hᵢ,
575+
u,
576+
endgame_options,
577+
tracker_options,
578+
progress,
579+
seed,
580+
)
581+
update_progress!(progress, W)
582+
559583
end
560584
end
561585

586+
587+
562588
Fᵢ = fixed(System(f[1:i], variables = vars), compile = false)
589+
563590
# after the first loop that takes care of intersecting with Hᵢ
564591
# we now check if we have added points that are already contained in
565592
# witness sets of higher dimension.
@@ -1110,13 +1137,13 @@ witness_sets(N::NumericalIrreducibleDecomposition, dim::Int) = witness_sets(N, [
11101137
seed(N::NumericalIrreducibleDecomposition) = N.seed
11111138

11121139
"""
1113-
n_components(N::NumericalIrreducibleDecomposition;
1140+
ncomponents(N::NumericalIrreducibleDecomposition;
11141141
dims::Union{Vector{Int},Nothing} = nothing)
11151142
11161143
Returns the total number of components in `N`.
11171144
`dims` specifies the dimensions that should be considered.
11181145
"""
1119-
function n_components(
1146+
function ncomponents(
11201147
N::NumericalIrreducibleDecomposition;
11211148
dims::Union{Vector{Int},Nothing} = nothing,
11221149
)
@@ -1134,7 +1161,7 @@ function n_components(
11341161

11351162
out
11361163
end
1137-
n_components(N::NumericalIrreducibleDecomposition, dim::Int) = n_components(N, dims = [dim])
1164+
ncomponents(N::NumericalIrreducibleDecomposition, dim::Int) = ncomponents(N, dims = [dim])
11381165

11391166
"""
11401167

test/nid_test.jl

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
@test isa(N3, NumericalIrreducibleDecomposition)
5656

5757
# number of components
58-
@test n_components(N3) == 4
59-
@test n_components(N3, dims = [1, 2]) == 3
60-
@test n_components(N3, 1) == 2
58+
@test ncomponents(N3) == 4
59+
@test ncomponents(N3, dims = [1, 2]) == 3
60+
@test ncomponents(N3, 1) == 2
6161
end
6262

6363
@testset "Hypersurface of degree 5" begin
@@ -67,7 +67,7 @@
6767

6868
N_Hyp = numerical_irreducible_decomposition(Hyp)
6969
@test degrees(N_Hyp) == Dict(3 => [5])
70-
@test n_components(N_Hyp) == 1
70+
@test ncomponents(N_Hyp) == 1
7171
end
7272

7373
@testset "Curve of degree 6" begin
@@ -78,7 +78,7 @@
7878

7979
N_Curve = nid(Curve)
8080
@test degrees(N_Curve) == Dict(1 => [6])
81-
@test n_components(N_Curve) == 1
81+
@test ncomponents(N_Curve) == 1
8282
end
8383

8484
@testset "Overdetermined Test" begin
@@ -88,7 +88,7 @@
8888

8989
N_TwistedCubicSphere = nid(TwistedCubicSphere)
9090
@test degrees(N_TwistedCubicSphere) == Dict(0 => [3])
91-
@test n_components(N_TwistedCubicSphere) == 1
91+
@test ncomponents(N_TwistedCubicSphere) == 1
9292
end
9393

9494
@testset "Three Lines" begin
@@ -101,7 +101,7 @@
101101

102102
N_ThreeLines = nid(ThreeLines)
103103
@test degrees(N_ThreeLines) == Dict(1 => [1; 1; 1])
104-
@test n_components(N_ThreeLines) == 3
104+
@test ncomponents(N_ThreeLines) == 3
105105
end
106106

107107
@testset "Bricard6R" begin
@@ -198,7 +198,7 @@
198198

199199
N_Bricard6R = nid(Bricard6R)
200200
@test degrees(N_Bricard6R) == Dict(1 => [8])
201-
@test n_components(N_Bricard6R) == 1
201+
@test ncomponents(N_Bricard6R) == 1
202202
end
203203

204204
@testset "ACR" begin
@@ -242,6 +242,21 @@
242242
end
243243

244244

245+
@testset "Union of a sphere, a line, and a point" begin
246+
@var x, y, z
247+
248+
S = [x^2 + y^2 + z^2 - 1] #The sphere
249+
L = [2 * x - z, 2 * y - z] #The line (t,t,2t)
250+
P = [x + y + 2 * z - 4, y - z, x - z] #The point (1,1,1)
251+
252+
F = System([s * l * p for s in S for l in L for p in P])
253+
254+
seed = rand(UInt32)
255+
NID = numerical_irreducible_decomposition(F; seed = 0x7a4845b9)
256+
257+
@test ncomponents(NID, 0) == 1
258+
end
259+
245260
# @testset "426" begin
246261
# ### Example thanks to Julian Vill
247262
# @var a, b, c, d, e
@@ -304,7 +319,7 @@
304319
# endgame_options = EndgameOptions(; sing_accuracy = 1e-10),
305320
# )
306321

307-
# @test n_components(N) == 1
322+
# @test ncomponents(N) == 1
308323
# @test degrees(N) == Dict(2 => [426])
309324
# end
310325
end

0 commit comments

Comments
 (0)