Module:Temperament data: Difference between revisions

CompactStar (talk | contribs)
No edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(12 intermediate revisions by one other user not shown)
Line 1: Line 1:
local p = {}
local rat = require("Module:Rational")
local rat = require("Module:Rational")
local p = {}
local u = require("Module:Utils")
local u = require("Module:Utils")


local function gcd(a,b)
local function gcd(a, b)
     if type(a) == "number" and type(b) == "number" and a == math.floor(a) and b == math.floor(b) then
     if type(a) == "number" and type(b) == "number" and a == math.floor(a) and b == math.floor(b) then
         if b == 0 then
         if b == 0 then
Line 66: Line 67:


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, 75 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.005)
for i = 1, 30 do
xn = matmul(xn, matsub(dbl_identity, matmul(a, xn)))
end
return xn
return xn
end
end