Module:ET: Difference between revisions

Undo. These aren't more accurate
Tag: Undo
Sintel (talk | contribs)
merge changes from dev
Line 1: Line 1:
local rat = require('Module:Rational')
local rat = require("Module:Rational")
local seq = require('Module:Sequence')
local seq = require("Module:Sequence")
local p = {}
local p = {}
-- TODO: we should not represent the equave as a rational number at all


local common_suffix = {
local common_suffix = {
['3/2'] = 'f',
["3/2"] = "f",
['987/610'] = 'ϕ',
["2"] = "o",
['2'] = 'o',
["2/1"] = "o",
['2/1'] = 'o',
["3"] = "t",
['3'] = 't',
["3/1"] = "t",
['3/1'] = 't',
 
['1264/465'] = 'n',
-- these should not be here
['355/113'] = 'π'
-- ["987/610"] = "ϕ",
-- ["1264/465"] = "n",
-- ["355/113"] = "π",
}
}
local common_ratio = {
local common_ratio = {
['f'] = rat.new(3, 2),
["f"] = rat.new(3, 2),
['ϕ'] = rat.new(987, 610),
["o"] = 2,
['o'] = 2,
["t"] = 3,
['t'] = 3,
 
['n'] = rat.new(1264, 465),
-- these should not be here
['π'] = rat.new(355, 113)
-- ["ϕ"] = rat.new(987, 610),
-- ["n"] = rat.new(1264, 465),
-- ["π"] = rat.new(355, 113),
}
}


Line 31: Line 37:
local equave_ratio = rat.as_ratio(equave)
local equave_ratio = rat.as_ratio(equave)
equave_ratio = equave_ratio:lower()
equave_ratio = equave_ratio:lower()
suffix = 'ed'
suffix = "ed"
if common_suffix[equave_ratio] then
if common_suffix[equave_ratio] then
suffix = suffix .. common_suffix[equave_ratio]
suffix = suffix .. common_suffix[equave_ratio]
Line 45: Line 51:
-- parse a ET structure
-- parse a ET structure
function p.parse(unparsed)
function p.parse(unparsed)
local size, suffix, equave = unparsed:match('^(%d+)([Ee][Dd](.+))$')
local size, suffix, equave = unparsed:match("^(%d+)([Ee][Dd](.+))$")
if equave == nil then
if equave == nil then
return nil
return nil
Line 80: Line 86:
function p.backslash_modifier(et)
function p.backslash_modifier(et)
if not rat.eq(et.equave, 2) then
if not rat.eq(et.equave, 2) then
return '\\' .. et.size .. et.suffix
return "\\" .. et.size .. et.suffix
end
end
return '\\' .. et.size
return "\\" .. et.size
end
end


Line 116: Line 122:
local t = 0
local t = 0
for factor, power in pairs(ratio) do
for factor, power in pairs(ratio) do
if type(factor) == 'number' then
if type(factor) == "number" then
t = t + power * p.approximate(et, factor)
t = t + power * p.approximate(et, factor)
end
end
Line 143: Line 149:
local zeta_integral = seq.contains(seq.zeta_integral, et.size)
local zeta_integral = seq.contains(seq.zeta_integral, et.size)
local zeta_gap = seq.contains(seq.zeta_gap, et.size)
local zeta_gap = seq.contains(seq.zeta_gap, et.size)
 
local markers = {}
local markers = {}
if zeta_peak then
if zeta_peak then
table.insert(markers, '[[The Riemann zeta function and tuning #Peak EDOs|zeta peak]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak]]")
elseif zeta_peak == nil then
elseif zeta_peak == nil then
table.insert(markers, '[[The Riemann zeta function and tuning #Peak EDOs|zeta peak?]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak?]]")
end
end
 
if zeta_peak_integer then
if zeta_peak_integer then
table.insert(markers, '[[The Riemann zeta function and tuning #Peak EDOs|zeta peak integer]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak integer]]")
elseif zeta_peak_integer == nil then
elseif zeta_peak_integer == nil then
table.insert(markers, '[[The Riemann zeta function and tuning #Peak EDOs|zeta peak integer?]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak integer?]]")
end
end
 
if zeta_integral then
if zeta_integral then
table.insert(markers, '[[The Riemann zeta function and tuning #Integral of Zeta EDOs|zeta integral]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Integral of Zeta EDOs|zeta integral]]")
elseif zeta_integral == nil then
elseif zeta_integral == nil then
table.insert(markers, '[[The Riemann zeta function and tuning #Integral of Zeta EDOs|zeta integral?]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Integral of Zeta EDOs|zeta integral?]]")
end
end
 
if zeta_gap then
if zeta_gap then
table.insert(markers, '[[The Riemann zeta function and tuning #Zeta Gap EDOs|zeta gap]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Zeta Gap EDOs|zeta gap]]")
elseif zeta_gap == nil then
elseif zeta_gap == nil then
table.insert(markers, '[[The Riemann zeta function and tuning #Zeta Gap EDOs|zeta gap?]]')
table.insert(markers, "[[The Riemann zeta function and tuning #Zeta Gap EDOs|zeta gap?]]")
end
end
 
return table.concat(markers, '<br>')
return table.concat(markers, "<br>")
end
end


return p
return p