Lua 4.0 compiled with complex numbers as the standard number type


David Meeker
dmeeker@ieee.org
01Dec2005

This is a modified version of Lua 4 (see http://www.lua.org) that uses the CComplex class from FEMM as the standard number type in Lua. The distribution contains a project for building a statically linked version of the Lua library and a dialog-based interpreter program for evaluating expressions in Lua 4. The package builds with Visual C++ 6.0.

In this package, sqrt(-1) is represented by the uppercase I. When representing complex numbers, always multiply by I. For example, the complex number 100*I is valid, but 100I would give an error. If you ask Lua to print out a complex number, that number will follow the same convention. For example, if the command:

print(tanh(1+I))

would return the answer:

1.083923327338695+I*0.2717525853195117

A number of additional mathematical functions are definedthat deal with complex numbers: re, im, abs, arg. Various trig functions have been redefined to give the correct answers for complex numbers.

Some example functions (specifically atanh) have been defined implemented in the LuaConsole program to demonstrate creating Lua functions that pass complex numbers back and forth between Lua and C++.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki