Module:Temperament data/Badness testing: Difference between revisions
CompactStar (talk | contribs) No edit summary |
CompactStar (talk | contribs) No edit summary |
||
(13 intermediate revisions by the same user not shown) | |||
Line 68: | 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 328: | 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 |