Skip to content

Commit 338df6d

Browse files
authored
Merge pull request #625 from JuliaHomotopyContinuation/nid_performance_update
use in-place evaluation
2 parents 7ff07cd + 4797c74 commit 338df6d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/numerical_irreducible_decomposition.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ mutable struct RegenerationCache{Sys<:AbstractSystem}
140140
As::Vector
141141
bs::Vector
142142
x0::Vector
143+
y0::Vector
144+
y::Vector
143145
U::UniquePoints
144146

145147
Fᵢ::Sys
@@ -157,12 +159,20 @@ end
157159
function RegenerationCache(Fᵢ, u, n, codim, EO, TO, progress)
158160
As = [zeros(ComplexF64, n + 1 - i, n + 1) for i = 0:codim]
159161
bs = [zeros(ComplexF64, n + 1 - i) for i = 0:codim]
160-
x0 = [zeros(ComplexF64, n); 0.0]
162+
x0 = zeros(ComplexF64, n + 1)
163+
y0 = zeros(ComplexF64, length(Fᵢ))
164+
y = zeros(ComplexF64, length(Fᵢ))
161165
U = UniquePoints(x0, 0)
162166

163-
RegenerationCache(As, bs, x0, U, Fᵢ, u, n, 0, codim, EO, TO, progress)
167+
RegenerationCache(As, bs, x0, y0, y, U, Fᵢ, u, n, 0, codim, EO, TO, progress)
168+
end
169+
function update_Fᵢ!(cache, Fᵢ)
170+
cache.Fᵢ = Fᵢ
171+
cache.y0 = zeros(ComplexF64, length(Fᵢ))
172+
cache.y = zeros(ComplexF64, length(Fᵢ))
173+
174+
nothing
164175
end
165-
update_Fᵢ!(cache, Fᵢ) = cache.Fᵢ = Fᵢ
166176
update_i!(cache, i) = cache.i = i
167177
function update_x0!(x0)
168178
for i = 1:length(x0)
@@ -543,6 +553,8 @@ function is_contained!(X, Y, F, cache)
543553
tracker_options = cache.tracker_options
544554
endgame_options = cache.endgame_options
545555
x0 = cache.x0
556+
y0 = cache.y0
557+
y = cache.y
546558

547559

548560
# main idea: for every x∈X we take a linear space L with codim(L)=dim(Y) through p and move the points in Y to L. Then, we check if the computed points contain x. If yes, return true, else return false.
@@ -577,7 +589,9 @@ function is_contained!(X, Y, F, cache)
577589
# first check
578590
update_x0!(x0)
579591
x0 = norm(x, Inf) .* x0
580-
if norm(F(x), Inf) > 1e-2 * norm(F(x0), Inf)
592+
evaluate!(y0, F, x0)
593+
evaluate!(y, F, x)
594+
if norm(y, Inf) > 1e-2 * norm(y0, Inf)
581595
return false
582596
end
583597

0 commit comments

Comments
 (0)