-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathextensions.lua
46 lines (37 loc) · 1.39 KB
/
extensions.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- Copyright (C) 2017 Deyan Dobromirov
-- An modules extensions functionalities library
if not debug.getinfo(3) then
print("This is a module to extend other modules with.")
print("Try `local module = require('module').extend()`.")
os.exit(1)
end
local complex = require("complex")
local matrix = require("matrix")
local metaData = {}
local extensions = {complex={},matrix={}}
metaData.__ipmtx = {{ 1, 0, 0, 0},
{ 0, 0, 1, 0},
{-3, 3,-2,-1},
{ 2,-2, 1, 1}}
function extensions.complex.getInterpolation(cSelf, nH, tI)
local mtx = matrix.getNew(metaData.__ipmtx)
local ftx = matrix.getNew({{tI.F [3], tI.F [1], tI.Fy [3], tI.Fy [1]},
{tI.F [4], tI.F [2], tI.Fy [4], tI.Fy [2]},
{tI.Fx[3], tI.Fx[1], tI.Fxy[3], tI.Fxy[1]},
{tI.Fx[4], tI.Fx[2], tI.Fxy[4], tI.Fxy[2]}})
local nV, x, y = 0, cSelf:getParts()
local mta = mtx:getMul(ftx):Mul(mtx:Trans())
for iD = 1, 4 do for jD = 1, 4 do
nV = (tonumber(mta(iD,jD) or 0)*x^(iD-1)*y^(jD-1))
end; end; return nV
end
function extensions.matrix.complexNew(nRe, nIm)
return complex.getNew(nRe, nIm)
end
function extensions.matrix.complexCnvNew(vIn, ...)
return complex.cnvNew(vIn, ...)
end
function extensions.matrix.complexGetRandom(nL, nU, vC)
return complex.getRandom(nL, nU, vC)
end
return extensions