com.apamax
Event Complex


Event that represents complex numbers in EPL.

A Complex number can be created either from the real and imaginaries parts as floating point numbers, eg:

Complex c := Complex(3.1, 5.0); // 3.1 + 5i
or by using one of the static from functions on Complex, either convenience methods, or conversion from polar coordinates in radians:

Complex c := Complex.fromPolar(7.2, float.PI/2.0); // 7.2i
There are also a number of convenince functions to return certain constants an Complex numbers.

You can inspect a Complex number using the real() and imag() functions, which return the real and imaginary parts respectively, and the arg() and abs() functions which calculate the polar versions of the Complex number.

For operating on Complex numbers this class provides operations as both static and event instance actions. Typically these have both a static version and an instance version with the name prefixed by u. The static action creates and returns a new Complex number. The instance u form will modify the complex number and return a reference to itself, to be used in chains of function calls. In other words, if add(a, b) corresponds to a + b, then a.uadd(b) corresponds to a += b. This has been done for performance reasons.
Action summary
 floatabs()

Return the magnitude of this Complex number.
 com.apamax.Complexstatic add(com.apamax.Complex a, com.apamax.Complex b)

Add two complex numbers and return a new Complex number with the result.
 floatarg()

Return the polar angle of this Complex number.
 booleanbitEquals(com.apamax.Complex b)

Returns true if both the real and imaginary parts of this Complex number are bit-equals to the real and imaginary parts of the argument.
 com.apamax.Complexstatic conjugate(com.apamax.Complex a)

Return a new Complex number which is the complex conjugate of the argument.
 com.apamax.Complexstatic cos(com.apamax.Complex a)

Returns the cosine of the argument as a new Complex number.
 com.apamax.Complexstatic divide(com.apamax.Complex a, com.apamax.Complex b)

Divide two complex numbers and return a new Complex number with the result.
 com.apamax.Complexstatic divideReal(com.apamax.Complex a, float b)

Divide the given complex number by a real divisor and return the result as a new Complex number.
 com.apamax.Complexstatic E()

Returns Euler's number e, represented as a complex number.
 com.apamax.Complexstatic exp(com.apamax.Complex a)

Exponentiate the argument and return the result as a new Complex number.
 stringformatFixed(integer dp)

Return the Complex number as a string with a fixed number of decimal places. e.g. 0.30-4.51i
 stringformatScientific(integer sf)

Return the Complex number as a string in scientific notation e.g. 1.3e-2+5.6e10i
 com.apamax.Complexstatic fromImaginaryFloat(float i)

Creates a Complex number with the given float as the imaginary part and 0 as the real part.
 com.apamax.Complexstatic fromImaginaryInteger(integer i)

Creates a Complex number with the given integer as the imaginary part and 0 as the real part.
 com.apamax.Complexstatic fromPolar(float abs, float arg)

Creates a Complex number from polar coordinates.
 com.apamax.Complexstatic fromRealFloat(float r)

Creates a Complex number with the given float as the real part and 0 as the imaginary part.
 com.apamax.Complexstatic fromRealInteger(integer r)

Creates a Complex number with the given integer as the real part and 0 as the imaginary part.
 com.apamax.Complexstatic I()

Returns the square root of -1, i, represented as a complex number.
 floatimag()

Returns the imaginary part of this Complex number.
 com.apamax.Complexstatic INFINITY()

Returns infinity + infinity*i, represented as a complex number.
 booleanisFinite()

Returns true if both parts of this Complex number are finite.
 booleanisInfinite()

Returns true if either part of this Complex number is infinite.
 booleanisNaN()

Returns true if either part of this Complex number is not a number.
 com.apamax.Complexstatic ln(com.apamax.Complex a)

Return the natural log of the argument as a new Complex number.
 com.apamax.Complexstatic max(com.apamax.Complex a, com.apamax.Complex b)

Return the larger of two Complex numbers.
 com.apamax.Complexstatic min(com.apamax.Complex a, com.apamax.Complex b)

Return the smaller of two Complex numbers.
 com.apamax.Complexstatic multiply(com.apamax.Complex a, com.apamax.Complex b)

Multiply two complex numbers and return a new Complex number with the result.
 com.apamax.Complexstatic multiplyReal(com.apamax.Complex a, float b)

Multiply the given complex number by a real divisor and return the result as a new Complex number.
 com.apamax.Complexstatic NAN()

Returns a Complex number which is not a number.
 com.apamax.Complexstatic negate(com.apamax.Complex a)

Return a new Complex number which is the negation of the argument.
 com.apamax.Complexstatic ONE()

Returns 1, represented as a complex number.
 com.apamax.Complexstatic PI()

Returns the constant pi, represented as a complex number.
 com.apamax.Complexstatic pow(com.apamax.Complex a, com.apamax.Complex b)

