Module:Temperament data: Difference between revisions
Jump to navigation
Jump to search
CompactStar (talk | contribs) No edit summary |
CompactStar (talk | contribs) No edit summary |
||
| Line 11: | Line 11: | ||
end | end | ||
function | local function cmul(a, b) | ||
return {(a[1] * b[1] - a[2] * b[2]), (a[1] * b[2] + a[2] * b[1])} | return {(a[1] * b[1] - a[2] * b[2]), (a[1] * b[2] + a[2] * b[1])} | ||
end | end | ||
function p.cdiv(a, b) | |||
return {(a[1] * b[1] + a[2] * b[2])/(b[1]*b[1] + b[2]*b[2]), (a[2] * b[1] - a[1] * b[2])/(b[1]*b[1] + b[2]*b[2])} | |||
end | |||
local function matmul(a, b) | local function matmul(a, b) | ||
Revision as of 03:08, 14 October 2023
- This module should not be invoked directly; use its corresponding template instead: Template:Temperament data.
| Introspection summary for Module:Temperament data | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| ||||||||||||
No function descriptions were provided. The Lua code may have further information.
local rat = require('Module:Rational')
local p = {}
-- Complex number functions (1st element = real and 2nd element = imaginary)
local function cadd(a, b)
return {(a[1] + b[1]), (a[2] + b[2])}
end
local function csub(a, b)
return {(a[1] - b[1]), (a[2] - b[2])}
end
local function cmul(a, b)
return {(a[1] * b[1] - a[2] * b[2]), (a[1] * b[2] + a[2] * b[1])}
end
function p.cdiv(a, b)
return {(a[1] * b[1] + a[2] * b[2])/(b[1]*b[1] + b[2]*b[2]), (a[2] * b[1] - a[1] * b[2])/(b[1]*b[1] + b[2]*b[2])}
end
local function matmul(a, b)
local result = {}
for i = 1, #a do
result[i] = {}
for j = 1, #(b[1]) do
result[i][j] = 0
for k = 1, #(a[1]) do
result[i][j] = result[i][j] + a[i][k] * b[k][j]
end
end
end
return result
end
local function matinv(a)
end
return p