Module:Temperament data/Badness testing: Difference between revisions

CompactStar (talk | contribs)
No edit summary
CompactStar (talk | contribs)
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 68: Line 68:


local function matinv(a)
local function matinv(a)
local dbl_identity = {}
local xn = scalarmatmul(a, 1e-7)
for i = 1, #a do
 
dbl_identity[i] = {}
for i = 1, 70 do
for j = 1, #a do
xn = matsub(scalarmatmul(xn, 2), matmul(xn, matmul(a, xn)))
if i == j then
dbl_identity[i][j] = 2
else
dbl_identity[i][j] = 0
end
end
end
end
local xn = scalarmatmul(a, 0.000005)
for i = 1, 30 do
xn = matmul(xn, matsub(dbl_identity, matmul(a, xn)))
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
local c = 0.0
for i = 1, #mapping do
for i = 1, #mapping do
for j = 1, #mapping[1] do
for j = 1, #mapping[1] do
Line 334: Line 323:
end
end
end
end
c = c/(#mapping * #mapping[1])
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