@ThreadSafety(level=IMMUTABLE) public final class Complex extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static Complex |
I
Complex imaginary number I (Square root of -1).
|
static Complex |
NOT_A_NUMBER
Complex number representing NaN (Not a Number).
|
static Complex |
ONE
Complex number with a value of one.
|
static Complex |
TWO
Complex number with a value of two.
|
static Complex |
ZERO
Complex number with a value of zero.
|
| Constructor and Description |
|---|
Complex(double real,
double imaginary)
Constructs this Complex number from the supplied real and imaginary
parts.
|
| Modifier and Type | Method and Description |
|---|---|
Complex |
add(Complex complex)
Adds the supplied Complex number to this Complex number.
|
static Complex |
add(Complex left,
Complex right)
Computes left + right.
|
Complex |
divide(Complex complex)
Multiplies this Complex number by the supplied Complex number.
|
static Complex |
divide(Complex left,
Complex right)
Computes left * right.
|
boolean |
equals(Object object)
Determines whether this object and the supplied object are the same.
|
double |
getImaginary()
Gets the imaginary part of this Complex number.
|
double |
getReal()
Gets the real part of this Complex number.
|
int |
hashCode()
Creates a hash code for this Complex number.
|
boolean |
isInfinite()
Determines whether this Complex number is Infinite..
|
boolean |
isNaN()
Determines whether this Complex number is NaN (Not a Number).
|
Complex |
multiply(Complex complex)
Multiplies this Complex number by the supplied Complex number.
|
static Complex |
multiply(Complex left,
Complex right)
Computes left * right.
|
Complex |
negate()
Negates this Complex number.
|
Complex |
subtract(Complex complex)
Subtracts the supplied Complex number from this Complex number.
|
static Complex |
subtract(Complex left,
Complex right)
Computes left - right.
|
String |
toString()
Creates a String representation of this Complex number.
|
static Complex |
valueOf(double real,
double imaginary)
Creates a Complex number from the supplied real and imaginary parts.
|
public static final Complex ZERO
public static final Complex ONE
public static final Complex TWO
public static final Complex I
public static final Complex NOT_A_NUMBER
public Complex(double real,
double imaginary)
real - The real part for this Complex number.imaginary - The imaginary part for this Complex number.public static Complex valueOf(double real, double imaginary)
real - The real part for this Complex number.imaginary - The imaginary part for this Complex number.public double getReal()
public double getImaginary()
public Complex negate()
public Complex add(Complex complex)
complex - The Complex number to add to this Complex number.NullPointerException - When the supplied Complex number is null.public static Complex add(Complex left, Complex right)
left - The Complex number at the left of the plus operator.right - The Complex number at the right of the plus operator.NullPointerException - When either the supplied left or right
Complex number is null.public Complex subtract(Complex complex)
complex - The Complex number to subtract from this Complex number.NullPointerException - When the supplied Complex number is null.public static Complex subtract(Complex left, Complex right)
left - The Complex number at the left of the minus operatorright - The Complex number at the right of the minus operator.NullPointerException - When either the supplied left or right
Complex number is null.public Complex multiply(Complex complex)
complex - The Complex number to multiply with.NullPointerException - When the supplied Complex number is null.public static Complex multiply(Complex left, Complex right)
left - The Complex number at the left of the multiply operator.right - The Complex number at the right of the multiply operator.NullPointerException - When either the supplied left or right
Complex number is null.public Complex divide(Complex complex)
complex - The Complex number to multiply with.NullPointerException - When the supplied Complex number is null.public static Complex divide(Complex left, Complex right)
left - The Complex number at the left of the multiply operator.right - The Complex number at the right of the multiply operator.NullPointerException - When either the supplied left or right
Complex number is null.public boolean isNaN()
public boolean isInfinite()
Double.POSITIVE_INFINITY or
Double.NEGATIVE_INFINITY.public boolean equals(Object object)
public int hashCode()
Copyright © 2008–2017. All rights reserved.