public final class Complex extends Object implements IEquatable<Complex>, ImmutableValueType
Constructor and Description |
---|
Complex()
Initializes a new instance.
|
Complex(double real)
Initializes a new instance with only the real component.
|
Complex(double real,
double imaginary)
Initializes a new instance with real and imaginary components.
|
Modifier and Type | Method and Description |
---|---|
static Complex |
abs(Complex value)
Compute the absolute value and returns the result.
|
static Complex |
acos(Complex x)
Calculates the arc cosine of the input value.
|
static Complex |
acosh(Complex x)
Calculates the inverse hyperbolic
cosine of a value.
|
static Complex |
add(Complex left,
Complex right)
Adds two complex numbers and returns the result.
|
static Complex |
conjugate(Complex value)
Computes the conjugate for a complex number and returns the result.
|
static Complex |
cos(Complex x)
Calculates the cosine of the input complex value.
|
static Complex |
divide(Complex dividend,
Complex divisor)
Divides one complex number by another and returns the result.
|
static Complex |
divide(Complex dividend,
double scalar)
Divides one complex number by a scalar and returns the result.
|
static boolean |
equals(Complex left,
Complex right)
Returns
true if the two instances are exactly equal. |
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
boolean |
equalsType(Complex other)
Indicates whether another instance of this type is exactly equal to this instance.
|
static Complex |
exp(Complex c)
Returns e raised to the specified power.
|
double |
getImaginary()
Gets the imaginary component of the complex number.
|
static Complex |
getImaginaryOne()
Gets a
Complex value of i. |
double |
getMagnitude()
Gets the magnitude of the complex number.
|
double |
getMagnitudeSquared()
Gets the square of the magnitude of the complex number.
|
static Complex |
getOne()
Gets a
Complex value of 1. |
double |
getPhase()
Gets the phase of the complex number.
|
double |
getReal()
Gets the real component of the complex number.
|
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
static Complex |
log(Complex x)
Calculates the complex natural logarithm of the input value.
|
static Complex |
multiply(Complex left,
Complex right)
Returns the product of two complex numbers.
|
static Complex |
negate(Complex value)
Negates the
Complex value. |
static boolean |
notEquals(Complex left,
Complex right)
Returns
true if the two instances are not exactly equal. |
static Complex |
pow(Complex x,
Complex power)
Calculates the complex square root of the input value.
|
static Complex |
sign(Complex x)
Returns the sign of a complex value
as either a -1 or +1.
|
static Complex |
sqrt(Complex x)
Calculates the complex square root of the input value.
|
static Complex |
subtract(Complex left,
Complex right)
Subtracts two complex numbers and returns the result.
|
static Complex |
toComplex(double real)
Implicit conversion from double to complex number.
|
String |
toString()
Returns a string which represents the complex number.
|
public Complex()
public Complex(double real)
real
- The real component of the complex value.public Complex(double real, double imaginary)
real
- The real component of the complex value.imaginary
- The imaginary component of the complex value.public final double getReal()
public final double getImaginary()
public final double getMagnitude()
public final double getMagnitudeSquared()
public final double getPhase()
@Nonnull public static Complex add(@Nonnull Complex left, @Nonnull Complex right)
left
- The first complex number to add.right
- The second complex number to add.@Nonnull public static Complex negate(@Nonnull Complex value)
Complex
value.value
- The value to negate.@Nonnull public static Complex subtract(@Nonnull Complex left, @Nonnull Complex right)
left
- The complex number to subtract from.right
- The complex number to subtract.@Nonnull public static Complex multiply(@Nonnull Complex left, @Nonnull Complex right)
left
- The first complex number to multiply.right
- The second complex number to multiply.@Nonnull public static Complex divide(@Nonnull Complex dividend, @Nonnull Complex divisor)
dividend
- The complex number to be divided.divisor
- The complex number to divide by.@Nonnull public static Complex divide(@Nonnull Complex dividend, double scalar)
dividend
- The complex number to be divided.scalar
- The scalar to divisor.@Nonnull public static Complex conjugate(@Nonnull Complex value)
value
- A complex number.@Nonnull public static Complex abs(@Nonnull Complex value)
value
- The complex value from which the absolute value is computed.public static boolean equals(@Nonnull Complex left, @Nonnull Complex right)
true
if the two instances are exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
represents the same value as right
; otherwise false
.public static boolean notEquals(@Nonnull Complex left, @Nonnull Complex right)
true
if the two instances are not exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
does not represent the same value as right
; otherwise false
.public final boolean equalsType(@Nonnull Complex other)
equalsType
in interface IEquatable<Complex>
other
- The instance to compare to this instance.true
if other
represents the same value as this instance; otherwise false
.public boolean equals(Object obj)
equals
in class Object
obj
- The object to compare to this instance.true
if obj
is an instance of this type and represents the same value as this instance; otherwise false
.Object.hashCode()
,
HashMap
@Nonnull public static Complex exp(@Nonnull Complex c)
c
- A complex value specifying a power.c
public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
@Nonnull public static Complex toComplex(double real)
real
- The real component of the complex number.@Nonnull public static Complex pow(@Nonnull Complex x, @Nonnull Complex power)
x
- The input complex number.power
- The power to raise the complex number to.@Nonnull public static Complex sqrt(@Nonnull Complex x)
x
- The input complex number.@Nonnull public static Complex log(@Nonnull Complex x)
x
- The input complex number.@Nonnull public static Complex cos(@Nonnull Complex x)
x
- The input value.@Nonnull public static Complex acos(@Nonnull Complex x)
x
- The input value.@Nonnull public static Complex acosh(@Nonnull Complex x)