@@ -101,47 +101,67 @@ function multroot(p::Polynomials.StandardBasisPolynomial{T}; verbose=false,
101
101
102
102
end
103
103
104
- # The multiplicity structure, `l`, gives rise to a pejorative manifold `Πₗ = {Gₗ(z) | z∈ Cᵐ}`.
105
- function pejorative_manifold (p:: Polynomials.StandardBasisPolynomial{T} ;
104
+ # The multiplicity structure, `l`, gives rise to a pejorative manifold
105
+ # `Πₗ = {Gₗ(z) | z ∈ Cᵐ}`. This first finds the approximate roots, then
106
+ # finds the multiplicity structure
107
+ function pejorative_manifold (p:: Polynomials.StandardBasisPolynomial{T,X} ;
106
108
θ = 1e-8 , # zero singular-value threshold
107
109
ρ = 1e-10 , # initial residual tolerance
108
110
ϕ = 100 # residual growth factor
109
- ) where {T}
110
- p₂ = norm (p, 2 )
111
- u, v, w, ρⱼ, κ = Polynomials. ngcd (p, derivative (p);
112
- satol = θ * p₂, srtol = zero (real (T)),
113
- atol = ρ * p₂, rtol = zero (real (T))
114
- )
111
+ ) where {T,X}
112
+
113
+ S = float (T)
114
+ u = Polynomials. PnPolynomial {S,X} (S .(coeffs (p)))
115
+
116
+ nu₂ = norm (u, 2 )
117
+ θ′, ρ′ = θ * nu₂, ρ * nu₂
118
+
119
+ u, v, w, ρⱼ, κ = Polynomials. ngcd (u, derivative (u);
120
+ satol = θ′, srtol = zero (real (T)),
121
+ atol = ρ′, rtol = zero (real (T))
122
+ )
123
+ ρⱼ /= nu₂
115
124
116
125
zs = roots (v)
126
+ ls = pejorative_manifold_multiplicities (u,
127
+ zs, ρⱼ,
128
+ θ, ρ, ϕ)
129
+ zs, ls
130
+ end
131
+
132
+
133
+
134
+ function pejorative_manifold_multiplicities (u:: Polynomials.PnPolynomial{T} ,
135
+ zs, ρⱼ,
136
+ θ, ρ, ϕ) where {T}
117
137
nrts = length (zs)
118
138
ls = ones (Int, nrts)
119
- λ = ϕ
139
+
120
140
while ! Polynomials. isconstant (u)
121
141
122
142
nu₂ = norm (u,2 )
123
- θ′ = θ * nu₂
124
- ρ′ = max (ρ, ϕ * ρⱼ) # paper uses just latter
143
+ θ = θ * nu₂
144
+ ρ = max (ρ, ϕ * ρⱼ)
145
+ ρ′ = ρ * nu₂
125
146
u, v, w, ρⱼ, κ = Polynomials. ngcd (u, derivative (u),
126
- satol = θ′ ,
127
- atol = ρ′,
128
- minⱼ = degree (u) - nrts
147
+ satol = θ, srtol = zero ( real (T)) ,
148
+ atol = ρ′, rtol = zero ( real (T)) ,
149
+ minⱼ = degree (u) - nrts
129
150
)
130
-
131
- rts = roots (v)
132
- nrts = length (rts)
133
-
134
- for z in rts
135
- tmp, ind = findmin (abs .(zs .- z))
151
+ ρⱼ /= nu₂
152
+ nrts = degree (v)
153
+ for z ∈ roots (v)
154
+ _, ind = findmin (abs .(zs .- z))
136
155
ls[ind] += 1
137
156
end
138
157
139
158
end
140
159
141
- zs, ls # estimate for roots, multiplicities
160
+ ls
142
161
143
162
end
144
163
164
+
145
165
"""
146
166
pejorative_root(p, zs, ls; kwargs...)
147
167
@@ -266,10 +286,10 @@ cond_zl(p::AbstractPolynomial, zs::Vector{S}, ls) where {S} = cond_zl(reverse(c
266
286
267
287
function cond_zl (p, zs:: Vector{S} , ls) where {S}
268
288
J = zeros (S, sum (ls), length (zs))
269
- W = diagm (0 => [min (1 , 1 / abs (aᵢ)) for aᵢ in p[2 : end ]])
270
289
evalJ! (J, zs, ls)
271
- _,R = qr (W* J)
272
- σ = Polynomials. NGCD. smallest_singular_value (UpperTriangular (R))
290
+ W = diagm (0 => [min (1 , 1 / abs (aᵢ)) for aᵢ in p[2 : end ]])
291
+
292
+ σ = Polynomials. NGCD. smallest_singular_value (W* J)
273
293
1 / σ
274
294
end
275
295
0 commit comments