Maturity Index: Relatively immature
+real:aRealReturns a new complex object with real part set to aReal and the imaginary part set to the real zero.
+real:aRealimaginary:anotherRealReturns a new complex object with real part set to aReal and the imaginary part set to anotherReal.
-copyReturns a new copy of the complex object.
-deepCopyReturns a new copy of the complex object; sends deepCopy messages to real and imaginary part.
-realReturns the real part of a complex number.
-imaginaryReturns the imaginary part of a complex number.
- (BOOL)isRealWhether the imaginary part is equal to zero.
- (BOOL)notRealWhether the isReal returns NO.
- (unsigned)hashReturns a small integer that is the same for objects that are equal in the sense of isEqual:.
- (BOOL)isEqual:bWhether real and imaginary parts are equal to each other.
-conjugateReturns a new reference to the object if it is real. Otherwise, returns a new object that is equal to the complex conjugate of the object. The conjugate of a + I b is a - I b.
-normReturns a new real object, the norm of the complex object i.e., the object multiplied by its conjugate.
-asRealIf the imaginary part of the object is zero, this method returns a new reference to the real part of the object.
-zeroReturns a new complex object with real and imaginary part equal to zero.
- (BOOL)isZeroWhether real and imaginary part are equal to zero.
- (BOOL)isOpposite:bWhether real and imaginary parts are opposite to each other.
-negateReturns a new complex number, by negating real and imaginary parts.
-doubleReturns a new complex number, by doubling real and imaginary parts.
-add:bReturns the sum of the complex numbers; adds real and imaginary parts together.
-subtract:bReturns the difference of the complex numbers; subtracts real and imaginary parts from each other.
-IReturns a new reference to the imaginary unit.
-oneReturns a new object with real part equal to one and imaginary part equal to zero.
- (BOOL)isOneWhether the complex object is a multiplicative unit. The complex units consist of the real units and the real units multiplied by the imaginary unit i.
- (BOOL)isMinusOneWhether the complex object is a multiplicative unit. The complex units consist of the real units and the real units multiplied by the imaginary unit i.
- (BOOL)isUnitWhether the complex object is a multiplicative unit. The complex units consist of the real units and the real units multiplied by the imaginary unit i.
-squareReturns the complex number multiplied by itself, computed by the rule :
(a+I b)^2 == (a^2 - b^2) + I (2 a b)
-multiply:bReturns the product of the two complex numbers, computed by the rule :
(a+I b)(c+I d) == (ac-bd) + I (ad+bc)
-power:(int)nReturns the complex number raised to the n-th power. If the object is real, simply computes the n-th power as a real. Otherwise, computes the power by the binary exponentation algorithm.
-divide:bReturns the exact quotient of the complex number by the complex number b. Multiplies by the conjugate of b and then divides by the norm of b, or returns nil if the latter division is not exact.
-inverseReturns the conjugate of the complex number divided by its norm, or nil if the latter division is not exact.
-quotient:bReturns the quotient on division by b.
Note: I'm not sure about the algorithm I'm using here !
-remainder:bquotient:(id *)qComputes the remainder, and if q is non-NULL pointer, the quotient on division by b.
-gcd:bIf both objects are real, returns a complex object with real part set to the (real) gcd of the objects. Otherwise, computes the greatest common divisor by the Euclidean algorithm.
-printOn:(IOD)aFilePrints the number to aStream.