Skip to content

Commit

Permalink
Merge pull request #552 from JuliaHomotopyContinuation/fixed
Browse files Browse the repository at this point in the history
Fix method ambiguity and Homotopy interpreter bug
  • Loading branch information
saschatimme committed Jun 27, 2023
2 parents 0b350e6 + 8b2db67 commit c53b387
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/homotopies/mixed_homotopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ ModelKit.evaluate!(u, H::MixedHomotopy, x::AbstractVector, t, p = nothing) =
evaluate!(u, H.compiled, x, t, p)
ModelKit.evaluate_and_jacobian!(u, U, H::MixedHomotopy, x, t, p = nothing) =
evaluate_and_jacobian!(u, U, H.compiled, x, t, p)
ModelKit.taylor!(u, v::Val, H::MixedHomotopy, tx, t, p = nothing) =
ModelKit.taylor!(u, v::Val, H::MixedHomotopy, tx, t, p = nothing, ::Bool = false) =
taylor!(u, v, H.interpreted, tx, t, p)

ModelKit.taylor!(u, v::Val, H::MixedHomotopy, tx, t, ::Bool) =
taylor!(u, v, H.interpreted, tx, t, nothing)
6 changes: 4 additions & 2 deletions src/model_kit/instruction_interpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,12 @@ function execute_taylor_instructions!_impl(K)
instructions = sequence.instructions
is_p_taylor = !isnothing(p) && !isempty(p) && length(p[1]) > 1
is_x_taylor = !isempty(x) && length(x[1]) > 1
if !is_p_taylor && !is_x_taylor
if !is_p_taylor && !is_x_taylor && isnothing(sequence.continuation_parameter_index)
constants_params_end = last(sequence.variables_range)
elseif !is_p_taylor
elseif !is_p_taylor && isnothing(sequence.continuation_parameter_index)
constants_params_end = last(sequence.parameters_range)
elseif !is_p_taylor && !isnothing(sequence.continuation_parameter_index)
constants_params_end = max(sequence.continuation_parameter_index - 1, 0)
else
constants_params_end = last(sequence.constants_range)
end
Expand Down
5 changes: 3 additions & 2 deletions test/certification_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@

n = size(M, 2)

S = collect(combinations(collect(1:n), 3))
S = collect(Combinatorics.combinations(collect(1:n), 3))
nonconstant_minors = filter(s -> !ModelKit.is_number(s), [det(M[:, s]) for s in S])

V = zeros(Expression, 6, 8)
Expand All @@ -234,7 +234,8 @@
end
end
end
conics = [det(V[:, s]) for s in combinations(collect(1:size(V, 2)), 6)]
conics =
[det(V[:, s]) for s in Combinatorics.combinations(collect(1:size(V, 2)), 6)]


@var s[1:length(nonconstant_minors)+length(conics)]
Expand Down
6 changes: 6 additions & 0 deletions test/homotopies_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,10 @@ end

test_homotopy(H, h)
end

@testset "MixedHomotopy" begin
@var x t
H = Homotopy([(1 - 2 * t) + (-2 + 2 * t) * x + x^2], [x], t)
test_homotopy(MixedHomotopy(H), H)
end
end
6 changes: 4 additions & 2 deletions test/monodromy_test.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@testset "Monodromy" begin
Random.seed!(0x8b868323)

function toric_ed(A)
d, n = size(A)
@var t[1:d] y[1:n] u[1:n]
Expand Down Expand Up @@ -232,8 +234,8 @@
permutations = true,
max_loops_no_progress = 20,
)
A = permutations(S)
B = permutations(S, reduced = false)
A = HC.permutations(S)
B = HC.permutations(S, reduced = false)

@test size(A) == (2, 2)
@test A == [1 2; 2 1] || A == [2 1; 1 2]
Expand Down
1 change: 1 addition & 0 deletions test/nid_test.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@testset "Numerical Irreducible Decomposition" begin
Random.seed!(0x8b868a92)

@testset "Union of 1 2-dim, 2 1-dim and 8 points" begin
@var x, y, z
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using HomotopyContinuation, LinearAlgebra, Test, Parameters, Random, Combinatorics
using HomotopyContinuation, LinearAlgebra, Test, Parameters, Random
using HomotopyContinuation.DoubleDouble: ComplexDF64
import Arblib
import Arblib, Combinatorics
using ProjectiveVectors: PVector, affine_chart
using TreeViews: TreeViews
const HC = HomotopyContinuation
Expand Down

0 comments on commit c53b387

Please sign in to comment.