Skip to content

Commit 599584f

Browse files
committed
fix int64
1 parent c6501ba commit 599584f

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/cubic_parser.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ end
300300
301301
Sort 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)
314314
end
315315

316316
"""
317-
_monomial_key(m::_Monomial)::NTuple{4,Int}
317+
_monomial_key(m::_Monomial)::NTuple{4,Int64}
318318
319319
Compute a canonical hash key for a monomial: (degree, sorted_val1, sorted_val2, sorted_val3).
320320
Uses integer tuple instead of a sorted Vector for faster hashing.
321321
"""
322322
function _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
341341
end
342342

343343
"""
344-
_monomial_vars(key::NTuple{4,Int})::Vector{MOI.VariableIndex}
344+
_monomial_vars(key::NTuple{4,Int64})::Vector{MOI.VariableIndex}
345345
346346
Given 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).
369369
Assumes all monomials have degree ≤ 3.
370370
"""
371371
function _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

Comments
 (0)