Module:No-1s limits: Difference between revisions
Dummy index (talk | contribs) mNo edit summary |
Dummy index (talk | contribs) No edit summary |
||
| (9 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | |||
local ET = require('Module:ET') | |||
local rat = require('Module:Rational') | local rat = require('Module:Rational') | ||
local | local yesno = require("Module:Yesno") | ||
-- compute all positive ratios n/m with n and m <= q modulo powers of equave | -- compute all positive ratios n/m with n and m <= q modulo powers of equave | ||
| Line 211: | Line 213: | ||
local previ = 1 | local previ = 1 | ||
for i = 1, #primes do | for i = 1, #primes do | ||
local | local ip = primes[i] | ||
if | if ip > limit then break end | ||
if | if ip == et.equave then | ||
val[i] = patent_val[i] | val[i] = patent_val[i] | ||
elseif | elseif ip == minprime then | ||
val[i] = patent_val[i] | val[i] = patent_val[i] | ||
previ = i | previ = i | ||
else | else | ||
val[i] = val[previ] + ET.approximate(et, | val[i] = val[previ] + ET.approximate(et, ip / primes[previ]) | ||
previ = i | previ = i | ||
end | end | ||
end | end | ||
rets[1] = '' | |||
if et.equave ~= 2 then | |||
local i = table.find(primes, et.equave) | |||
if i then | |||
rets[1] = rets[1] .. string.sub(wart, i, i) | |||
else | |||
rets[1] = rets[1] .. 'q' | |||
end | |||
end | |||
rets[1] = rets[1] .. et.size | |||
if limit < minprime * minprime then | if limit < minprime * minprime then | ||
local nonpatent = false | local nonpatent = false | ||
local binded = false | |||
local bias = 0 | local bias = 0 | ||
for i = 1, #val do | for i = 1, #val do | ||
local | local ip = primes[i] | ||
if | if ip == et.equave then | ||
elseif | elseif ip == minprime then | ||
bias = wart_dir[i] | bias = wart_dir[i] | ||
else | else | ||
if val[i] ~= patent_val[i] then nonpatent = true end | if val[i] ~= patent_val[i] then | ||
nonpatent = true | |||
elseif wart_dir[i] ~= bias then | |||
binded = true | |||
end | |||
end | end | ||
end | end | ||
if nonpatent or not binded then | |||
if nonpatent then | |||
rets[2] = '' .. rets[1] | rets[2] = '' .. rets[1] | ||
for i = 1, #val do | for i = 1, #val do | ||
local | local ip = primes[i] | ||
local difference = (val[i] - patent_val[i]) * wart_dir[i] | local difference = (val[i] - patent_val[i]) * wart_dir[i] | ||
if difference > 0 then | if difference > 0 then | ||
rets[1] = rets[1] .. wart | rets[1] = rets[1] .. string.rep(string.sub(wart, i, i), difference * 2) | ||
elseif difference < 0 then | elseif difference < 0 then | ||
rets[1] = rets[1] .. wart | rets[1] = rets[1] .. string.rep(string.sub(wart, i, i), -difference * 2 - 1) | ||
end | end | ||
end | end | ||
for i = 1, #val do | for i = 1, #val do | ||
local | local ip = primes[i] | ||
if | if ip ~= et.equave then val[i] = val[i] - bias end | ||
local difference = (val[i] - patent_val[i]) * wart_dir[i] | local difference = (val[i] - patent_val[i]) * wart_dir[i] | ||
if difference > 0 then | if difference > 0 then | ||
rets[2] = rets[2] .. wart | rets[2] = rets[2] .. string.rep(string.sub(wart, i, i), difference * 2) | ||
elseif difference < 0 then | elseif difference < 0 then | ||
rets[2] = rets[2] .. wart | rets[2] = rets[2] .. string.rep(string.sub(wart, i, i), -difference * 2 - 1) | ||
end | end | ||
end | end | ||
if bias > 0 then rets = {rets[2], rets[1]} end | |||
end | end | ||
else | else | ||
for i = 1, #val do | |||
local ip = primes[i] | |||
if ip * minprime <= limit then | |||
if val[i] ~= patent_val[i] then | |||
return '(error)' | |||
end | |||
end | |||
local difference = (val[i] - patent_val[i]) * wart_dir[i] | |||
if difference > 0 then | |||
rets[1] = rets[1] .. string.rep(string.sub(wart, i, i), difference * 2) | |||
elseif difference < 0 then | |||
rets[1] = rets[1] .. string.rep(string.sub(wart, i, i), -difference * 2 - 1) | |||
end | |||
end | |||
end | end | ||
return table.concat (rets, ", ") | return table.concat (rets, ", ") | ||
end | end | ||
function p.for_small_edos (frame) | function p.for_small_edos(frame) | ||
local | local liners = tonumber(frame.args['lines']) | ||
local debugg = yesno(frame.args['debug']) | |||
local t_body = {} | local t_body = {} | ||
local val = {} | local val = {} | ||
for i = 1, | |||
for i = 1, liners do | |||
local et = ET.parse('' .. i .. 'edo') | local et = ET.parse('' .. i .. 'edo') | ||
local limit = p.consistency_limit(et, false, 43) | local limit = p.consistency_limit(et, false, 43) | ||
local vals = p.vals(et, limit) | local vals = p.vals(et, limit) | ||
t_body[i] = string.format ("|-\n| %s\n| %s\n| %s", i, limit, vals) | t_body[i] = string.format("|-\n| %s\n| %s\n| %s", i, limit, vals) | ||
end | end | ||
local result = "{| class=\"wikitable center-all mw-collapsible mw-collapsed\"\n" .. | |||
"|-\n" .. | "|-\n" .. | ||
"! EDO\n" .. | "! EDO\n" .. | ||
"! No-1s consistency limit\n" .. | "! No-1s consistency limit\n" .. | ||
"! Associated vals\n" .. | "! Associated vals\n" .. | ||
table.concat (t_body, "\n") .. | table.concat(t_body, "\n") .. | ||
"\n|}" | "\n|}" | ||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||
return p | return p | ||