@@ -204,8 +204,6 @@ function ngcd(p::PnPolynomial{T,X},
204
204
minⱼ = - 1
205
205
) where {T, X}
206
206
207
- verbose = false
208
-
209
207
m,n = length (p)- 1 , length (q)- 1
210
208
(m == 1 || n == 0 ) && return trivial_gcd (p, q)
211
209
@@ -254,20 +252,20 @@ function ngcd(p::PnPolynomial{T,X},
254
252
xx = view (x, 1 : nc)
255
253
λ = norm (Q,Inf )* norm (R,Inf )
256
254
σ₋₁ = smallest_singular_value! (xx, V, ρ * sqrt (m - j + 1 ), λ* ϵₘ)
257
- verbose && @show j, σ₋₁, ρ * sqrt (m - j + 1 )
255
+ # @show j, σ₋₁, ρ * sqrt(m - j + 1)
258
256
259
257
# Lemma 7.1: If (p,q) is w/in ϵ of P^k_{mn} then σ₋₁ < ϵ√(m-j+1)
260
258
if σ₋₁ ≤ ρ * sqrt (m - j + 1 )
261
259
# candidate for degree; refine u₀, vₒ, w₀ to see if ρ < ϵ
262
260
if iszero (σ₋₁)
263
- @info " Determinant is zero, which shouldn't be the case. Treat results with scrutiny "
261
+ # determinant is 0
264
262
u, v, w = initial_uvw (Val (:iszero ), j, p, q, xx)
265
263
else
266
264
u, v, w = initial_uvw (Val (:ispossible ), j, p, q, xx)
267
265
end
268
266
ϵₖ, κ = refine_uvw! (u, v, w, p, q, uv, uw)
269
267
ϵ = max (atol, npq₂ * κ * rtol)
270
- verbose && @show ϵₖ, ϵ
268
+ # @show ϵₖ, ϵ
271
269
if ϵₖ ≤ ϵ
272
270
return (u= u, v= v, w= w, Θ= ϵₖ, κ= κ)
273
271
end
@@ -430,28 +428,29 @@ function initial_uvw(::Val{:ispossible}, j, p::P, q::Q, x) where {T,X,
430
428
431
429
end
432
430
433
- # find u₎ , v₀. w₀ when R is singular
431
+ # find u₀ , v₀. w₀ when R is singular.
434
432
function initial_uvw (:: Val{:iszero} , j, p:: P , q:: Q , x) where {T,X,
435
433
P<: PnPolynomial{T,X} ,
436
434
Q<: PnPolynomial{T,X} }
437
435
438
436
m,n = length (p)- 1 , length (q)- 1
439
- S = [convmtx (p, n- j+ 1 ) convmtx (q, m- j+ 1 )]
440
-
437
+ S = SylvesterMatrix (p,q,j)
441
438
F = qr (S)
442
439
R = UpperTriangular (F. R)
443
440
444
441
if iszero (det (R))
445
442
x .= eigvals (R)[:,1 ]
446
443
else
447
- x .= ones (T, size (R,2 ))
448
- ldiv! (R' , x)
449
- x ./= norm (x,2 )
450
- ldiv! (R, x)
451
- x ./= norm (x)
444
+ rand! (x)
445
+ smallest_singular_value! (x, R)
446
+ # x .= ones(T, size(R,2))
447
+ # ldiv!(R', x)
448
+ # x ./= norm(x,2)
449
+ # ldiv!(R, x)
450
+ # x ./= norm(x)
452
451
end
453
452
454
- w = P (x[1 : n- j+ 1 ])
453
+ w = P (x[1 : n- j+ 1 ]) # ordering of S is not interlaced
455
454
v = P (- x[(n- j+ 2 ): end ])
456
455
457
456
u = solve_u (v,w,p,q,j)
735
734
736
735
function SylvesterMatrix (p, q, j)
737
736
m, n = length (p)- 1 , length (q) - 1
738
- Sₓ = hcat (convmtx (p, n- j + 1 ), convmtx (q, m- j + 1 ))
737
+ Sₓ = hcat (convmtx (p, n - j + 1 ), convmtx (q, m - j + 1 ))
739
738
end
740
739
741
740
# # ----
0 commit comments