[HCPX] Complex Number Library v1.0

HXCTCreations - Custom level - Apr 23, 2017 from Android
Revision #2, updated Jan 1, 1970
Play Edit 7 players liked this.

A flexible and easy to use module to implement complex number into Lua.

The plain lua module is to the right of the display, go to edit and save it :)

Usage:
-Use [x = hcpx:new(re, im)] to declare a new complex number x and assign value to it, with re as the real part and im as the imaginary part.
-Use [a, b = x:unpack()] to unpack the real part a and imaginary part b of a complex number x.
-Use [str = x:string()] to get a mathematical form of the number (a + bi)
-for basic operation between two complex number, you can write the usual arithmetical operation of two number (e.g. r = a * b where a and b are complex number). However if you want to do operation between a complex and a non-complex you have to write r = a * hcpx:new(b, 0).

Overview:
Complex number is a type of number which has two degrees of freedom instead of one in real number. The two degrees of freedom are a real part and an imaginary part. It is written as a + bi, with "a" being the real part, "b" being the imaginary part, and i being the imaginary unit, with it's unique property i^2 = -1.
While it won't be used to tag a price of a chocolate bar, it is quite useful for a much complex stuff as the name suggest, such as quantum computing.

Downloads: 142 - Level ID: 25732