Return a Complex number raised to the power of a second Complex number as a new Complex number.
 floatreal()

Returns the real part of this Complex number.
 com.apamax.Complexstatic reciprocal(com.apamax.Complex a)

Return a new Complex number which is the reciprocal of the argument.
 com.apamax.Complexstatic sin(com.apamax.Complex a)

Returns the sine of the argument as a new Complex number.
 com.apamax.Complexstatic sqrt(com.apamax.Complex a)

Returns the square root of the argument as a new Complex number.
 com.apamax.Complexstatic subtract(com.apamax.Complex a, com.apamax.Complex b)

Subtract two complex numbers and return a new Complex number with the result.
 com.apamax.Complexstatic tan(com.apamax.Complex a)

Returns the tangent of the argument as a new Complex number.
 stringtoValueString()

Return the Complex number as a string. e.g. 0.3-4.5i
 com.apamax.Complexuadd(com.apamax.Complex b)

Set this Complex number to add the argument and return self.
 com.apamax.Complexuconjugate()

Assign this to its complex conjugate and return self.
 com.apamax.Complexudivide(com.apamax.Complex b)

Set this Complex number to be divided by the argument and return self.
 com.apamax.ComplexudivideReal(float b)

Set this Complex number to be divided by the real argument and return self.
 com.apamax.Complexuexp()

Set this Complex number it's exponent (ez) and return self.
 com.apamax.Complexuln()

Sets this Complex number to the natural logarithm of itself and return self.
 com.apamax.Complexumultiply(com.apamax.Complex b)

Set this Complex number to multiply by the argument and return self.
 com.apamax.ComplexumultiplyReal(float b)

Set this Complex number to be multiplied by the real argument and return self.
 com.apamax.Complexunegate()

Set this Complex number to its own negation and return self.
 com.apamax.Complexureciprocal()

Set this Complex number to its own reciprocal and return self.
 com.apamax.Complexusqrt()

Set this Complex number to its square root and return self.
 com.apamax.Complexusubtract(com.apamax.Complex b)

Set this Complex number to subtract the argument and return self.
 com.apamax.Complexstatic ZERO()

Returns 0, represented as a complex number.
 
Action detail

abs

float abs()
Return the magnitude of this Complex number.
Returns:
|a|

add

com.apamax.Complex static add(com.apamax.Complex a, com.apamax.Complex b)
Add two complex numbers and return a new Complex number with the result.
Parameters:
a
b
Returns:
a+b.

arg

float arg()
Return the polar angle of this Complex number.

bitEquals

boolean bitEquals(com.apamax.Complex b)
Returns true if both the real and imaginary parts of this Complex number are bit-equals to the real and imaginary parts of the argument.
Parameters:
b

conjugate

com.apamax.Complex static conjugate(com.apamax.Complex a)
Return a new Complex number which is the complex conjugate of the argument.
Parameters:
a

cos

com.apamax.Complex static cos(com.apamax.Complex a)
Returns the cosine of the argument as a new Complex number.
Parameters:
a
Returns:
cos(a)

divide

com.apamax.Complex static divide(com.apamax.Complex a, com.apamax.Complex b)
Divide two complex numbers and return a new Complex number with the result.
Parameters:
a
b
Returns:
a/b.

divideReal

com.apamax.Complex static divideReal(com.apamax.Complex a, float b)
Divide the given complex number by a real divisor and return the result as a new Complex number.
Parameters:
a
b
Returns:
a/b

E

com.apamax.Complex static E()
Returns Euler's number e, represented as a complex number.

exp

com.apamax.Complex static exp(com.apamax.Complex a)
Exponentiate the argument and return the result as a new Complex number.
Parameters:
a
Returns:
ea

formatFixed

string formatFixed(integer dp)
Return the Complex number as a string with a fixed number of decimal places. e.g. 0.30-4.51i
Parameters:
dp - The number of decimal places in each of the real and imaginary parts.

formatScientific

string formatScientific(integer sf)
Return the Complex number as a string in scientific notation e.g. 1.3e-2+5.6e10i
Parameters:
sf

fromImaginaryFloat

com.apamax.Complex static fromImaginaryFloat(float i)
Creates a Complex number with the given float as the imaginary part and 0 as the real part.
Parameters:
i

fromImaginaryInteger

com.apamax.Complex static fromImaginaryInteger(integer i)
Creates a Complex number with the given integer as the imaginary part and 0 as the real part.
Parameters:
i

fromPolar

com.apamax.Complex static fromPolar(float abs, float arg)
Creates a Complex number from polar coordinates.
Parameters:
abs
arg
Returns:
the Complex number abs*ei*arg

fromRealFloat

com.apamax.Complex static fromRealFloat(float r)
Creates a Complex number with the given float as the real part and 0 as the imaginary part.
Parameters:
r

