@@ -252,6 +252,42 @@ function remove_points!(
252
252
nothing
253
253
end
254
254
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
255
291
256
292
function is_tracked_to_x (x, X, P, A, b, tracker, U, progress)
257
293
# set up the corresponding LinearSubspace L
@@ -291,17 +327,15 @@ function is_contained!(X, Y, F, endgame_options, tracker_options, progress, seed
291
327
292
328
LX = linear_subspace (X)
293
329
LY = linear_subspace (Y)
294
- mX = codim (LX)
295
- mY = codim (LY)
296
330
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
298
332
299
333
if k < 0 || length (points (Y)) == 0 || length (points (X)) == 0
300
334
# if dim X > dim Y return only false
301
335
out = falses (length (points (X)))
302
336
else
303
337
# setup
304
- P = points (Y)
338
+ P = points (Y)
305
339
Hom = linear_subspace_homotopy (F, LY, LY)
306
340
tracker = EndgameTracker (
307
341
Hom;
@@ -310,40 +344,24 @@ function is_contained!(X, Y, F, endgame_options, tracker_options, progress, seed
310
344
)
311
345
U = UniquePoints (first (P), 0 )
312
346
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
-
340
347
# 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)
341
349
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
343
360
for i = 2 : (k+ 1 )
344
361
b[i] = sum (A[i, j] * x[j] for j = 1 : n)
345
362
end
346
363
is_tracked_to_x (x, X, P, A, b, tracker, U, progress)
364
+
347
365
end
348
366
end
349
367
0 commit comments