public class Complex
extends java.lang.Object
implements java.lang.Cloneable
| Constructor and Description |
|---|
Complex(double x,
double y)
Creates a complex number with the real part x and the
imaginary part y.
|
| Modifier and Type | Method and Description |
|---|---|
Complex |
add(Complex that)
Returns a complex number whose value is (this + that).
|
static Complex |
add(Complex a,
Complex b)
Returns a complex number whose value is (a + b).
|
double |
arg()
Returns the argument of this complex number
(the angle in radians with the x-axis in polar coordinates).
|
Complex |
clone()
Returns a clone of this complex number.
|
Complex |
div(Complex that)
Returns a complex number whose value is (this / that).
|
static Complex |
div(Complex a,
Complex b)
Returns a complex number whose value is (a / b).
|
boolean |
equals(java.lang.Object o)
Returns true of this complex number is equal to the specified
complex number.
|
int |
hashCode()
Returns a hash code for this complex number.
|
double |
img()
Returns the imaginary part of the complex number.
|
boolean |
isNaN()
Returns true if this complex numer is not a number (NaN).
|
static void |
main(java.lang.String[] args) |
double |
mod()
Returns the modulo of this complex number.
|
Complex |
mul(Complex that)
Returns a complex number whose value is (this * that).
|
static Complex |
mul(Complex a,
Complex b)
Returns a complex number whose value is (a * b).
|
double |
real()
Returns the real part of the complex number.
|
Complex |
sqrt()
Returns the principal branch of the square root of this complex number.
|
Complex |
sub(Complex that)
Returns a complex number whose value is (this - that).
|
static Complex |
sub(Complex a,
Complex b)
Returns a complex number whose value is (a - b).
|
java.lang.String |
toString()
Returns a descriptive string representation of this complex number.
|
public Complex(double x,
double y)
x - real part of the complex numbery - imaginary part of the complex numberpublic double real()
public double img()
public Complex add(Complex that)
that - A complex number.public static Complex add(Complex a, Complex b)
a - A complex number.b - A complex number.public Complex sub(Complex that)
that - A complex number.public static Complex sub(Complex a, Complex b)
a - A complex number.b - A complex number.public Complex mul(Complex that)
that - A complex number.public static Complex mul(Complex a, Complex b)
a - A complex number.b - A complex number.public Complex div(Complex that)
that - A complex number.public static Complex div(Complex a, Complex b)
a - A complex number.b - A complex number.public double arg()
public double mod()
public Complex sqrt()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic Complex clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isNaN()
public static void main(java.lang.String[] args)