Module:Limits: Difference between revisions

Plumtree (talk | contribs)
m integer_limit() implemented
Plumtree (talk | contribs)
Distinct consistency limit: bugfix
Line 67: Line 67:
local a_approx = ET.approximate(et, rat.as_float(a)) % et.size
local a_approx = ET.approximate(et, rat.as_float(a)) % et.size
if approx_set[a_approx] then
if approx_set[a_approx] then
return false
if not rat.eq(rat.modulo_mul(rat.div(a, approx_set[a_approx]), et.equave), 1) then
mw.log(a_key .. ' -> ' .. a_approx .. ': conflict!')
return false
end
end
end
approx_set[a_approx] = true
approx_set[a_approx] = a
mw.log(a_key .. ' -> ' .. a_approx)
end
end
for a_key, a in pairs(ratios) do
for a_key, a in pairs(ratios) do
local a_approx = ET.approximate(et, rat.as_float(a)) % et.size
local a_approx = ET.approximate(et, rat.as_float(a)) % et.size
if approx_set[a_approx] then
if approx_set[a_approx] then
return false
if not rat.eq(rat.modulo_mul(rat.div(a, approx_set[a_approx]), et.equave), 1) then
mw.log(a_key .. ' -> ' .. a_approx .. ': conflict!')
return false
end
end
end
approx_set[a_approx] = true
approx_set[a_approx] = a
mw.log(a_key .. ' -> ' .. a_approx)
end
end
end
end
Line 155: Line 163:
local consistent = p.additively_consistent(et, ratios, distinct, previous)
local consistent = p.additively_consistent(et, ratios, distinct, previous)
if not consistent then
if not consistent then
mw.log('Not consistent at step ' .. n .. ', returning ' .. last_n)
return last_n
return last_n
end
end