fromRealInteger

com.apamax.Complex static fromRealInteger(integer r)
Creates a Complex number with the given integer as the real part and 0 as the imaginary part.
Parameters:
r

I

com.apamax.Complex static I()
Returns the square root of -1, i, represented as a complex number.

imag

float imag()
Returns the imaginary part of this Complex number.

INFINITY

com.apamax.Complex static INFINITY()
Returns infinity + infinity*i, represented as a complex number.

isFinite

boolean isFinite()
Returns true if both parts of this Complex number are finite.

isInfinite

boolean isInfinite()
Returns true if either part of this Complex number is infinite.

isNaN

boolean isNaN()
Returns true if either part of this Complex number is not a number.

ln

com.apamax.Complex static ln(com.apamax.Complex a)
Return the natural log of the argument as a new Complex number.
Parameters:
a
Returns:
ln(a)

max

com.apamax.Complex static max(com.apamax.Complex a, com.apamax.Complex b)
Return the larger of two Complex numbers.
Parameters:
a
b

min

com.apamax.Complex static min(com.apamax.Complex a, com.apamax.Complex b)
Return the smaller of two Complex numbers.
Parameters:
a
b

multiply

com.apamax.Complex static multiply(com.apamax.Complex a, com.apamax.Complex b)
Multiply two complex numbers and return a new Complex number with the result.
Parameters:
a
b
Returns:
a*b.

multiplyReal

com.apamax.Complex static multiplyReal(com.apamax.Complex a, float b)
Multiply the given complex number by a real divisor and return the result as a new Complex number.
Parameters:
a
b
Returns:
a*b

NAN

com.apamax.Complex static NAN()
Returns a Complex number which is not a number.

negate

com.apamax.Complex static negate(com.apamax.Complex a)
Return a new Complex number which is the negation of the argument.
Parameters:
a
Returns:
-a

ONE

com.apamax.Complex static ONE()
Returns 1, represented as a complex number.

PI

com.apamax.Complex static PI()
Returns the constant pi, represented as a complex number.

pow

com.apamax.Complex static pow(com.apamax.Complex a, com.apamax.Complex b)
Return a Complex number raised to the power of a second Complex number as a new Complex number.
Parameters:
a
b
Returns:
ab

real

float real()
Returns the real part of this Complex number.

reciprocal

com.apamax.Complex static reciprocal(com.apamax.Complex a)
Return a new Complex number which is the reciprocal of the argument.
Parameters:
a
Returns:
-1/a

sin

com.apamax.Complex static sin(com.apamax.Complex a)
Returns the sine of the argument as a new Complex number.
Parameters:
a
Returns:
sin(a)

sqrt

com.apamax.Complex static sqrt(com.apamax.Complex a)
Returns the square root of the argument as a new Complex number.
Parameters:
a
Returns:
a1/2

subtract

com.apamax.Complex static subtract(com.apamax.Complex a, com.apamax.Complex b)
Subtract two complex numbers and return a new Complex number with the result.
Parameters:
a
b
Returns:
a-b.

tan

com.apamax.Complex static tan(com.apamax.Complex a)
Returns the tangent of the argument as a new Complex number.
Parameters:
a
Returns:
tan(a)

toValueString

string toValueString()
Return the Complex number as a string. e.g. 0.3-4.5i

uadd

com.apamax.Complex uadd(com.apamax.Complex b)
Set this Complex number to add the argument and return self.
Parameters:
b

uconjugate

com.apamax.Complex uconjugate()
Assign this to its complex conjugate and return self.

udivide

com.apamax.Complex udivide(com.apamax.Complex b)
Set this Complex number to be divided by the argument and return self.
Parameters:
b

udivideReal

com.apamax.Complex udivideReal(float b)
Set this Complex number to be divided by the real argument and return self.
Parameters:
b

uexp

com.apamax.Complex uexp()
Set this Complex number it's exponent (ez) and return self.

uln

com.apamax.Complex uln()
Sets this Complex number to the natural logarithm of itself and return self.

umultiply

com.apamax.Complex umultiply(com.apamax.Complex b)
Set this Complex number to multiply by the argument and return self.
Parameters:
b

umultiplyReal

com.apamax.Complex umultiplyReal(float b)
Set this Complex number to be multiplied by the real argument and return self.
Parameters:
b

unegate

com.apamax.Complex unegate()
Set this Complex number to its own negation and return self.

ureciprocal

com.apamax.Complex ureciprocal()
Set this Complex number to its own reciprocal and return self.

usqrt

com.apamax.Complex usqrt()
Set this Complex number to its square root and return self.

usubtract

com.apamax.Complex usubtract(com.apamax.Complex b)
Set this Complex number to subtract the argument and return self.
Parameters:
b

ZERO

com.apamax.Complex static ZERO()
Returns 0, represented as a complex number.