300300
301301Sort three integers without heap allocation (in-place bubble sort).
302302"""
303- function _sort3 (a:: Int , b:: Int , c:: Int )
303+ function _sort3 (a:: Real , b:: Real , c:: Real )
304304 if a > b
305305 a, b = b, a
306306 end
@@ -314,38 +314,38 @@ function _sort3(a::Int, b::Int, c::Int)
314314end
315315
316316"""
317- _monomial_key(m::_Monomial)::NTuple{4,Int }
317+ _monomial_key(m::_Monomial)::NTuple{4,Int64 }
318318
319319Compute a canonical hash key for a monomial: (degree, sorted_val1, sorted_val2, sorted_val3).
320320Uses integer tuple instead of a sorted Vector for faster hashing.
321321"""
322322function _monomial_key (m:: _Monomial )
323323 n = length (m. variables)
324324 if n == 0
325- return (0 , 0 , 0 , 0 )
325+ return (Int64 ( 0 ), Int64 ( 0 ), Int64 ( 0 ), Int64 ( 0 ) )
326326 elseif n == 1
327327 a = m. variables[1 ]. value
328- return (1 , a, 0 , 0 )
328+ return (Int64 ( 1 ), Int64 (a), Int64 ( 0 ), Int64 ( 0 ) )
329329 elseif n == 2
330330 a, b = m. variables[1 ]. value, m. variables[2 ]. value
331331 lo, hi = a <= b ? (a, b) : (b, a)
332- return (2 , lo, hi, 0 )
332+ return (Int64 ( 2 ), Int64 (lo), Int64 (hi), Int64 ( 0 ) )
333333 else # n >= 3; degree > 3 is rejected at classification stage
334334 a, b, c = _sort3 (
335335 m. variables[1 ]. value,
336336 m. variables[2 ]. value,
337337 m. variables[3 ]. value,
338338 )
339- return (n, a, b, c )
339+ return (Int64 (n), Int64 (a), Int64 (b), Int64 (c) )
340340 end
341341end
342342
343343"""
344- _monomial_vars(key::NTuple{4,Int })::Vector{MOI.VariableIndex}
344+ _monomial_vars(key::NTuple{4,Int64 })::Vector{MOI.VariableIndex}
345345
346346Given a monomial key, reconstruct the list of variables.
347347"""
348- function _monomial_vars (key:: NTuple{4,Int } )
348+ function _monomial_vars (key:: NTuple{4,Int64 } )
349349 degree = key[1 ]
350350 if degree == 0
351351 return MOI. VariableIndex[]
@@ -369,8 +369,8 @@ Combine like monomials (same variables, regardless of order).
369369Assumes all monomials have degree ≤ 3.
370370"""
371371function _combine_like_monomials (monomials:: Vector{_Monomial{T}} ) where {T}
372- # Key: NTuple{4,Int } (degree + up to 3 sorted variable indices).
373- combined = Dict {NTuple{4,Int },T} ()
372+ # Key: NTuple{4,Int64 } (degree + up to 3 sorted variable indices).
373+ combined = Dict {NTuple{4,Int64 },T} ()
374374
375375 for m in monomials
376376 key = _monomial_key (m)
0 commit comments