Module:Temperament data/Badness testing: Difference between revisions
CompactStar (talk | contribs) Created page with "local rat = require("Module:Rational") local p = {} local u = require("Module:Utils") local function gcd(a,b) if type(a) == "number" and type(b) == "number" and a == math..." |
CompactStar (talk | contribs) No edit summary |
||
(14 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
-- This is just for testing about badness metrics, do not actually use it. | |||
local rat = require("Module:Rational") | local rat = require("Module:Rational") | ||
local p = {} | local p = {} | ||
Line 66: | Line 68: | ||
local function matinv(a) | local function matinv(a) | ||
local | local xn = scalarmatmul(a, 1e-7) | ||
for i = 1, | |||
for i = 1, 70 do | |||
xn = matsub(scalarmatmul(xn, 2), matmul(xn, matmul(a, xn))) | |||
end | end | ||
return xn | return xn | ||
end | end | ||
Line 326: | Line 317: | ||
end | end | ||
result = result:sub(0,-3) | result = result:sub(0,-3) | ||
local c = 0.0 | |||
for i = 1, #mapping do | |||
for j = 1, #mapping[1] do | |||
c = c + math.abs(mapping[i][j]) | |||
end | |||
end | |||
c = c/(#(mapping) * #(mapping[1])) | |||
mw.logObject(c) | |||
local te_generator = get_te_generator(subgroup, comma_matrix, generators) | |||
local te_tuning = matmul(te_generator, mapping) | |||
local e = 0.0 | |||
for i = 1, #(te_tuning[1]) do | |||
-- mw.logObject(te_tuning) | |||
-- mw.logObject((te_tuning[1][i] * 1200) - ((math.log(subgroup[i])/math.log(2)) * 1200)) | |||
e = e + math.abs((te_tuning[1][i] * 1200) - ((math.log(subgroup[i])/math.log(2)) * 1200)) | |||
end | |||
e = e/#(te_tuning[1]) | |||
local usb = c * e | |||
result = u._round(usb, 7) | |||
return result | return result | ||
end | end | ||
return p | return p |