|
ccomplex Specification SheetComputer Algebra Kit (c) 1993,00 by Comp.Alg.Objects. All Rights Reserved.
ComplexInherits from: CAObjectMaturity Index: Relatively immature
Class DescriptionA complex object consists of two real objects, a real and imaginary part. Real objects could be arbitrary Computer Algebra Kit objects, but the class has been used so far only for the Gaussian integers i.e., complex numbers over the integers. The imaginary unit is represented by the symbol I.
Method typesCreationIdentityConjugationAdditionMultiplicationComplex DivisionGreatest Common DivisorPrintingMethodsreal:+real:aRealReturns a new complex object with real part set to aReal and the imaginary part set to the real zero.
real:imaginary:+real:aRealimaginary:anotherRealReturns a new complex object with real part set to aReal and the imaginary part set to anotherReal.
copy-copyReturns a new copy of the complex object.
deepCopy-deepCopyReturns a new copy of the complex object; sends deepCopy messages to real and imaginary part.
real-realReturns the real part of a complex number.
imaginary-imaginaryReturns the imaginary part of a complex number.
isReal- (BOOL)isRealWhether the imaginary part is equal to zero.
notReal- (BOOL)notRealWhether the isReal returns NO.
hash- (unsigned)hashReturns a small integer that is the same for objects that are equal in the sense of isEqual:.
isEqual:- (BOOL)isEqual:bWhether real and imaginary parts are equal to each other.
conjugate-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.
norm-normReturns a new real object, the norm of the complex object i.e., the object multiplied by its conjugate.
asReal-asRealIf the imaginary part of the object is zero, this method returns a new reference to the real part of the object.
zero-zeroReturns a new complex object with real and imaginary part equal to zero.
isZero- (BOOL)isZeroWhether real and imaginary part are equal to zero.
isOpposite:- (BOOL)isOpposite:bWhether real and imaginary parts are opposite to each other.
negate-negateReturns a new complex number, by negating real and imaginary parts.
double-doubleReturns a new complex number, by doubling real and imaginary parts.
add:-add:bReturns the sum of the complex numbers; adds real and imaginary parts together.
subtract:-subtract:bReturns the difference of the complex numbers; subtracts real and imaginary parts from each other.
I-IReturns a new reference to the imaginary unit.
one-oneReturns a new object with real part equal to one and imaginary part equal to zero.
isOne- (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.
isMinusOne- (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.
isUnit- (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.
square-squareReturns the complex number multiplied by itself, computed by the rule :
(a+I b)^2 == (a^2 - b^2) + I (2 a b) multiply:-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:-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:-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.
inverse-inverseReturns the conjugate of the complex number divided by its norm, or nil if the latter division is not exact.
quotient:-quotient:bReturns the quotient on division by b. Note: I'm not sure about the algorithm I'm using here !
remainder:quotient:-remainder:bquotient:(id *)qComputes the remainder, and if q is non-NULL pointer, the quotient on division by b.
gcd:-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:-printOn:(IOD)aFilePrints the number to aStream.
|