Skip to content

Commit a7dfe61

Browse files
committed
add additional check in is_contained!
1 parent 73b7a05 commit a7dfe61

File tree

1 file changed

+50
-32
lines changed

1 file changed

+50
-32
lines changed

src/numerical_irreducible_decomposition.jl

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,42 @@ function remove_points!(
252252
nothing
253253
end
254254

255+
function set_up_linear_spaces(LX, LY)
256+
257+
n = ambient_dim(LY)
258+
mX = codim(LX)
259+
mY = codim(LY)
260+
k = codim(LY) - codim(LX)
261+
262+
# to compute linear spaces through the points in X we first set up
263+
# a matrix-vector pair of the correct size mY×n
264+
A = zeros(ComplexF64, mY, n)
265+
b = zeros(ComplexF64, mY)
266+
267+
# since we have used a subset of the equations for Y also for X,
268+
# we can reuse them
269+
AX = extrinsic(LX).A
270+
bX = extrinsic(LX).b
271+
272+
# the equation for u = 0
273+
A[1, n] = 1.0
274+
# new equations
275+
for i = 2:(k+1)
276+
for j = 1:n
277+
A[i, j] = randn(ComplexF64)
278+
end
279+
end
280+
# equations from X, the overlap in linear equations is in the *last* mx-1 equations
281+
for i = 2:mX
282+
= k + i
283+
for j = 1:n
284+
A[ℓ, j] = AX[i, j]
285+
end
286+
b[ℓ] = bX[i]
287+
end
288+
289+
A, b
290+
end
255291

256292
function is_tracked_to_x(x, X, P, A, b, tracker, U, progress)
257293
# set up the corresponding LinearSubspace L
@@ -291,17 +327,15 @@ function is_contained!(X, Y, F, endgame_options, tracker_options, progress, seed
291327

292328
LX = linear_subspace(X)
293329
LY = linear_subspace(Y)
294-
mX = codim(LX)
295-
mY = codim(LY)
296330
n = ambient_dim(LY)
297-
k = mY - mX # k≥0 iff dim X ≤ dim Y
331+
k = codim(LY) - codim(LX) # k≥0 iff dim X ≤ dim Y
298332

299333
if k < 0 || length(points(Y)) == 0 || length(points(X)) == 0
300334
# if dim X > dim Y return only false
301335
out = falses(length(points(X)))
302336
else
303337
# setup
304-
P = points(Y)
338+
P = points(Y)
305339
Hom = linear_subspace_homotopy(F, LY, LY)
306340
tracker = EndgameTracker(
307341
Hom;
@@ -310,40 +344,24 @@ function is_contained!(X, Y, F, endgame_options, tracker_options, progress, seed
310344
)
311345
U = UniquePoints(first(P), 0)
312346

313-
# to compute linear spaces through the points in X we first set up
314-
# a matrix-vector pair of the correct size mY×n
315-
A = zeros(ComplexF64, mY, n)
316-
b = zeros(ComplexF64, mY)
317-
318-
# since we have used a subset of the equations for Y also for X,
319-
# we can reuse them
320-
AX = extrinsic(LX).A
321-
bX = extrinsic(LX).b
322-
323-
# the equation for u = 0
324-
A[1, n] = 1.0
325-
# new equations
326-
for i = 2:(k+1)
327-
for j = 1:n
328-
A[i, j] = randn(ComplexF64)
329-
end
330-
end
331-
# equations from X, the overlap in linear equations is in the *last* mx-1 equations
332-
for i = 2:mX
333-
= k + i
334-
for j = 1:n
335-
A[ℓ, j] = AX[i, j]
336-
end
337-
b[ℓ] = bX[i]
338-
end
339-
340347
# now we loop over the points in X and check if they are contained in Y
348+
A, b = set_up_linear_spaces(LX, LY)
341349
out = map(points(X)) do x
342-
# first, adjust the linear equations so that they are satisfies by x
350+
351+
# first check
352+
x0 = randn(ComplexF64, n)
353+
LA.normalize!(x0)
354+
x0 = norm(x, Inf) .* x0
355+
if norm(F(x), Inf) > 1e-2 * norm(F(x0), Inf)
356+
return false
357+
end
358+
359+
# second check
343360
for i = 2:(k+1)
344361
b[i] = sum(A[i, j] * x[j] for j = 1:n)
345362
end
346363
is_tracked_to_x(x, X, P, A, b, tracker, U, progress)
364+
347365
end
348366
end
349367

0 commit comments

Comments
 (0)