public abstract class ComplexNumber
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
double |
angle
The angle (theta) in radians, which should be between 0 and 2π.
|
double |
im
The imaginary part.
|
double |
re
The real part.
|
Constructor and Description |
---|
ComplexNumber() |
Modifier and Type | Method and Description |
---|---|
abstract ComplexNumber |
add(ComplexNumber c)
Add another complex number to this one, and return a new
instance that has the sum.
|
abstract double |
angle()
Compute and return the angle in radians, ensuring that it's between 0 and 2π.
|
abstract ComplexNumber |
conjugate()
Return the conjugate.
|
abstract double |
magnitude()
Return the magnitude.
|
static ComplexNumber |
makeComplexNumber(double re,
double im)
Make an instance of a complex number with given real and imaginary
parts.
|
abstract ComplexNumber |
mult(ComplexNumber c)
Multiply another complex number into this one, and return a new
instance that has the product.
|
abstract ComplexNumber |
mult(double a)
Multiply a real number into this complex number, and return a new
instance that has the product.
|
abstract ComplexNumber |
pow(int n)
Raise this complex number to the power n, and return a new
instance that has the power.
|
abstract ComplexNumber |
sub(ComplexNumber c)
Subtract another complex number from this one, and return a new
instance that has the difference.
|
java.lang.String |
toString()
Overrides
toString() in Object
to print the real and imaginary parts. |
public double re
public double im
public double angle
public abstract double magnitude()
public abstract double angle()
public abstract ComplexNumber add(ComplexNumber c)
public abstract ComplexNumber sub(ComplexNumber c)
public abstract ComplexNumber mult(ComplexNumber c)
public abstract ComplexNumber mult(double a)
public abstract ComplexNumber pow(int n)
public abstract ComplexNumber conjugate()
public java.lang.String toString()
toString()
in Object
to print the real and imaginary parts.toString
in class java.lang.Object
public static ComplexNumber makeComplexNumber(double re, double im)