Class complex

Complex number type.

The constructor (complex) is in the global namespace (global.complex).

Complex numbers support basic operations +,-,*,/ among themselves or with regular numbers.

The real or imaginary part can be accessed with .r or .i (i.e. z.r or z.i). This works for setting and getting the value.

Methods

complex:set (x[, y=0]) Set complex number from another, or 1 or 2 real numbers.
complex:conj () Return complex conjugate.
complex:peq (z) Add another number to this one (+=).
complex:meq (z) Subtract another number from this one (-=).
complex:sqrt () Return square root.
complex:norm2 () Return absolute value squared.


Methods

complex:set (x[, y=0])
Set complex number from another, or 1 or 2 real numbers.

Parameters:

  • x number or complex real part or complex value
  • y number imaginary part (only if x is not complex) (default 0)
complex:conj ()
Return complex conjugate.

Returns:

    complex conjugate of self
complex:peq (z)
Add another number to this one (+=).

Parameters:

  • z real or complex number to add to self
complex:meq (z)
Subtract another number from this one (-=).

Parameters:

  • z real or complex number to subtract from self
complex:sqrt ()
Return square root.

Returns:

    complex square root of self
complex:norm2 ()
Return absolute value squared.

Returns:

    complex absolute value squared of self
generated by LDoc 1.4.2