Implementations of arithmetic operations handle NaN and
infinite values according to the rules for java., i.e.
equals is an equivalence relation for all instances that have
a NaN in either real or imaginary part, e.g. the following are
considered equal:
1 + NaNiNaN + iNaN + NaNi
Note that this contradicts the IEEE-754 standard for floating
point numbers (according to which the test x == x must fail if
x is NaN). The method
equals for primitive double in org.
conforms with IEEE-754 while this class conforms with the standard behavior
for Java object types.
| Modifier and Type | Field and Description |
|---|---|
| public static final Complex | I
The square root of -1. |
| private final double | imaginary
The imaginary part. |
| public static final Complex | INF
A complex number representing "+INF + INFi" |
| private final transient boolean | isInfinite
Record whether this complex number is infinite. |
| private final transient boolean | isNaN
Record whether this complex number is equal to NaN. |
| public static final Complex | NaN
A complex number representing "NaN + NaNi" |
| public static final Complex | ONE
A complex number representing "1.0 + 0.0i" |
| private final double | real
The real part. |
| private static final long | serialVersionUID
Serializable version identifier |
| public static final Complex | ZERO
A complex number representing "0.0 + 0.0i" |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Complex(double
Real part. real, double Imaginary part. imaginary)Create a complex number given the real and imaginary parts. |
| Modifier and Type | Method and Description |
|---|---|
| public double | |
| public Complex | Returns: the inverse cosine of this complex number.Compute the inverse cosine of this complex number. |
| public Complex | Returns: this + addend.Value to be added to this addend)Complex.Implements org. Returns a |
| public Complex | Returns: this + addend.Value to be added to this addend)Complex.Implements org. Returns a |
| public Complex | Returns: the inverse sine of this complex number.Compute the inverse sine of this complex number. |
| public Complex | Returns: the inverse tangent of this complex numberCompute the inverse tangent of this complex number. |
| public Complex | Returns: the conjugate of this Complex object.Returns the conjugate of this complex number. |
| public Complex | |
| public Complex | Returns: the hyperbolic cosine of this complex number.Compute the hyperbolic cosine of this complex number. |
| protected Complex | Returns: a new complex number instance.Real part. realPart, double Imaginary part. imaginaryPart)Create a complex number given the real and imaginary parts. |
| public Complex | Returns: this / divisor.Value by which this divisor)Complex is to be divided.Implements org. Returns a |
| public Complex | Returns: this / divisor.Value by which this divisor)Complex is to be divided.Implements org. Returns a |
| public boolean | Returns: true if the objects are equal, false if object
is null, not an instance of Complex, or not equal to
this instance.Object to test for equality with this instance. other)Overrides java. Test for equality with another object. |
| public static boolean | Returns: true if there are fewer than maxUlps floating
point values between the real (resp. imaginary) parts of x
and y.First value (cannot be x, Complex null).Second value (cannot be y, int null).(maxUlps - 1) is the number of floating point
values between the real (resp. imaginary) parts of x and
y.Test for the floating-point equality between Complex objects. |
| public static boolean | Returns: true if the values are equal.First value (cannot be x, Complex null).Second value (cannot be y)null).Returns |
| public static boolean | Returns: true if the values are two adjacent floating point
numbers or they are within range of each other.First value (cannot be x, Complex null).Second value (cannot be y, double null).Amount of allowed absolute error. eps)Returns |
| public static boolean | Returns: true if the values are two adjacent floating point
numbers or they are within range of each other.First value (cannot be x, Complex null).Second value (cannot be y, double null).Amount of allowed relative error. eps)Returns |
| public Complex | |
| public double | |
| public ComplexField | getField()
Implements org. Get the |
| public double | |
| public double | |
| public int | Returns: a hash code value for this object.Overrides java. Get a hashCode for the complex number. |
| public boolean | Returns: true if one or both parts of this complex number are infinite and neither part isNaN.Checks whether either the real or imaginary part of this complex number
takes an infinite value (either |
| public boolean | Returns: true if either or both parts of this complex number isNaN; false otherwise.Checks whether either or both parts of this complex number is
|
| public Complex | Returns: the valueln this, the natural logarithm
of this.Compute the natural logarithm of this complex number. |
| public Complex | Returns: this * factor.value to be multiplied by this factor)Complex.Implements org. Returns a |
| public Complex | Returns: this * factor.value to be multiplied by this factor)Complex.Implements org. Returns a |
| public Complex | Returns: this * factor.value to be multiplied by this factor)Complex.Implements org. Returns a |
| public Complex | Returns: -this.Implements org. Returns a |
| public List | Returns: a List of alln-th roots of this.Degree of root. n)Computes the n-th roots of this complex number. |
| public Complex | |
| public Complex | Returns: thisx.exponent to which this x)Complex is to be raised.Returns of value of this complex number raised to the power of |
| protected final Object | Returns: A Complex instance with all fields resolved.Resolve the transient fields in a deserialized Complex Object. |
| public Complex | reciprocal()
Implements org. Returns the multiplicative inverse of |
| public Complex | |
| public Complex | |
| public Complex | |
| public Complex | Returns: the square root of1 - this2.Compute the
square root of |
| public Complex | Returns: this - subtrahend.value to be subtracted from this subtrahend)Complex.Implements org. Returns a |
| public Complex | Returns: this - subtrahend.value to be subtracted from this subtrahend)Complex.Implements org. Returns a |
| public Complex | |
| public Complex | Returns: the hyperbolic tangent ofthis.Compute the hyperbolic tangent of this complex number. |
| public String | |
| public static Complex | Returns: a Complex instance.Real part. realPart, double Imaginary part. imaginaryPart)Create a complex number given the real and imaginary parts. |
| public static Complex | Returns: a Complex instance.Real part. realPart)Create a complex number given only the real part. |
| I | back to summary |
|---|---|
| public static final Complex I The square root of -1. A number representing "0.0 + 1.0i" | |
| imaginary | back to summary |
|---|---|
| private final double imaginary The imaginary part. | |
| INF | back to summary |
|---|---|
| public static final Complex INF A complex number representing "+INF + INFi" | |
| isInfinite | back to summary |
|---|---|
| private final transient boolean isInfinite Record whether this complex number is infinite. | |
| isNaN | back to summary |
|---|---|
| private final transient boolean isNaN Record whether this complex number is equal to NaN. | |
| NaN | back to summary |
|---|---|
| public static final Complex NaN A complex number representing "NaN + NaNi" | |
| ONE | back to summary |
|---|---|
| public static final Complex ONE A complex number representing "1.0 + 0.0i" | |
| real | back to summary |
|---|---|
| private final double real The real part. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| ZERO | back to summary |
|---|---|
| public static final Complex ZERO A complex number representing "0.0 + 0.0i" | |
| Complex | back to summary |
|---|---|
| public Complex(double real) Create a complex number given only the real part.
| |
| Complex | back to summary |
|---|---|
| public Complex(double real, double imaginary) Create a complex number given the real and imaginary parts.
| |
| abs | back to summary |
|---|---|
| public double abs() Return the absolute value of this complex number.
Returns
| |
| acos | back to summary |
|---|---|
| public Complex acos() Compute the inverse cosine of this complex number. Implements the formula:
Complex#NaN if either real or imaginary part of the
input argument is NaN or infinite.
| |
| add | back to summary |
|---|---|
| public Complex add(Complex addend) throws NullArgumentException Implements org. Returns a
this or addend has a NaN value in
either part, NaN is returned; otherwise Infinite
and NaN values are returned in the parts of the result
according to the rules for java. arithmetic.
| |
| add | back to summary |
|---|---|
| public Complex add(double addend) Implements org. Returns a
| |
| asin | back to summary |
|---|---|
| public Complex asin() Compute the inverse sine of this complex number. Implements the formula:
Returns
| |
| atan | back to summary |
|---|---|
| public Complex atan() Compute the inverse tangent of this complex number. Implements the formula:
Returns
| |
| conjugate | back to summary |
|---|---|
| public Complex conjugate() Returns the conjugate of this complex number.
The conjugate of
If the imaginary part is infinite, and the real part is not
| |
| cos | back to summary |
|---|---|
| public Complex cos() Compute the cosine of this complex number. Implements the formula:
where the (real) functions on the right-hand side are
Returns Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Examples:
| |
| cosh | back to summary |
|---|---|
| public Complex cosh() Compute the hyperbolic cosine of this complex number. Implements the formula:
where the (real) functions on the right-hand side are
FastMath#sin, FastMath#cos,
FastMath#cosh and FastMath#sinh.
Returns
Examples:
| |
| createComplex | back to summary |
|---|---|
| protected Complex createComplex(double realPart, double imaginaryPart) Create a complex number given the real and imaginary parts.
| |
| divide | back to summary |
|---|---|
| public Complex divide(Complex divisor) throws NullArgumentException Implements org. Returns a
but uses
prescaling of operands to limit the effects of overflows and
underflows in the computation.
| |
| divide | back to summary |
|---|---|
| public Complex divide(double divisor) Implements org. Returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Test for equality with another object.
If both the real and imaginary parts of two complex numbers
are exactly the same, and neither is
| |
| equals | back to summary |
|---|---|
| public static boolean equals(Complex x, Complex y, int maxUlps) Test for the floating-point equality between Complex objects.
It returns
| |
| equals | back to summary |
|---|---|
| public static boolean equals(Complex x, Complex y) Returns | |
| equals | back to summary |
|---|---|
| public static boolean equals(Complex x, Complex y, double eps) Returns
| |
| equalsWithRelativeTolerance | back to summary |
|---|---|
| public static boolean equalsWithRelativeTolerance(Complex x, Complex y, double eps) Returns
| |
| exp | back to summary |
|---|---|
| public Complex exp() Compute the exponential function of this complex number. Implements the formula:
where the (real) functions on the right-hand side are
FastMath#exp, FastMath#cos, and
FastMath#sin.
Returns
Examples:
| |
| getArgument | back to summary |
|---|---|
| public double getArgument() Compute the argument of this complex number. The argument is the angle phi between the positive real axis and the point representing this number in the complex plane. The value returned is between -PI (not inclusive) and PI (inclusive), with negative values returned for numbers with negative imaginary parts.
If either real or imaginary part (or both) is NaN, NaN is returned.
Infinite parts are handled as
| |
| getField | back to summary |
|---|---|
| public ComplexField getField() Implements org. Doc from org. Get the
| |
| getImaginary | back to summary |
|---|---|
| public double getImaginary() Access the imaginary part.
| |
| getReal | back to summary |
|---|---|
| public double getReal() Access the real part.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Get a hashCode for the complex number.
Any
| |
| isInfinite | back to summary |
|---|---|
| public boolean isInfinite() Checks whether either the real or imaginary part of this complex number
takes an infinite value (either
| |
| isNaN | back to summary |
|---|---|
| public boolean isNaN() Checks whether either or both parts of this complex number is
| |
| log | back to summary |
|---|---|
| public Complex log() Compute the natural logarithm of this complex number. Implements the formula:
where ln on the right hand side is FastMath#log,
|a + bi| is the modulus, Complex#abs, and
arg(a + bi) = FastMath#atan2(b, a).
Returns
Examples:
| |
| multiply | back to summary |
|---|---|
| public Complex multiply(Complex factor) throws NullArgumentException Implements org. Returns a
NaN if either this or factor has one or
more NaN parts.
Returns Returns finite values in components of the result per the definitional formula in all remaining cases.
| |
| multiply | back to summary |
|---|---|
| public Complex multiply(final int factor) Implements org. Returns a
| |
| multiply | back to summary |
|---|---|
| public Complex multiply(double factor) Implements org. Returns a
| |
| negate | back to summary |
|---|---|
| public Complex negate() Implements org. Returns a
| |
| nthRoot | back to summary |
|---|---|
| public List Computes the n-th roots of this complex number. The nth roots are defined by the formula:
for k=0, 1, ..., n-1, where abs and phi
are respectively the modulus and
argument of this complex number.
If one or both parts of this complex number is NaN, a list with just
one element,
| |
| pow | back to summary |
|---|---|
| public Complex pow(Complex x) throws NullArgumentException Returns of value of this complex number raised to the power of
where exp and log are exp and
log, respectively.
Returns
| |
| pow | back to summary |
|---|---|
| public Complex pow(double x) Returns of value of this complex number raised to the power of
| |
| readResolve | back to summary |
|---|---|
| protected final Object readResolve() Resolve the transient fields in a deserialized Complex Object.
Subclasses will need to override
| |
| reciprocal | back to summary |
|---|---|
| public Complex reciprocal() Implements org. Doc from org. Returns the multiplicative inverse of
| |
| sin | back to summary |
|---|---|
| public Complex sin() Compute the sine of this complex number. Implements the formula:
where the (real) functions on the right-hand side are
FastMath#sin, FastMath#cos,
FastMath#cosh and FastMath#sinh.
Returns
Infinite values in real or imaginary parts of the input may result in
infinite or
Examples:
| |
| sinh | back to summary |
|---|---|
| public Complex sinh() Compute the hyperbolic sine of this complex number. Implements the formula:
where the (real) functions on the right-hand side are
FastMath#sin, FastMath#cos,
FastMath#cosh and FastMath#sinh.
Returns Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Examples:
| |
| sqrt | back to summary |
|---|---|
| public Complex sqrt() Compute the
square root of this complex number.
Implements the following algorithm to compute
Returns
Examples:
| |
| sqrt1z | back to summary |
|---|---|
| public Complex sqrt1z() Compute the
square root of
Returns
| |
| subtract | back to summary |
|---|---|
| public Complex subtract(Complex subtrahend) throws NullArgumentException Implements org. Returns a
this or subtrahend has a NaN] value in either part,
NaN is returned; otherwise infinite and NaN values are
returned in the parts of the result according to the rules for
java. arithmetic.
| |
| subtract | back to summary |
|---|---|
| public Complex subtract(double subtrahend) Implements org. Returns a
| |
| tan | back to summary |
|---|---|
| public Complex tan() Compute the tangent of this complex number. Implements the formula:
where the (real) functions on the right-hand side are
FastMath#sin, FastMath#cos, FastMath#cosh and
FastMath#sinh.
Returns
Examples:
| |
| tanh | back to summary |
|---|---|
| public Complex tanh() Compute the hyperbolic tangent of this complex number. Implements the formula:
where the (real) functions on the right-hand side are
FastMath#sin, FastMath#cos, FastMath#cosh and
FastMath#sinh.
Returns
Examples:
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| valueOf | back to summary |
|---|---|
| public static Complex valueOf(double realPart, double imaginaryPart) Create a complex number given the real and imaginary parts.
| |
| valueOf | back to summary |
|---|---|
| public static Complex valueOf(double realPart) Create a complex number given only the real part.
| |