public class Complex
extends java.lang.Object
implements java.lang.Cloneable
Constructor and Description |
---|
Complex()
Default constructor creates zero.
|
Complex(double r,
double i)
Constructor from real and imaginary parts.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
Complex |
conjugate()
Returns the complex conjugate.
|
Complex |
cos()
Returns the cosine.
|
Complex |
cosh() |
static double |
cosh(double a) |
Complex |
divide(Complex c)
Complex division.
|
boolean |
equals(Complex c) |
double |
imag()
Returns the imaginary part.
|
double |
imaginary()
Returns the imaginary part.
|
Complex |
inverse()
Reciprocates the complex number.
|
boolean |
isZero()
Tests for equality with zero.
|
double |
mag()
Returns the magnitude.
|
double |
mod()
Returns the modulus.
|
Complex |
negate()
Negates the complex number.
|
Complex |
plus(Complex c)
Adds complex numbers.
|
Complex |
positive()
Makes both components positive.
|
double |
real()
Returns the real part.
|
Complex |
sin()
Returns the sine.
|
Complex |
sinh() |
static double |
sinh(double a) |
Complex |
sqrt()
Returns the square root.
|
Complex |
subtract(Complex c)
Subtracts complex numbers.
|
Complex |
tan()
Returns the tangent.
|
Complex |
tanh() |
static double |
tanh(double a) |
Complex |
times(Complex c)
Multiplies complex numbers.
|
Complex |
times(double d)
Multiplies by a scalar.
|
java.lang.String |
toString() |
public Complex(double r, double i)
r
- Real part.i
- Imaginary part.public Complex()
public java.lang.Object clone()
clone
in class java.lang.Object
public double real()
public double imag()
public double imaginary()
public double mod()
public double mag()
public boolean equals(Complex c)
public boolean isZero()
public java.lang.String toString()
toString
in class java.lang.Object
public Complex plus(Complex c)
c
- Complex number to add.public Complex subtract(Complex c)
c
- Complex number to subtract.public Complex times(Complex c)
c
- Complex number to multiply by.public Complex times(double d)
d
- Scalar to multiply by.public Complex divide(Complex c) throws ComplexNumberException
c
- Complex number to divide by.ComplexNumberException
public Complex negate()
public Complex positive()
public Complex inverse() throws ComplexNumberException
ComplexNumberException
public Complex conjugate()
public Complex sqrt()
public Complex sin()
public Complex cos()
public Complex tan() throws ComplexNumberException
ComplexNumberException
public static double sinh(double a)
public static double cosh(double a)
public static double tanh(double a)
public Complex sinh()
public Complex cosh()
public Complex tanh()