Module:Temperament data: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
CompactStar (talk | contribs)
No edit summary
CompactStar (talk | contribs)
Copying code from AI (it has references to some library which I will remove and replace with my own functions)
Line 16: Line 16:
end
end


-- Moore-Penrose pseudoinverse
local function moore_penrose_inverse(A)
local function pinv()end
  -- Perform the singular value decomposition of A.
  local U, S, V = svd(A)
 
  -- Compute the pseudo-inverse of S.
  local S_inv = torch.diag(torch.reciprocal(S + torch.zeros_like(S)))
 
  -- Compute the Moore-Penrose inverse of A.
  local A_inv = V * S_inv * U
 
  return A_inv
end


local function get_cte_error()
local function get_cte_error()

Revision as of 02:53, 14 October 2023

Module documentation[view] [edit] [history] [purge]
This module should not be invoked directly; use its corresponding template instead: Template:Temperament data.
Module:Temperament data is a draft module. It is incomplete and may not be in active development. If possible, editors are encouraged to help with its development. In the meantime, editors should avoid using this module across the Xenharmonic Wiki, except for testing.
Introspection summary for Module:Temperament data 
Functions provided (0)
Line Function Params
Lua modules required (1)
Variable Module Functions used
rat Module:Rational dependency not used

No function descriptions were provided. The Lua code may have further information.


local rat = require('Module:Rational')
local p = {}

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 moore_penrose_inverse(A)
  -- Perform the singular value decomposition of A.
  local U, S, V = svd(A)

  -- Compute the pseudo-inverse of S.
  local S_inv = torch.diag(torch.reciprocal(S + torch.zeros_like(S)))

  -- Compute the Moore-Penrose inverse of A.
  local A_inv = V * S_inv * U

  return A_inv
end

local function get_cte_error()
end


return p