summaryrefslogtreecommitdiff
path: root/test/examples/complex
diff options
context:
space:
mode:
authorLua Team <team@lua.org>1997-07-01 12:00:00 +0000
committerrepogen <>1997-07-01 12:00:00 +0000
commit4f8c5d0f284e1f4da717aea5008915f185cd2e05 (patch)
tree5671acf8a2cacf0c0524ce96d22959590a3aa5af /test/examples/complex
parent47a298a24ad3a8202440051de5938618502302a0 (diff)
downloadlua-github-3.0.tar.gz
Lua 3.03.0
Diffstat (limited to 'test/examples/complex')
-rw-r--r--test/examples/complex/complex.lua82
-rw-r--r--test/examples/complex/mandel.lua25
2 files changed, 0 insertions, 107 deletions
diff --git a/test/examples/complex/complex.lua b/test/examples/complex/complex.lua
deleted file mode 100644
index a213a746..00000000
--- a/test/examples/complex/complex.lua
+++ /dev/null
@@ -1,82 +0,0 @@
--- complex.lua
--- complex arithmetic package for lua
--- Luiz Henrique de Figueiredo (lhf@csg.uwaterloo.ca)
--- 24 Oct 95
-$debug
-
-Complex={type="package"}
-
-function complex(x,y)
- return { re=x, im=y, type="complex" }
-end
-
-function Complex.conj(x,y)
- return complex(x.re,-x.im)
-end
-
-function Complex.norm2(x)
- local n=Complex.mul(x,Complex.conj(x))
- return n.re
-end
-
-function Complex.abs(x)
- return sqrt(Complex.norm2(x))
-end
-
-function Complex.add(x,y)
- return complex(x.re+y.re,x.im+y.im)
-end
-
-function Complex.sub(x,y)
- return complex(x.re-y.re,x.im-y.im)
-end
-
-function Complex.mul(x,y)
- return complex(x.re*y.re-x.im*y.im,x.re*y.im+x.im*y.re)
-end
-
-function Complex.div(x,y)
- local z=x*Complex.conj(y)
- local t=Complex.norm2(y)
- z.re=z.re/t
- z.im=z.im/t
- return z
-end
-
-function Complex.fallback(x,y,op)
- if type(x)=="number" then x=complex(x,0) end
- if type(y)=="number" then y=complex(y,0) end
- if type(x)=="complex" and type(y)=="complex" then
- return Complex[op](x,y)
- else
- return Complex.oldfallback(x,y)
- end
-end
-
-function Complex.newtype(x)
- local t=Complex.oldtype(x)
- if t=="table" and x.type then return x.type else return t end
-end
-
-function Complex.print(x)
- if type(x)~="complex" then
- Complex.oldprint(x)
- else
- local s
- if x.im>=0 then s="+" else s="" end
- Complex.oldprint(x.re..s..x.im.."I")
- end
-end
-
-function Complex.newabs(x)
- if type(x)~="complex" then
- return Complex.oldabs(x)
- else
- return Complex.abs(x)
- end
-end
-
-Complex.oldfallback=setfallback("arith",Complex.fallback)
-Complex.oldtype=type type=Complex.newtype
-Complex.oldprint=print print=Complex.print
-Complex.oldabs=abs abs=Complex.abs
diff --git a/test/examples/complex/mandel.lua b/test/examples/complex/mandel.lua
deleted file mode 100644
index 5e3d3eb6..00000000
--- a/test/examples/complex/mandel.lua
+++ /dev/null
@@ -1,25 +0,0 @@
-dofile("complex.lua")
-
-xmin=-2 xmax=2 ymin=-2 ymax=2
-d=.125
-
-function level(x,y)
- local c=complex(x,y)
- local l=0
- local z=c
- repeat
- z=z*z+c
- l=l+1
- until abs(z)>2 or l>255
- return l-1
-end
-
-x=xmin
-while x<xmax do
- y=ymin
- while y<ymax do
- print(level(x,y))
- y=y+d
- end
- x=x+d
-end