Class Complex128
- All Implemented Interfaces:
Serializable
,Comparable<Complex128>
,Field<Complex128>
,Ring<Complex128>
,Semiring<Complex128>
This class models a complex number in rectangular (Cartesian) form, defined by its real and imaginary parts,
each stored as a 64-bit floating-point number (double
). Instances of Complex128
are immutable
and thread-safe.
The class provides various operations for complex arithmetic, including addition, subtraction, multiplication, division, exponentiation, logarithms, trigonometric and hyperbolic functions, as well as utilities for comparing and rounding complex numbers.
Usage Example:
Complex128 a = new Complex128(2.5, 3.2); // Creates a complex number 2.5 + 3.2i.
Complex128 b = new Complex128(1, -4); // Creates a complex number 1 - 4i.
Complex128 sum = a.add(b); // Sum of a and b.
Complex128 product = a.mult(b); // Product of a and b.
Special Values:
The class defines several constants for common complex numbers:
ZERO
- Complex number representing zero (0 + 0i).ONE
- Complex number representing one (1 + 0i).TWO
- Complex number representing two (2 + 0i).THREE
- Complex number representing three (3 + 0i).IMAGINARY_UNIT
- The imaginary unit (0 + 1i).INV_IMAGINARY_UNIT
- Negative imaginary unit (0 - 1i).NaN
- Complex number representing a Not-a-Number value.POSITIVE_INFINITY
- Complex number with infinite real part.NEGATIVE_INFINITY
- Complex number with negative infinite real part.
Mathematical Functions:
The class provides methods for several mathematical functions:
sqrt()
- Computes the square root.ln(Complex128)
- Computes the natural logarithm.exp(Complex128)
- Computes the exponential function.pow(Complex128, Complex128)
- Computes the power function.sin(Complex128)
- Computes the sine function.cos(Complex128)
- Computes the cosine function.tan(Complex128)
- Computes the tangent function.sinh(Complex128)
- Computes the hyperbolic sine function.cosh(Complex128)
- Computes the hyperbolic cosine function.tanh(Complex128)
- Computes the hyperbolic tangent function.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal double
Imaginary component of the complex number.static final Complex128
The imaginary unit i.static final Complex128
The additive inverse of the imaginary unit, -i.static final Complex128
Complex number with real and imaginary parts equal toDouble.NaN
.static final Complex128
Complex number with real part equal toDouble.NEGATIVE_INFINITY
.static final Complex128
The complex number with zero imaginary part and one real part.static final Complex128
Complex number with real part equal toDouble.POSITIVE_INFINITY
.final double
Real component of the complex number.static final Complex128
The double value closer than any other to the square root of 3,static final Complex128
The double value closer than any other to the square root of 2.static final Complex128
The complex number with zero imaginary part and three real part.static final Complex128
The complex number with zero imaginary part and two real part.static final Complex128
The complex number with zero imaginary and real parts. -
Constructor Summary
ConstructorsConstructorDescriptionComplex128
(double re) Constructs a complex number with specified real component and zero imaginary component.Complex128
(double re, double im) Constructs a complex number with specified complex and real components.Complex128
(String num) Constructs a complex number from a string of the form"a +/- bi"
wherea
andb
are real values where either may be omitted. i.e.Complex128
(Complex64 num) Constructs a 128-bit complex number from a 64-bit complex number. -
Method Summary
Modifier and TypeMethodDescriptionstatic Complex128
acos
(Complex128 num) Computes the inverse cosine of a complex value.add
(double b) Sums an elements of this field with a real number.add
(Complex128 b) Sums two elements of this field (associative and commutative).addInv()
Computes the additive inverse for an element of this field.static double
arg
(Complex128 num) Computes the complex argument function for a complex number.static int
argmax
(Complex128... values) Computes the index of the maximum magnitude from an array of complex numbers.static int
argmaxReal
(Complex128... values) Computes the index of the minimum real component from an array of complex numbers.static int
argmin
(Complex128... values) Computes the index of the minimum magnitude from an array of complex numbers.static int
argminReal
(Complex128... values) Computes the index of the minimum real component from an array of complex numbers.static Complex128
asin
(Complex128 num) Computes the inverse sine of a complex value.static Complex128
atan
(Complex128 num) Computes the inverse tangent of a complex value.static double
atan2
(Complex128 num) Computes the 2 argument arc-tangent function for a complex number.int
Compares this element of the field withb
.conj()
Computes the conjugate of this field element.static Complex128
cos
(Complex128 num) Computes the trigonometric cosine value of a complex value.static Complex128
cosh
(Complex128 num) Computes the hyperbolic cosine of a complex value.div
(double b) Computes the quotient of an elements of this field and a real number.div
(Complex128 b) Computes the quotient of two elements of this field.double
Converts this complex number to an equivalent double.boolean
equals
(double b) Checks if this complex has zero imaginary part and real part equal to a double.boolean
Checks if an object is equal to this Field element.static Complex128
exp
(Complex128 exponent) Computes the exponential function with the given input.static Complex128
fromPolar
(double r, double theta) Converts a complex number expressed in polar from to the rectangular form.getOne()
Gets the multiplicative identity for this semiring.getZero()
Gets the additive identity for this semiring.int
hashCode()
Generates the hashcode for this complex number.double
im()
Gets the imaginary component of this complex number.boolean
Checks if this complex number has non-zero imaginary part.boolean
isDouble()
Checks if this complex number is a real valued double.boolean
isFinite()
Checks if this field element is finite in magnitude.boolean
Checks if this complex number has zero real part.boolean
Checks if this field element is infinite in magnitude.boolean
isInt()
Checks if this complex number is a real valued integer.boolean
isNaN()
Checks if this field element is NaN in magnitude.boolean
isOne()
Checks if this value is a multiplicative identity for this semiring.boolean
isReal()
Checks if this complex number has zero imaginary part.boolean
isZero()
Checks if this value is an additive identity for this semiring.static int
length
(Complex128 a) Gets the length of the string representation of this complex number.static Complex128
ln
(double num) Computes the natural logarithm of a double.static Complex128
ln
(Complex128 num) Computes the complex natural logarithm of a complex number.static Complex128
log
(double num) Computes the complex logarithm base 10 of a complex number.static Complex128
log
(double base, double num) Computes the complex logarithm, with specified base, of a complex number.static Complex128
log
(double base, Complex128 num) Computes the complex logarithm, with specified base, of a complex number.static Complex128
log
(Complex128 num) Computes the complex logarithm base 10 of a complex number.static Complex128
log
(Complex128 base, Complex128 num) Computes the complex logarithm, with specified base, of a complex number.double
mag()
Computes the magnitude of this field element.double
Squares this magnitude of this complex number.static Complex128
max
(Complex128... values) Computes the maximum magnitude from an array of complex numbers.static Complex128
maxRe
(Complex128... values) Computes the minimum real component from an array of complex numbers.static Complex128
min
(Complex128... values) Computes the minimum magnitude from an array of complex numbers.static Complex128
minRe
(Complex128... values) Computes the minimum real component from an array of complex numbers.mult
(double b) Multiplies an element of this field with a real number.mult
(Complex128 b) Multiplies two elements of this field (associative and commutative).multInv()
Computes the multiplicative inverse of this complex number.static boolean
nearZero
(Complex128 n, double tol) Checks if a number is near zero in magnitude.static Complex128
pow
(double a, Complex128 b) Compute a raised to the power ofb
.static Complex128
pow
(Complex128 a, double b) Computesa
raised to the power ofb
.static Complex128
pow
(Complex128 a, Complex128 b) Compute a raised to the power of b.double
re()
Gets the real component of this complex number.static Complex128
round
(Complex128 n) Rounds both components of a complex number to the nearest respective integer.static Complex128
round
(Complex128 n, int decimals) Rounds number to specified number of decimal places.static Complex128
roundToZero
(Complex128 n, double tol) Rounds a complex numbers to zero if its magnitude within the specified tolerance from zero.static Complex128
sgn
(Complex128 value) The complex signum function.static Complex128
sin
(Complex128 num) Computes the trigonometric sine of a complex value.static Complex128
sinh
(Complex128 num) Computes the hyperbolic sine of a complex value.sqrt()
Computes the square root of this field element.static Complex128
sqrt
(double num) Computes the principle square root of a number.sub
(double b) Computes difference of an element of this field and a real number.sub
(Complex128 b) Computes difference of two elements of this field.static Complex128
sum
(Complex128... numbers) Computes the sum of all data of specified array.static Complex128
tan
(Complex128 num) Computes the trigonometric tangent value of a complex value.static Complex128
tanh
(Complex128 num) Computes the hyperbolic tangent of a complex value.double[]
toPolar()
Converts a complex number to an equivalent polar from.toString()
Converts the complex number to a string representation.
-
Field Details
-
ZERO
The complex number with zero imaginary and real parts. -
ONE
The complex number with zero imaginary part and one real part. -
TWO
The complex number with zero imaginary part and two real part. -
THREE
The complex number with zero imaginary part and three real part. -
ROOT_THREE
The double value closer than any other to the square root of 3, -
ROOT_TWO
The double value closer than any other to the square root of 2. -
IMAGINARY_UNIT
The imaginary unit i. -
INV_IMAGINARY_UNIT
The additive inverse of the imaginary unit, -i. -
POSITIVE_INFINITY
Complex number with real part equal toDouble.POSITIVE_INFINITY
. -
NEGATIVE_INFINITY
Complex number with real part equal toDouble.NEGATIVE_INFINITY
. -
NaN
Complex number with real and imaginary parts equal toDouble.NaN
. -
re
public final double reReal component of the complex number. -
im
public final double imImaginary component of the complex number.
-
-
Constructor Details
-
Complex128
public Complex128(double re) Constructs a complex number with specified real component and zero imaginary component.- Parameters:
re
- Real component of complex number.
-
Complex128
public Complex128(double re, double im) Constructs a complex number with specified complex and real components.- Parameters:
re
- Real component of complex number.im
- Imaginary component of complex number.
-
Complex128
Constructs a complex number from a string of the form"a +/- bi"
wherea
andb
are real values where either may be omitted. i.e."a", "bi", "a +/- i"
, and"i"
are all also valid. Excess white space is ignored.- Parameters:
num
- The string representation of a complex number. Must be parsable byComplexNumberParser.parseNumberToComplex128(String)
.- Throws:
Flag4jParsingException
- Ifnum
cannot be parsed.
-
Complex128
Constructs a 128-bit complex number from a 64-bit complex number.- Parameters:
num
- The 64-bit complex number.
-
-
Method Details
-
equals
public boolean equals(double b) Checks if this complex has zero imaginary part and real part equal to a double.- Returns:
- True if
this.re == b && this.im == 0
. False otherwise.
-
equals
Checks if an object is equal to this Field element.- Overrides:
equals
in classObject
- Parameters:
b
- Object to compare to this Field element.- Returns:
- True if the objects are the same or are both
Complex128
's and have equal real and imaginary parts.
-
hashCode
-
isReal
public boolean isReal()Checks if this complex number has zero imaginary part.- Returns:
- True if this complex number has zero imaginary part. False otherwise.
- See Also:
-
isImaginary
public boolean isImaginary()Checks if this complex number has zero real part.- Returns:
- True if this complex number has zero real part. False otherwise.
- See Also:
-
isComplex
public boolean isComplex()Checks if this complex number has non-zero imaginary part.- Returns:
- True if this complex number has non-zero imaginary part. False otherwise.
- See Also:
-
add
Sums two elements of this field (associative and commutative).- Specified by:
add
in interfaceSemiring<Complex128>
- Parameters:
b
- Second field element in sum.- Returns:
- The sum of this element and
b
.
-
add
Sums an elements of this field with a real number.- Specified by:
add
in interfaceField<Complex128>
- Parameters:
b
- Second element in sum.- Returns:
- The sum of this element and
b
.
-
sub
Computes difference of two elements of this field.- Specified by:
sub
in interfaceRing<Complex128>
- Parameters:
b
- Second field element in difference.- Returns:
- The difference of this field element and
b
.
-
sub
Computes difference of an element of this field and a real number.- Specified by:
sub
in interfaceField<Complex128>
- Parameters:
b
- Second element in difference.- Returns:
- The difference of this field element and
b
.
-
sum
Computes the sum of all data of specified array.- Parameters:
values
- Values to compute product of.- Returns:
- The sum of all values in
values
.
-
mult
Multiplies two elements of this field (associative and commutative).- Specified by:
mult
in interfaceSemiring<Complex128>
- Parameters:
b
- Second field element in product.- Returns:
- The product of this field element and
b
.
-
isZero
public boolean isZero()Checks if this value is an additive identity for this semiring.
An element 0 is an additive identity if a + 0 = a for any a in the semiring.
- Specified by:
isZero
in interfaceSemiring<Complex128>
- Returns:
- True if this value is an additive identity for this semiring. Otherwise, false.
-
isOne
public boolean isOne()Checks if this value is a multiplicative identity for this semiring.
An element 1 is a multiplicative identity if a * 1 = a for any a in the semiring.
- Specified by:
isOne
in interfaceSemiring<Complex128>
- Returns:
- True if this value is a multiplicative identity for this semiring. Otherwise, false.
-
getZero
Gets the additive identity for this semiring.
An element 0 is an additive identity if a + 0 = a for any a in the semiring.
- Specified by:
getZero
in interfaceSemiring<Complex128>
- Returns:
- The additive identity for this semiring.
-
getOne
Gets the multiplicative identity for this semiring.
An element 1 is a multiplicative identity if a * 1 = a for any a in the semiring.
- Specified by:
getOne
in interfaceSemiring<Complex128>
- Returns:
- The multiplicative identity for this semiring.
-
mult
Multiplies an element of this field with a real number.- Specified by:
mult
in interfaceField<Complex128>
- Parameters:
b
- Second element in product.- Returns:
- The product of this field element and
b
.
-
div
Computes the quotient of two elements of this field.- Specified by:
div
in interfaceField<Complex128>
- Parameters:
b
- Second field element in quotient.- Returns:
- The quotient of this field element and
b
.
-
div
Computes the quotient of an elements of this field and a real number.- Specified by:
div
in interfaceField<Complex128>
- Parameters:
b
- Second element in quotient.- Returns:
- The quotient of this field element and
b
.
-
mag
public double mag()Computes the magnitude of this field element.- Specified by:
mag
in interfaceRing<Complex128>
- Returns:
- The magnitude of this field element.
-
sqrt
Computes the square root of this field element.- Specified by:
sqrt
in interfaceField<Complex128>
- Returns:
- The square root of this field element.
-
magSquared
public double magSquared()Squares this magnitude of this complex number.
- Returns:
- The square of the magnitude of this complex number as a real value.
-
addInv
Computes the additive inverse for an element of this field.
An element -x is an additive inverse for a field element x if -x + x = 0 where 0 is the additive identity.
- Specified by:
addInv
in interfaceRing<Complex128>
- Returns:
- The additive inverse for this field element.
-
multInv
Computes the multiplicative inverse of this complex number.- Specified by:
multInv
in interfaceField<Complex128>
- Returns:
- The multiplicative inverse of this complex number.
-
conj
Computes the conjugate of this field element.- Specified by:
conj
in interfaceRing<Complex128>
- Returns:
- The conjugate of this field element.
-
pow
Compute a raised to the power ofb
. and returns aComplex128
.- Parameters:
a
- The base.b
- The exponent.- Returns:
- a to the power of
b
.
-
pow
Compute a raised to the power of b. and returns aComplex128
.- Parameters:
a
- The base.b
- The exponent.- Returns:
- a to the power of b.
-
pow
Computesa
raised to the power ofb
.- Parameters:
a
- The base.b
- The exponent.- Returns:
a
raised to the power ofb
.
-
exp
Computes the exponential function with the given input.- Parameters:
exponent
- Input to the exponential function.- Returns:
- The output of the exponential function.
-
ln
Computes the natural logarithm of a double. For non-negative values this function is equivalent toMath.log(double)
. If the number is negative, then it is passed on as a complex value toln(Complex128)
.- Parameters:
num
- Input to the complex natural logarithm function.- Returns:
- The principle value of the complex natural logarithm for the given input.
-
ln
Computes the complex natural logarithm of a complex number. This function is the analytic continuation of the natural logarithm, that is the log basee
.- Parameters:
num
- Input to the complex natural logarithm function.- Returns:
- The principle value of the complex natural logarithm for the given input.
-
log
Computes the complex logarithm base 10 of a complex number. Please note, this is NOT the natural logarithm. If the complex natural logarithm is desired seeln(double)
. To specify a base, seelog(double, Complex128)
orlog(Complex128, Complex128)
. If the argument is non-negative, then this function is equivalent toMath.log(double)
.- Parameters:
num
- Input to the complex logarithm base 10 function.- Returns:
- The principle value of the complex logarithm base 10 for the given input.
-
log
Computes the complex logarithm base 10 of a complex number. Please note, this is NOT the complex natural logarithm. If the complex natural logarithm is desired seeln(Complex128)
. To specify a base, seelog(double, Complex128)
orlog(Complex128, Complex128)
.- Parameters:
num
- Input to the complex logarithm base 10 function.- Returns:
- The principle value of the complex logarithm base 10 for the given input.
-
log
Computes the complex logarithm, with specified base, of a complex number.- Parameters:
base
- Base of the logarithm.num
- Input to the complex logarithm function with specified base.- Returns:
- The principle value of the complex logarithm, with specified base, for the given input.
-
log
Computes the complex logarithm, with specified base, of a complex number.- Parameters:
base
- Base of the logarithm.num
- Input to the complex logarithm function with specified base.- Returns:
- The principle value of the complex logarithm, with specified base, for the given input.
-
log
Computes the complex logarithm, with specified base, of a complex number.- Parameters:
base
- Base of the logarithm.num
- Input to the complex logarithm function with specified base.- Returns:
- The principle value of the complex logarithm, with specified base, for the given input.
-
sqrt
Computes the principle square root of a number. This method wrapsMath.sqrt(double)
and returns aComplex128
.- Parameters:
num
- Input to square root.- Returns:
- The principle square root of
num
.
-
toPolar
public double[] toPolar()Converts a complex number to an equivalent polar from.- Returns:
- An array of length 2 containing in order, the radius and angle (in radians) if the complex number.
-
fromPolar
Converts a complex number expressed in polar from to the rectangular form.- Parameters:
r
- Radius of complex number.theta
- Angle of the complex number in radians.- Returns:
- An equivalent complex number in rectangular form.
-
atan2
Computes the 2 argument arc-tangent function for a complex number. That is, for a complex number a+bi, atan2(b, a) is computed. This method wrapsMath.atan2(double, double)
.- Parameters:
num
- The input to the atan2 function.- Returns:
- The output of the atan2 function given the specified input. If the complex number is zero, then
Double.NaN
is returned.
-
arg
Computes the complex argument function for a complex number. is computed. This method is equivalent toatan2(Complex128)
.- Parameters:
num
- The input to the atan2 function.- Returns:
- The output of the atan2 function given the specified input. If the complex number is zero, then
Double.NaN
is returned.
-
sin
Computes the trigonometric sine of a complex value.- Parameters:
num
- Complex valued input to the sine function. If num is real, then this is an angle in radians.- Returns:
- The trigonometric sine function evaluated at the specified value.
-
asin
Computes the inverse sine of a complex value.- Parameters:
num
- Input to the inverse sine function.- Returns:
- The inverse sine of the input value.
-
sinh
Computes the hyperbolic sine of a complex value.- Parameters:
num
- Input to the hyperbolic sine function.- Returns:
- The hyperbolic sine of the input value.
-
cos
Computes the trigonometric cosine value of a complex value.- Parameters:
num
- Complex valued input to the cosine function. If num is real, then this is an angle in radians.- Returns:
- The trigonometric cosine function evaluated at the specified value.
-
acos
Computes the inverse cosine of a complex value.- Parameters:
num
- Input to the inverse cosine function.- Returns:
- The inverse cosine of the input value.
-
cosh
Computes the hyperbolic cosine of a complex value.- Parameters:
num
- Input to the hyperbolic cosine function.- Returns:
- The hyperbolic cosine of the input value.
-
tan
Computes the trigonometric tangent value of a complex value.- Parameters:
num
- Complex valued input to the tangent function. If num is real, then this is an angle in radians.- Returns:
- The trigonometric tangent function evaluated at the specified value.
-
atan
Computes the inverse tangent of a complex value.- Parameters:
num
- Input to the inverse tangent function.- Returns:
- The inverse tangent of the input value.
-
tanh
Computes the hyperbolic tangent of a complex value.- Parameters:
num
- Input to the hyperbolic tangent function.- Returns:
- The hyperbolic tangent of the input value.
-
sgn
The complex signum function. Please note, if the value passed to this method is zero, the function will return zero.- Parameters:
value
- Value to evaluate the signum function at.- Returns:
- If the number is zero then this function returns zero. Otherwise, returns the number divided by its magnitude.
-
round
Rounds both components of a complex number to the nearest respective integer.- Parameters:
n
- The complex number to round.- Returns:
- A complex number with integer real and imaginary components closest to the real and imaginary components of the parameter n
- Throws:
NumberFormatException
- If n isDouble.NaN
,Double.POSITIVE_INFINITY
orDouble.NEGATIVE_INFINITY
- See Also:
-
round
Rounds number to specified number of decimal places. If the number is complex, both the real and imaginary parts will be rounded.- Parameters:
n
- Number to round.decimals
- Number of decimals to round to.- Returns:
- The number rounded to the specified number of decimals.
- Throws:
IllegalArgumentException
- If decimals is less than zero.NumberFormatException
- If n isDouble.NaN
,Double.POSITIVE_INFINITY
orDouble.NEGATIVE_INFINITY
- See Also:
-
roundToZero
Rounds a complex numbers to zero if its magnitude within the specified tolerance from zero.- Parameters:
n
- Number to round.tol
- Max distances in complex plane for which number should be rounded to zero.- Returns:
- The
-
nearZero
Checks if a number is near zero in magnitude.- Parameters:
n
- Number to round.tol
- Tolerance of how close to zero is considered "near".- Returns:
- Returns
true
if magnitude of number is less than or equal totol
;false
otherwise. - Throws:
IllegalArgumentException
- If tol is less than 0.
-
compareTo
Compares this element of the field withb
.- Specified by:
compareTo
in interfaceComparable<Complex128>
- Specified by:
compareTo
in interfaceSemiring<Complex128>
- Parameters:
b
- Second element of the field.- Returns:
- An int value:
- 0 if this field element is equal to
b
in magnitude. - invalid input: '<' 0 if this field element is less than
b
in magnitude. - > 0 if this field element is greater than
b
in magnitude.
Hence, this method returns zero if and only if the two field elements are equal in magnitude, a negative value if and
only the field element it was called on is less than
b
in magnitude and positive if and only if the field element it was called on is greater thanb
in magnitude. - 0 if this field element is equal to
-
doubleValue
public double doubleValue()Converts this complex number to an equivalent double. This will be the magnitude of the complex number.- Specified by:
doubleValue
in interfaceSemiring<Complex128>
- Returns:
- A double value equivalent to this complex number. This will be the magnitude of the complex number.
-
min
Computes the minimum magnitude from an array of complex numbers.- Parameters:
values
- Array of values to compute the minimum magnitude from.- Returns:
- The minimum magnitude from the
values array
. If the array has zero length, thennull
is returned.
-
minRe
Computes the minimum real component from an array of complex numbers. All imaginary components are ignored.- Parameters:
values
- Array of values to compute the minimum real component from.- Returns:
- The minimum magnitude from the
values array
. If the array has zero length,Double.NaN
is returned.
-
max
Computes the maximum magnitude from an array of complex numbers.- Parameters:
values
- Array of values to compute the maximum magnitude from.- Returns:
- The minimum magnitude from the
values array
. If the array has zero length, then -1 is returned.
-
maxRe
Computes the minimum real component from an array of complex numbers. All imaginary components are ignored.- Parameters:
values
- Array of values to compute the minimum real component from.- Returns:
- The minimum magnitude from the
values array
. If the array has zero length,Double.NaN
is returned.
-
argmin
Computes the index of the minimum magnitude from an array of complex numbers.- Parameters:
values
- Array of values to compute the index of the minimum magnitude from.- Returns:
- The index of the minimum magnitude from the
values array
. If the array has zero length, then -1 is returned.
-
argminReal
Computes the index of the minimum real component from an array of complex numbers. All imaginary components are ignored.- Parameters:
values
- Array of values to compute the index of the minimum real component from.- Returns:
- The index of the minimum magnitude from the
values array
. If the array has zero length, -1 is returned.
-
argmax
Computes the index of the maximum magnitude from an array of complex numbers.- Parameters:
values
- Array of values to compute the index of the maximum magnitude from.- Returns:
- The index of the minimum magnitude from the
values array
. If the array has zero length, then -1 is returned.
-
argmaxReal
Computes the index of the minimum real component from an array of complex numbers. All imaginary components are ignored.- Parameters:
values
- Array of values to compute the index of the minimum real component from.- Returns:
- The index of the minimum magnitude from the
values array
. If the array has zero length, -1 is returned.
-
isInt
public boolean isInt()Checks if this complex number is a real valued integer.- Returns:
true
if the real component of this number is an integer and the complex component is zero;false
otherwise.
-
isDouble
public boolean isDouble()Checks if this complex number is a real valued double.- Returns:
true
if the complex component is zero;false
otherwise.
-
isFinite
public boolean isFinite()Checks if this field element is finite in magnitude.
NOTE: It may be possible for this method to return true and
mag()
to returnDouble.POSITIVE_INFINITY
,Double.NEGATIVE_INFINITY
, orDouble.NaN
if both components are finite but computing the magnitude explicitly results in an overflow.- Specified by:
isFinite
in interfaceField<Complex128>
- Returns:
- True if this field element is finite in magnitude. False otherwise (i.e. infinite, NaN etc.).
-
isInfinite
public boolean isInfinite()Checks if this field element is infinite in magnitude.- Specified by:
isInfinite
in interfaceField<Complex128>
- Returns:
- True if this field element is infinite in magnitude. False otherwise (i.e. finite, NaN, etc.).
-
isNaN
public boolean isNaN()Checks if this field element is NaN in magnitude.- Specified by:
isNaN
in interfaceField<Complex128>
- Returns:
- True if this field element is NaN in magnitude. False otherwise (i.e. finite, NaN, etc.).
-
re
public double re()Gets the real component of this complex number.- Returns:
- The real component of this complex number.
-
im
public double im()Gets the imaginary component of this complex number.- Returns:
- The imaginary component of this complex number.
-
length
Gets the length of the string representation of this complex number.- Parameters:
a
- Complex number.- Returns:
- The length of the string representation of the number.
-
toString
-