Complex - A Complex Float Type.
{ x, y }
For Convinence you can declare in several ways eg:
var c0: Complex = '1 + 2i';
var c1: Complex = { real: 1., imaginary: 2. };
var c2: Complex = { r: 1., i: 2. };
var c3: Complex = new Complex({ x: 1., y: 2. });
You can use normal operations
var c4 = c0 * c1;
var c5 = c0 + c1;
You can extract either part
var real = c0.real;
var imaginary = c0.i;
You can trace it. trace( Complex.fromString( c0 ) ); // '1. + 2. i'
Trig functions are contained in geom.curve.ComplexTrig, but do not have tests beyond compile.
Static variables
staticread onlyiInfinity:Complex
>>> ({
... Complex.iInfinity == new Complex({x:0.
... , y:Math.POSITIVE_INFINITY});
... }) == true
staticread onlyiMinus1:Complex
>>> ({
... Complex.iMinus1 == new Complex({x: 0.
... , y: -1.});
... }) == true
staticread onlyiMinusInfinity:Complex
>>> ({
... Complex.iMinusInfinity == new Complex({x:0.
... , y:Math.NEGATIVE_INFINITY});
... }) == true
staticread onlyiMinusPi:Complex
>>> ({
... Complex.iMinusPi == new Complex({x:0.
... , y:(-Math.PI)});
... }) == true
staticread onlyiMinusTau:Complex
>>> ({
... Complex.iMinusTau == new Complex({x:0.
... , y:(-Math.PI*2)});
... }) == true
staticread onlyiPi:Complex
>>> ({
... Complex.iPi == new Complex({x:0.
... , y:(Math.PI)});
... }) == true
staticread onlyiTau:Complex
>>> ({
... Complex.iTau == new Complex({x:0.
... , y:(Math.PI*2)});
... }) == true
staticmagnitude:Float
>>> ({
... var a = new Complex({ x: 3, y: 4});
... a.magnitude == 5.; }) == true
staticread onlyminus1:Complex
>>> ({
... Complex.minus1 == new Complex({x: -1.
... , y: 0.});
... }) == true
staticread onlyminusInfinity:Complex
>>> ({
... Complex.minusInfinity == new Complex({x:Math.NEGATIVE_INFINITY
... , y:0.});
... }) == true
staticread onlyminusPi:Complex
>>> ({
... Complex.minusPi == new Complex({x:(-Math.PI)
... , y:0.});
... }) == true
staticread onlyminusTau:Complex
>>> ({
... Complex.minusTau == new Complex({x:(-Math.PI*2)
... , y:0.});
... }) == true
staticread onlyminusUnit:Complex
>>> ({
... Complex.minusUnit == new Complex({x: -1.
... , y: -1.});
... }) == true
staticread onlynegPosInfinity:Complex
>>> ({
... Complex.negPosInfinity == new Complex({x:Math.NEGATIVE_INFINITY
... , y:Math.POSITIVE_INFINITY});
... }) == true
staticread onlynegPosPi:Complex
>>> ({
... Complex.negPosPi == new Complex({x:(-Math.PI)
... , y:(Math.PI)});
... }) == true
staticread onlynegPosTau:Complex
>>> ({
... Complex.negPosTau == new Complex({x:(-Math.PI*2)
... , y:(Math.PI*2)});
... }) == true
staticread onlyposNegInfinity:Complex
>>> ({
... Complex.posNegInfinity == new Complex({x:Math.POSITIVE_INFINITY
... , y:Math.NEGATIVE_INFINITY});
... }) == true
staticread onlyposNegPi:Complex
>>> ({
... Complex.posNegPi == new Complex({x:(Math.PI)
... , y:(-Math.PI)});
... }) == true
staticread onlyposNegTau:Complex
>>> ({
... Complex.posNegTau == new Complex({x:(Math.PI*2)
... , y:(-Math.PI*2)});
... }) == true
staticread onlyrealInfinity:Complex
>>> ({
... Complex.realInfinity == new Complex({x:Math.POSITIVE_INFINITY
... , y:0.});
... }) == true
staticread onlyrealPi:Complex
>>> ({
... Complex.realPi == new Complex({x:(Math.PI)
... , y:0.});
... }) == true
staticread onlyrealTau:Complex
>>> ({
... Complex.realTau == new Complex({x:(Math.PI*2)
... , y:0.});
... }) == true
staticread onlyunit:Complex
>>> ({
... Complex.unit == new Complex({x: 1.
... , y: 1.});
... }) == true
staticread onlyunitInfinity:Complex
>>> ({
... Complex.unitInfinity == new Complex({x:Math.POSITIVE_INFINITY
... , y:Math.POSITIVE_INFINITY});
... }) == true
staticread onlyunitMinusInfinity:Complex
>>> ({
... Complex.unitMinusInfinity == new Complex({x:Math.NEGATIVE_INFINITY
... , y:Math.NEGATIVE_INFINITY});
... }) == true
staticread onlyunitMinusPi:Complex
>>> ({
... Complex.unitMinusPi == new Complex({x:(-Math.PI)
... , y:(-Math.PI)});
... }) == true
staticread onlyunitMinusTau:Complex
>>> ({
... Complex.unitMinusTau == new Complex({x:(-Math.PI*2)
... , y:(-Math.PI*2)});
... }) == true
staticread onlyunitPi:Complex
>>> ({
... Complex.unitPi == new Complex({x:(Math.PI)
... , y:(Math.PI)});
... }) == true
Static methods
staticinlineadd(a:Complex, b:Complex):Complex
>>> ({
... var a = Complex.unit;
... a + a == new Complex({ x: 2., y: 2. });
... }) == true
staticinlineaddExponents(this:Mat1x2):Float
>>> ({
... var a = new Complex({ x: 3., y: 2. });
... a.addExponents() == 5;
... }) == true
staticinlinearg(c:Complex):Float
>>> ({
... var a = new Complex({ x: 3, y: 4});
... var b = new Complex({ x: 6, y: 8});
... var arg = Complex.arg;
... arg( a*b ) == arg( a ) + arg( b ); }) == true
staticinlinecis(angle:Float):Complex
>>> ({
... var r = 12;
... var theta = Math.PI/4;
... var cis = Complex.cis;
... var square = Complex.square;
... square(r*cis( theta )) == r*r*cis( 2*theta ); }) == true
staticinlineclone(this:Mat1x2):Complex
>>> ({
... var a = new Complex({ x: 1., y: 2. });
... a.clone() == a; }) == true
staticinlineconjugate(a:Complex):Complex
>>> ({
... var a = new Complex({ x: 1., y: 2. });
... var b = ~a;
... b == new Complex({ x: 1., y: -2. }); }) == true
staticinlinedivide(c1:Complex, c2:Complex):Complex
>>> ({
... var a = new Complex({ x: 1., y: -3. });
... var b = new Complex({ x: 1., y: 2. });
... a / b == new Complex({ x:-1, y: -1 });
... }) == true
staticinlineequal(a:Complex, b:Complex):Bool
>>> ({
... var a = new Complex({ x: 1., y: 2. });
... var b = new Complex({ x: 1., y: 2. });
... a == b; }) == true
staticinlineexp(c:Complex):Complex
>>> ({
... var r = 12;
... var theta = Math.PI/4;
... var cis = Complex.cis;
... var fromCircle = Complex.fromCircle;
... var exp = Complex.exp;
... fromCircle(r,theta) == r*exp( new Complex({ x: 0, y: theta }) ); }) == true
staticinlinefromCircle(r:Float, angle:Float):Complex
>>> ({
... var r = 12;
... var theta = Math.PI/4;
... var cis = Complex.cis;
... var square = Complex.square;
... var fromCircle = Complex.fromCircle;
... square(fromCircle(r,theta)) == fromCircle( r*r, 2*theta ); }) == true
staticinlinefromRealI(c:{real:Float, i:Float}):Complex
>>> ({
... var c0: Complex = { real: 1., i: 2. };
... var c1 = new Complex({ x: 1., y: 2. });
... c1 == c0; }) == true
staticinlinefromRealImaginary(c:{real:Float, imaginary:Float}):Complex
>>> ({
... var c0: Complex = { real: 1., imaginary: 2. };
... var c1 = new Complex({ x: 1., y: 2. });
... c1 == c0; }) == true
staticinlinefromRi(c:{r:Float, i:Float}):Complex
>>> ({
... var c0: Complex = { r: 1., i: 2. };
... var c1 = new Complex({ x: 1., y: 2. });
... c1 == c0; }) == true
staticinlinefromString(s:String):Complex
>>> ({
... var c0: Complex = '1 + 2i';
... var c1 = new Complex({ x: 1., y: 2. });
... c1 == c0; }) == true
staticinlineisImaginary(this:Mat1x2):Bool
>>> ({
... var a = Complex.i1;
... a.isImaginary() == true; }) == true
staticinlineisReal(this:Mat1x2):Bool
>>> ({
... var a = Complex.one;
... a.isReal() == true; }) == true
staticinlineln(c:Complex):Complex
>>> ({
... var a = new Complex({ x: 3, y: 4});
... var b = new Complex({ x: 6, y: 8});
... var ln = Complex.ln;
... ln( a*b ) == ln( a ) + ln( b ); }) == true
staticinlinemagnitudeSquared(this:Mat1x2):Float
>>> ({
... var a = new Complex({ x: 2., y: 4. });
... a.magnitudeSquared() == 4. + 16.; }) == true
staticinlinemultiply(a:Complex, b:Complex):Complex
>>> ({
... var a = new Complex({ x: 3., y: 2. });
... var b = new Complex({ x: 1., y: 7. });
... a * b == new Complex({ x: -11., y: 23. });
... }) == true
staticinlinenegate(a:Complex):Complex
>>> ({
... var a = new Complex({ x: 1., y: 2. });
... var b = -a;
... b == new Complex({ x: -1., y: -2. }); }) == true
staticinlinenotEqual(a:Complex, b:Complex):Bool
>>> ({
... var a = new Complex({ x: 1., y: 2. });
... var b = new Complex({ x: 1., y: 1. });
... a != b; }) == true
staticinlinesquare(c:Complex):Complex
>>> ({
... var r = 12;
... var theta = Math.PI/4;
... var cis = Complex.cis;
... var square = Complex.square;
... var fromCircle = Complex.fromCircle;
... square(fromCircle(r,theta)) == fromCircle( r*r, 2*theta ); }) == true
staticinlinesubtract(a:Complex, b:Complex):Complex
>>> ({
... var a = Complex.unit;
... a - a == Complex.zero;
... }) == true