Skip to content

Commit 9622662

Browse files
committed
more cleanup
1 parent 6edc199 commit 9622662

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/polynomials/multroot.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function pejorative_manifold(p::Polynomials.StandardBasisPolynomial{T};
133133

134134
for z in rts
135135
tmp, ind = findmin(abs.(zs .- z))
136-
ls[ind] = ls[ind] + 1
136+
ls[ind] += 1
137137
end
138138

139139
end
@@ -212,7 +212,7 @@ function pejorative_root(p, zs::Vector{S}, ls;
212212
@info ("""
213213
The multiplicity count may be in error: the initial guess for the roots failed
214214
to converge to a pejorative root.
215-
""")
215+
""")
216216
return(zₖs)
217217
end
218218

@@ -268,8 +268,8 @@ function cond_zl(p, zs::Vector{S}, ls) where {S}
268268
J = zeros(S, sum(ls), length(zs))
269269
W = diagm(0 => [min(1, 1/abs(aᵢ)) for aᵢ in p[2:end]])
270270
evalJ!(J, zs, ls)
271-
F = qr(W*J)
272-
σ = Polynomials.NGCD.smallest_singular_value(F.R)
271+
_,R = qr(W*J)
272+
σ = Polynomials.NGCD.smallest_singular_value(UpperTriangular(R))
273273
1 / σ
274274
end
275275

src/polynomials/ngcd.jl

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ function ngcd(p::PnPolynomial{T,X},
204204
minⱼ = -1
205205
) where {T, X}
206206

207-
verbose = false
208-
209207
m,n = length(p)-1, length(q)-1
210208
(m == 1 || n == 0) && return trivial_gcd(p, q)
211209

@@ -254,20 +252,20 @@ function ngcd(p::PnPolynomial{T,X},
254252
xx = view(x, 1:nc)
255253
λ = norm(Q,Inf)*norm(R,Inf)
256254
σ₋₁ = smallest_singular_value!(xx, V, ρ * sqrt(m - j + 1), λ*ϵₘ)
257-
verbose && @show j, σ₋₁, ρ * sqrt(m - j + 1)
255+
# @show j, σ₋₁, ρ * sqrt(m - j + 1)
258256

259257
# Lemma 7.1: If (p,q) is w/in ϵ of P^k_{mn} then σ₋₁ < ϵ√(m-j+1)
260258
if σ₋₁ ρ * sqrt(m - j + 1)
261259
# candidate for degree; refine u₀, vₒ, w₀ to see if ρ < ϵ
262260
if iszero(σ₋₁)
263-
@info "Determinant is zero, which shouldn't be the case. Treat results with scrutiny"
261+
# determinant is 0
264262
u, v, w = initial_uvw(Val(:iszero), j, p, q, xx)
265263
else
266264
u, v, w = initial_uvw(Val(:ispossible), j, p, q, xx)
267265
end
268266
ϵₖ, κ = refine_uvw!(u, v, w, p, q, uv, uw)
269267
ϵ = max(atol, npq₂ * κ * rtol)
270-
verbose && @show ϵₖ, ϵ
268+
# @show ϵₖ, ϵ
271269
if ϵₖ ϵ
272270
return (u=u, v=v, w=w, Θ=ϵₖ, κ=κ)
273271
end
@@ -430,28 +428,29 @@ function initial_uvw(::Val{:ispossible}, j, p::P, q::Q, x) where {T,X,
430428

431429
end
432430

433-
# find u, v₀. w₀ when R is singular
431+
# find u, v₀. w₀ when R is singular.
434432
function initial_uvw(::Val{:iszero}, j, p::P, q::Q, x) where {T,X,
435433
P<:PnPolynomial{T,X},
436434
Q<:PnPolynomial{T,X}}
437435

438436
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)
441438
F = qr(S)
442439
R = UpperTriangular(F.R)
443440

444441
if iszero(det(R))
445442
x .= eigvals(R)[:,1]
446443
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)
452451
end
453452

454-
w = P(x[1:n-j+1])
453+
w = P(x[1:n-j+1]) # ordering of S is not interlaced
455454
v = P(-x[(n-j+2):end])
456455

457456
u = solve_u(v,w,p,q,j)
@@ -735,7 +734,7 @@ end
735734

736735
function SylvesterMatrix(p, q, j)
737736
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))
739738
end
740739

741740
## ----

0 commit comments

Comments
 (0)