Module:Limits: Difference between revisions
m Distinct consistency limit optimisation |
m integer_limit() implemented |
||
Line 30: | Line 30: | ||
local a = rat.new(n, m) | local a = rat.new(n, m) | ||
a = rat.modulo_mul(a, equave) | a = rat.modulo_mul(a, equave) | ||
local key = rat.as_ratio(a) | |||
ratios[key] = a | |||
end | |||
end | |||
end | |||
return ratios | |||
end | |||
-- compute q-integer limit | |||
-- if a function `norm` and a number `max_norm` are provided, the output will be additionally restricted | |||
function p.integer_limit(q, norm, max_norm) | |||
local check_norm = type(norm) == 'function' and type(max_norm) == 'number' | |||
local ratios = {} | |||
for n = 1, q do | |||
for m = 1, q do | |||
local a = rat.new(n, m) | |||
if not check_norm or norm(a) <= max_norm then | |||
local key = rat.as_ratio(a) | local key = rat.as_ratio(a) | ||
ratios[key] = a | ratios[key] = a |