A simple complex number libray for Lua wrote in C
-
Ensure dependencies
- you need the Lua c API installed, you can move the lib to the lib/{YOUR-PLATFORM} directory inside src or change the makefile to use your global installed, for windows and linux users the lua54.lib and liblua54.a are already in the lib/Windows and lib/Linux directories
- GCC and GNU Make, (other compilers may work, but you need to change it in the Makefile)
-
git clone this repo
-
type
make install OS={YOUR-PLATFORM}
- Platforms:
- Windows (dependencies included)
- Linux (dependencies included)
- MacOS (dependencies need to be downloaded apart)
- BSD (dependencies need to be downloaded apart)
- If your system isn't availble, you can compile the program using your compilers CLI
-
(OPTIONAL) type
make clean OS={YOUR-PLATFORM}
to clean the objects (if you want) -
copy the dynamic library to your lua project or to your lua global path/cpath
-
require it and use :3
The entire documentation can be found in the docs directory(WORK IN PROGRESS).
Test examples of all functions can be found on the tst directory.
local cpx = require("complex")
local z = cpx.new(2,3)
local w = cpx.new(3,2)
print(cpx.to_string(z) .. " + " .. cpx.to_string(w) .. " = " .. cpx.to_string(cpx.add(z,w)))
-- > 2.0000000000 + 3.0000000000i + 3.0000000000 + 2.0000000000i = 5.0000000000 + 5.0000000000i