JuliaHomotopyContinuation / HomotopyContinuation.jl

A Julia package for solving systems of polynomials via homotopy continuation.
https://www.JuliaHomotopyContinuation.org
MIT License
181 stars 30 forks source link

fix fast arithmetic typo bugs #469

Closed alexheaton2 closed 3 years ago

alexheaton2 commented 3 years ago

fixed some typos as directed by Sascha, hopefully correctly!

alexheaton2 commented 3 years ago

I tried to fix it, but I think I failed. Now I get this error below, which I also posted here: https://github.com/JuliaHomotopyContinuation/HomotopyContinuation.jl/issues/466

mul_float: types of a and b must match

Stacktrace:
 [1] * at ./float.jl:405 [inlined]
 [2] * at ./complex.jl:320 [inlined]
 [3] muladd_fast at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/model_kit/instructions.jl:139 [inlined]
 [4] macro expansion at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/model_kit/slp_compiler.jl:128 [inlined]
 [5] macro expansion at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/model_kit/compiled_system_homotopy.jl:216 [inlined]
 [6] evaluate_and_jacobian!(::Array{Complex{Float64},1}, ::StructArrays.StructArray{Complex{Float64},2,NamedTuple{(:re, :im),Tuple{Array{Float64,2},Array{Float64,2}}},Int64}, ::CompiledSystem{(0x76b5e12acde9819b, 1)}, ::Array{Complex{Float64},1}, ::Array{Complex{Float64},1}) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/model_kit/compiled_system_homotopy.jl:216
 [7] evaluate_and_jacobian! at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/systems/mixed_system.jl:31 [inlined]
 [8] evaluate_and_jacobian! at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/homotopies/parameter_homotopy.jl:96 [inlined]
 [9] init_newton!(::Array{Complex{Float64},1}, ::HomotopyContinuation.NewtonCorrector, ::ParameterHomotopy{MixedSystem{Float64,(0x76b5e12acde9819b, 1)}}, ::Array{Complex{Float64},1}, ::Complex{Float64}, ::HomotopyContinuation.Jacobian{StructArrays.StructArray{Complex{Float64},2,NamedTuple{(:re, :im),Tuple{Array{Float64,2},Array{Float64,2}}},Int64}}, ::WeightedNorm{InfNorm}; a::Float64, extended_precision::Bool) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/newton_corrector.jl:221
 [10] init!(::Tracker{ParameterHomotopy{MixedSystem{Float64,(0x76b5e12acde9819b, 1)}},StructArrays.StructArray{Complex{Float64},2,NamedTuple{(:re, :im),Tuple{Array{Float64,2},Array{Float64,2}}},Int64}}, ::Array{Float64,1}, ::Float64, ::Float64; ω::Float64, μ::Float64, τ::Float64, max_initial_step_size::Float64, keep_steps::Bool, extended_precision::Bool) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/tracker.jl:675
 [11] init!(::EndgameTracker{ParameterHomotopy{MixedSystem{Float64,(0x76b5e12acde9819b, 1)}},StructArrays.StructArray{Complex{Float64},2,NamedTuple{(:re, :im),Tuple{Array{Float64,2},Array{Float64,2}}},Int64}}, ::Array{Float64,1}, ::Float64; ω::Float64, μ::Float64, extended_precision::Bool) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/endgame_tracker.jl:266
 [12] #track!#150 at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/endgame_tracker.jl:301 [inlined]
 [13] track! at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/endgame_tracker.jl:301 [inlined]
 [14] track(::EndgameTracker{ParameterHomotopy{MixedSystem{Float64,(0x76b5e12acde9819b, 1)}},StructArrays.StructArray{Complex{Float64},2,NamedTuple{(:re, :im),Tuple{Array{Float64,2},Array{Float64,2}}},Int64}}, ::Array{Float64,1}, ::Float64; path_number::Int64, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/endgame_tracker.jl:897
 [15] serial_solve(::Solver{EndgameTracker{ParameterHomotopy{MixedSystem{Float64,(0x76b5e12acde9819b, 1)}},StructArrays.StructArray{Complex{Float64},2,NamedTuple{(:re, :im),Tuple{Array{Float64,2},Array{Float64,2}}},Int64}}}, ::Array{Array{Float64,1},1}, ::ProgressMeter.Progress, ::typeof(HomotopyContinuation.always_false); catch_interrupt::Bool) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/solve.jl:568
 [16] solve(::Solver{EndgameTracker{ParameterHomotopy{MixedSystem{Float64,(0x76b5e12acde9819b, 1)}},StructArrays.StructArray{Complex{Float64},2,NamedTuple{(:re, :im),Tuple{Array{Float64,2},Array{Float64,2}}},Int64}}}, ::Array{Array{Float64,1},1}; stop_early_cb::Function, show_progress::Bool, threading::Bool, catch_interrupt::Bool) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/solve.jl:522
 [17] solve(::System, ::Vararg{Any,N} where N; show_progress::Bool, threading::Bool, catch_interrupt::Bool, target_parameters::Array{Complex{Float64},1}, stop_early_cb::Function, transform_result::Nothing, transform_parameters::typeof(identity), flatten::Nothing, target_subspaces::Nothing, kwargs::Base.Iterators.Pairs{Symbol,Array{Complex{Float64},1},Tuple{Symbol},NamedTuple{(:start_parameters,),Tuple{Array{Complex{Float64},1}}}}) at /Users/heaton/.julia/packages/HomotopyContinuation/zIN25/src/solve.jl:487
 [18] twostep(::System, ::Array{Float64,1}, ::Float64) at /Users/heaton/Julia notebooks/Myf and Matthias/BMNparameterhomotopyoptimization.jl:113
 [19] takelocalsteps(::Array{Float64,1}, ::Float64, ::Float64, ::ConstraintVariety, ::typeof(evaluateobjectivefunctiongradient); decreasefactor::Float64, increasefactor::Float64, maxsteps::Int64) at /Users/heaton/Julia notebooks/Myf and Matthias/BMNparameterhomotopyoptimization.jl:191
 [20] findminima(::Array{Float64,1}, ::Float64, ::Float64, ::ConstraintVariety, ::Function; maxseconds::Int64, maxlocalsteps::Int64) at /Users/heaton/Julia notebooks/Myf and Matthias/BMNparameterhomotopyoptimization.jl:310
 [21] top-level scope at In[19]:11
 [22] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091
saschatimme commented 3 years ago

That’s very annoying and I don’t fully understand what the problem is. But I think just removing the fast math code path is also fine since the speed up was often only minimal anyways (besides for complex division where we really need it)