imaginary.py

Complex class

Complex is a class for complex numbers. Each instance has a coupled numbers; real and imaginary part of the number.

constructor

Complex(re [, im])

Create a complex number. re can be either real or complex number. If re is real and im is not given, then its imaginary part is zero. The real part can be accessed as the attribute real, and imaginary part imag.

methods

arg()

Return the angle between the x-axis and the number in the Gaussian plane.

conjugate()

Return the complex conjugate of the number.

copy()

Copy the number.

inverse()

Return the inverse of the number. If the number is zero, ZeroDivisionError is raised.

operators

+addition
-subtraction
*multiplication
/division
**, powpowering
==equality
!=not equal
+(unary)copy
-(unary)negation
reprrepr string like "Complex(1, 1)"
strstr string like "1 + 1j"
complexconvert to Python complex
absabsolute value

All comparison operators (<, <=, >=, >) are prohibited, and an attempt raises TypeError.


Last-modified: 2005-09-28 (¿å) 13:50:47