Skip to content

Commit

Permalink
Merge pull request #467 from JuliaHomotopyContinuation/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
saschatimme authored Apr 15, 2021
2 parents 09c6bce + b40f6c2 commit 47c69ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/model_kit/instructions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,20 @@ function arity(op::InstructionOp)
end
@inline neg_fast(x) = Base.FastMath.sub_fast(x)
@inline add_fast(x, y) = Base.FastMath.add_fast(x, y)
@inline add_fast(x::T, y::T) where {T} = x + y
@inline sub_fast(x, y) = Base.FastMath.sub_fast(x, y)
@inline sub_fast(x::T, y::T) where {T} = x - y
@inline mul_fast(x, y) = Base.FastMath.mul_fast(x, y)
@inline mul_fast(x::T, y::T) where {T} = x * y
@inline div_fast(x, y) = Base.FastMath.div_fast(x, y)
@inline div_fast(x::T, y::T) where {T} = x / y
@inline pow_fast(x, p::Integer) = Base.power_by_squaring(x, p)
@inline muladd_fast(x, y, z) = @fastmath x * y + z
@inline muladd_fast(x::T, y::T, z::T) where {T} = x * y + z
@inline mulsub_fast(x, y, z) = @fastmath x * y - z
@inline mulsub_fast(x::T, y::T, z::T) where {T} = x * y - z
@inline submul_fast(x, y, z) = @fastmath z - x * y
@inline submul_fast(x::T, y::T, z::T) where {T} = z - x * y
@inline sqr_fast(x) = sqr(x)
@inline sqr(x) = @fastmath x * x
@inline function sqr(z::Complex)
Expand Down
6 changes: 5 additions & 1 deletion src/tracker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,11 @@ function init!(
else
evaluate_and_jacobian!(corrector.r, workspace(jacobian), homotopy, x, t)
J = matrix(workspace(jacobian))
corank = size(J, 2) - LA.rank(J, rtol = 1e-14)
if J isa StructArrays.StructArray
corank = size(J, 2) - LA.rank(Matrix(J), rtol = 1e-14)
else
corank = size(J, 2) - LA.rank(J, rtol = 1e-14)
end
if corank > 0
state.code = TrackerCode.terminated_invalid_startvalue_singular_jacobian
else
Expand Down
14 changes: 7 additions & 7 deletions test/monodromy_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
result = monodromy_solve(
F,
target_solutions_count = 21,
max_loops_no_progress = 20,
max_loops_no_progress = 50,
threading = false,
)
@test is_success(result)
Expand All @@ -27,7 +27,7 @@
result2 = monodromy_solve(
F,
target_solutions_count = 21,
max_loops_no_progress = 20,
max_loops_no_progress = 50,
threading = false,
seed = result.seed,
)
Expand All @@ -36,7 +36,7 @@
result = monodromy_solve(
F,
target_solutions_count = 21,
max_loops_no_progress = 20,
max_loops_no_progress = 50,
threading = true,
)
@test is_success(result)
Expand All @@ -53,7 +53,7 @@
[x₀ for _ = 1:30],
p₀,
target_solutions_count = 21,
max_loops_no_progress = 20,
max_loops_no_progress = 50,
)
@test length(solutions(result)) == 21

Expand Down Expand Up @@ -97,7 +97,7 @@
p₀,
equivalence_classes = true,
target_solutions_count = 7,
max_loops_no_progress = 20,
max_loops_no_progress = 50,
group_actions = roots_of_unity,
)
@test nresults(result) == 7
Expand All @@ -107,7 +107,7 @@
x₀,
p₀,
group_action = roots_of_unity,
max_loops_no_progress = 20,
max_loops_no_progress = 50,
)
@test nsolutions(result) == 7

Expand All @@ -116,7 +116,7 @@
InterpretedSystem(F),
group_action = roots_of_unity,
target_solutions_count = 7,
max_loops_no_progress = 20,
max_loops_no_progress = 50,
)
@test nsolutions(result) == 7

Expand Down

0 comments on commit 47c69ba

Please sign in to comment.