Class Complex64

java.lang.Object
org.flag4j.algebraic_structures.Complex64
All Implemented Interfaces:
Serializable, Comparable<Complex64>, Field<Complex64>, Ring<Complex64>, Semiring<Complex64>

public class Complex64 extends Object implements Field<Complex64>
Represents an immutable complex number with single-precision floating point components.

This class models a complex number in rectangular (Cartesian) form, defined by its real and imaginary parts, each stored as a 32-bit floating-point number (float). Instances of Complex64 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:


 Complex64 a = new Complex64(2.5f, 3.2f);  // Creates a complex number 2.5 + 3.2i.
 Complex64 b = new Complex64(1, -4);       // Creates a complex number 1 - 4i.
 Complex64 sum = a.add(b);                 // Sum of a and b.
 Complex64 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:

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final float
    Imaginary component of the complex number.
    static final Complex64
    The imaginary unit i.
    static final Complex64
    The additive inverse of the imaginary unit, -i.
    static final Complex64
    Complex number with real and imaginary parts equal to Float.NaN.
    static final Complex64
    Complex number with real part equal to Float.NEGATIVE_INFINITY.
    static final Complex64
    The complex number with zero imaginary part and one real part.
    static final Complex64
    Complex number with real part equal to Float.POSITIVE_INFINITY.
    final float
    Real component of the complex number.
    static final Complex64
    The float value closer than any other to the square root of 3
    static final Complex64
    The float value closer than any other to the square root of 2
    static final Complex64
    The complex number with zero imaginary part and three real part.
    static final Complex64
    The complex number with zero imaginary part and two real part.
    static final Complex64
    The complex number with zero imaginary and real parts.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Complex64(float re)
    Constructs a complex number with specified real component and zero imaginary component.
    Complex64(float re, float im)
    Constructs a complex number with specified complex and real components.
    Constructs a complex number from a string of the form "a +/- bi" where a and {b} are real values and either may be omitted. i.e.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Complex64
    Computes the inverse cosine of a complex value.
    add(float b)
    Sums an elements of this field with a real number.
    Sums two elements of this field (associative and commutative).
    Computes the additive inverse for an element of this field.
    static float
    Computes the complex argument function for a complex number.
    static int
    argmax(Complex64... values)
    Computes the index of the maximum magnitude from an array of complex numbers.
    static int
    argmaxReal(Complex64... values)
    Computes the index of the minimum real component from an array of complex numbers.
    static int
    argmin(Complex64... values)
    Computes the index of the minimum magnitude from an array of complex numbers.
    static int
    argminReal(Complex64... values)
    Computes the index of the minimum real component from an array of complex numbers.
    static Complex64
    Computes the inverse sine of a complex value.
    static Complex64
    Computes the inverse tangent of a complex value.
    static float
    Computes the 2 argument arc-tangent function for a complex number.
    int
    Compares this element of the field with b.
    Computes the conjugate of this field element.
    static Complex64
    Computes the trigonometric cosine value of a complex value.
    static Complex64
    Computes the hyperbolic cosine of a complex value.
    div(float b)
    Computes the quotient of an elements of this field and a real number.
    Computes the quotient of two elements of this field.
    double
    Converts this complex number to an equivalent double.
    boolean
    equals(float 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 Complex64
    exp(Complex64 exponent)
    Computes the exponential function with the given input.
    static Complex64
    fromPolar(float r, float theta)
    Converts a complex number expressed in polar from to the rectangular form.
    Gets the multiplicative identity for this semiring.
    Gets the additive identity for this semiring.
    int
    Generates the hashcode for this complex number.
    float
    im()
    Gets the imaginary component of this complex number.
    boolean
    Checks if this complex number has non-zero imaginary part.
    boolean
    Checks if this field element is finite in magnitude.
    boolean
    Checks if this complex number is a real valued float.
    boolean
    Checks if this complex number has zero real part.
    boolean
    Checks if this field element is infinite in magnitude.
    boolean
    Checks if this complex number is a real valued integer.
    boolean
    Checks if this field element is NaN in magnitude.
    boolean
    Checks if this value is a multiplicative identity for this semiring.
    boolean
    Checks if this complex number has zero imaginary part.
    boolean
    Checks if this value is an additive identity for this semiring.
    static int
    Gets the length of the string representation of this complex number.
    static Complex64
    ln(float num)
    Computes the natural logarithm of a float.
    static Complex64
    Computes the complex natural logarithm of a complex number.
    static Complex64
    log(float num)
    Computes the complex logarithm base 10 of a complex number.
    static Complex64
    log(float base, float num)
    Computes the complex logarithm, with specified base, of a complex number.
    static Complex64
    log(float base, Complex64 num)
    Computes the complex logarithm, with specified base, of a complex number.
    static Complex64
    Computes the complex logarithm base 10 of a complex number.
    static Complex64
    log(Complex64 base, Complex64 num)
    Computes the complex logarithm, with specified base, of a complex number.
    double
    mag()
    Computes the magnitude of this field element.
    float
    Squares this magnitude of this complex number.
    static Complex64
    max(Complex64... values)
    Computes the maximum magnitude from an array of complex numbers.
    static Complex64
    maxRe(Complex64... values)
    Computes the minimum real component from an array of complex numbers.
    static Complex64
    min(Complex64... values)
    Computes the minimum magnitude from an array of complex numbers.
    static Complex64
    minRe(Complex64... values)
    Computes the minimum real component from an array of complex numbers.
    mult(float b)
    Multiplies an element of this field and a real number (associative and commutative).
    Multiplies two elements of this field (associative and commutative).
    Computes the multiplicative inverse of this complex number.
    static boolean
    nearZero(Complex64 n, float tol)
    Checks if a number is near zero in magnitude.
    static Complex64
    pow(float a, Complex64 b)
    Compute a raised to the power of b.
    static Complex64
    pow(Complex64 a, float b)
    Computes a raised to the power of b.
    static Complex64
    Computes a raised to the power of b.
    float
    re()
    Gets the real component of this complex number.
    static Complex64
    Rounds both components of a complex number to the nearest respective integer.
    static Complex64
    round(Complex64 n, int decimals)
    Rounds number to specified number of decimal places.
    static Complex64
    roundToZero(Complex64 n, float tol)
    Rounds a complex numbers to zero if its magnitude within the specified tolerance from zero.
    static Complex64
    sgn(Complex64 value)
    The complex signum function.
    static Complex64
    Computes the trigonometric sine of a complex value.
    static Complex64
    Computes the hyperbolic sine of a complex value.
    Computes the square root of this field element.
    static Complex64
    sqrt(float num)
    Computes the principle square root of a number.
    sub(float b)
    Computes difference of an element of this field and a real number.
    Computes difference of two elements of this field.
    static Complex64
    sum(Complex64... numbers)
    Computes the sum of all data of specified array.
    static Complex64
    Computes the trigonometric tangent value of a complex value.
    static Complex64
    Computes the hyperbolic tangent of a complex value.
    float[]
    Converts a complex number to an equivalent polar from.
    Converts the complex number to a string representation.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.flag4j.algebraic_structures.Field

    add, div, mult, sub

    Methods inherited from interface org.flag4j.algebraic_structures.Ring

    abs
  • Field Details

    • ZERO

      public static final Complex64 ZERO
      The complex number with zero imaginary and real parts.
    • ONE

      public static final Complex64 ONE
      The complex number with zero imaginary part and one real part.
    • TWO

      public static final Complex64 TWO
      The complex number with zero imaginary part and two real part.
    • THREE

      public static final Complex64 THREE
      The complex number with zero imaginary part and three real part.
    • ROOT_TWO

      public static final Complex64 ROOT_TWO
      The float value closer than any other to the square root of 2
    • ROOT_THREE

      public static final Complex64 ROOT_THREE
      The float value closer than any other to the square root of 3
    • IMAGINARY_UNIT

      public static final Complex64 IMAGINARY_UNIT
      The imaginary unit i.
    • INV_IMAGINARY_UNIT

      public static final Complex64 INV_IMAGINARY_UNIT
      The additive inverse of the imaginary unit, -i.
    • POSITIVE_INFINITY

      public static final Complex64 POSITIVE_INFINITY
      Complex number with real part equal to Float.POSITIVE_INFINITY.
    • NEGATIVE_INFINITY

      public static final Complex64 NEGATIVE_INFINITY
      Complex number with real part equal to Float.NEGATIVE_INFINITY.
    • NaN

      public static final Complex64 NaN
      Complex number with real and imaginary parts equal to Float.NaN.
    • re

      public final float re
      Real component of the complex number.
    • im

      public final float im
      Imaginary component of the complex number.
  • Constructor Details

    • Complex64

      public Complex64(float re)
      Constructs a complex number with specified real component and zero imaginary component.
      Parameters:
      re - Real component of complex number.
    • Complex64

      public Complex64(float re, float im)
      Constructs a complex number with specified complex and real components.
      Parameters:
      re - Real component of complex number.
      im - Imaginary component of complex number.
    • Complex64

      public Complex64(String num)
      Constructs a complex number from a string of the form "a +/- bi" where a and {b} are real values and either may be omitted. i.e. "a", "bi", "a +/- i", and "i" are all also valid.
      Parameters:
      num - The string representation of a complex number.
  • Method Details

    • equals

      public boolean equals(float 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

      public boolean equals(Object b)
      Checks if an object is equal to this Field element.
      Overrides:
      equals in class Object
      Parameters:
      b - Object to compare to this Field element.
      Returns:
      True if the objects are the same or are both Complex64's and have equal real and imaginary parts.
    • hashCode

      public int hashCode()
      Generates the hashcode for this complex number.
      Overrides:
      hashCode in class Object
      Returns:
      An integer hash for this complex number.
    • 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

      public Complex64 add(Complex64 b)
      Sums two elements of this field (associative and commutative).
      Specified by:
      add in interface Semiring<Complex64>
      Parameters:
      b - Second field element in sum.
      Returns:
      The sum of this element and b.
    • add

      public Complex64 add(float b)
      Sums an elements of this field with a real number.
      Parameters:
      b - Second element in sum.
      Returns:
      The sum of this element and b.
    • sub

      public Complex64 sub(Complex64 b)
      Computes difference of two elements of this field.
      Specified by:
      sub in interface Ring<Complex64>
      Parameters:
      b - Second field element in difference.
      Returns:
      The difference of this field element and b.
    • sub

      public Complex64 sub(float b)
      Computes difference of an element of this field and a real number.
      Parameters:
      b - Second element in difference.
      Returns:
      The difference of this field element and b.
    • sum

      public static Complex64 sum(Complex64... numbers)
      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

      public Complex64 mult(Complex64 b)
      Multiplies two elements of this field (associative and commutative).
      Specified by:
      mult in interface Semiring<Complex64>
      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 interface Semiring<Complex64>
      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 interface Semiring<Complex64>
      Returns:
      True if this value is a multiplicative identity for this semiring. Otherwise, false.
    • getZero

      public Complex64 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 interface Semiring<Complex64>
      Returns:
      The additive identity for this semiring.
    • getOne

      public Complex64 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 interface Semiring<Complex64>
      Returns:
      The multiplicative identity for this semiring.
    • mult

      public Complex64 mult(float b)
      Multiplies an element of this field and a real number (associative and commutative).
      Parameters:
      b - Real number product.
      Returns:
      The product of this field element and b.
    • div

      public Complex64 div(Complex64 b)
      Computes the quotient of two elements of this field.
      Specified by:
      div in interface Field<Complex64>
      Parameters:
      b - Second field element in quotient.
      Returns:
      The quotient of this field element and b.
    • div

      public Complex64 div(float b)
      Computes the quotient of an elements of this field and a real number.
      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 interface Ring<Complex64>
      Returns:
      The magnitude of this field element.
    • sqrt

      public Complex64 sqrt()
      Computes the square root of this field element.
      Specified by:
      sqrt in interface Field<Complex64>
      Returns:
      The square root of this field element.
    • magSquared

      public float magSquared()

      Squares this magnitude of this complex number.

      Returns:
      The square of the magnitude of this complex number as a real value.
    • addInv

      public Complex64 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 interface Ring<Complex64>
      Returns:
      The additive inverse for this field element.
    • multInv

      public Complex64 multInv()
      Computes the multiplicative inverse of this complex number.
      Specified by:
      multInv in interface Field<Complex64>
      Returns:
      The multiplicative inverse of this complex number.
    • conj

      public Complex64 conj()
      Computes the conjugate of this field element.
      Specified by:
      conj in interface Ring<Complex64>
      Returns:
      The conjugate of this field element.
    • pow

      public static Complex64 pow(float a, Complex64 b)
      Compute a raised to the power of b. and returns a Complex64.
      Parameters:
      a - The base.
      b - The exponent.
      Returns:
      a to the power of b.
    • pow

      public static Complex64 pow(Complex64 a, Complex64 b)
      Computes a raised to the power of b.
      Parameters:
      a - The base.
      b - The exponent.
      Returns:
      a raised to the power of b.
    • pow

      public static Complex64 pow(Complex64 a, float b)
      Computes a raised to the power of b.
      Parameters:
      a - The base.
      b - The exponent.
      Returns:
      a raised to the power of b.
    • exp

      public static Complex64 exp(Complex64 exponent)
      Computes the exponential function with the given input.
      Parameters:
      exponent - Input to the exponential function.
      Returns:
      The output of the exponential function.
    • ln

      public static Complex64 ln(float num)
      Computes the natural logarithm of a float. For non-negative values this function is equivalent to Math.log(double). If the number is negative, then it is passed on as a complex value to ln(Complex64).
      Parameters:
      num - Input to the complex natural logarithm function.
      Returns:
      The principle value of the complex natural logarithm for the given input.
    • ln

      public static Complex64 ln(Complex64 num)
      Computes the complex natural logarithm of a complex number. This function is the analytic continuation of the natural logarithm, that is the log base e.
      Parameters:
      num - Input to the complex natural logarithm function.
      Returns:
      The principle value of the complex natural logarithm for the given input.
    • log

      public static Complex64 log(float num)
      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 see ln(float). To specify a base, see log(float, Complex64) or log(Complex64, Complex64). If the argument is non-negative, then this function is equivalent to Math.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

      public static Complex64 log(Complex64 num)
      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 see ln(Complex64). To specify a base, see log(float, Complex64) or log(Complex64, Complex64).
      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

      public static Complex64 log(float base, float num)
      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

      public static Complex64 log(float base, Complex64 num)
      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

      public static Complex64 log(Complex64 base, Complex64 num)
      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

      public static Complex64 sqrt(float num)
      Computes the principle square root of a number. This method wraps Math.sqrt(double) and returns a Complex64.
      Parameters:
      num - Input to square root.
      Returns:
      The principle square root of num.
    • toPolar

      public float[] 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

      public static Complex64 fromPolar(float r, float theta)
      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

      public static float atan2(Complex64 num)
      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 wraps Math.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 Float.NaN is returned.
    • arg

      public static float arg(Complex64 num)
      Computes the complex argument function for a complex number. is computed. This method is equivalent to atan2(Complex64).
      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 Float.NaN is returned.
    • sin

      public static Complex64 sin(Complex64 num)
      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

      public static Complex64 asin(Complex64 num)
      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

      public static Complex64 sinh(Complex64 num)
      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

      public static Complex64 cos(Complex64 num)
      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

      public static Complex64 acos(Complex64 num)
      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

      public static Complex64 cosh(Complex64 num)
      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

      public static Complex64 tan(Complex64 num)
      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

      public static Complex64 atan(Complex64 num)
      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

      public static Complex64 tanh(Complex64 num)
      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

      public static Complex64 sgn(Complex64 value)
      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

      public static Complex64 round(Complex64 n)
      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 is Float.NaN, Float.POSITIVE_INFINITY or Float.NEGATIVE_INFINITY
      See Also:
    • round

      public static Complex64 round(Complex64 n, int decimals)
      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.
      See Also:
    • roundToZero

      public static Complex64 roundToZero(Complex64 n, float tol)
      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

      public static boolean nearZero(Complex64 n, float tol)
      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 to tol; false otherwise.
      Throws:
      IllegalArgumentException - If tol is less than 0.
    • compareTo

      public int compareTo(Complex64 b)
      Compares this element of the field with b.
      Specified by:
      compareTo in interface Comparable<Complex64>
      Specified by:
      compareTo in interface Semiring<Complex64>
      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 than b in magnitude.
    • 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 interface Semiring<Complex64>
      Returns:
      A double value equivalent to this complex number. This will be the magnitude of the complex number.
    • min

      public static Complex64 min(Complex64... values)
      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, then null is returned.
    • minRe

      public static Complex64 minRe(Complex64... values)
      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, Float.NaN is returned.
    • max

      public static Complex64 max(Complex64... values)
      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 null is returned.
    • maxRe

      public static Complex64 maxRe(Complex64... values)
      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, Float.NaN is returned.
    • argmin

      public static int argmin(Complex64... values)
      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

      public static int argminReal(Complex64... values)
      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

      public static int argmax(Complex64... values)
      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

      public static int argmaxReal(Complex64... values)
      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.
    • isFloat

      public boolean isFloat()
      Checks if this complex number is a real valued float.
      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 return Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, or Float.NaN if both components are finite but computing the magnitude explicitly results in an overflow.

      Specified by:
      isFinite in interface Field<Complex64>
      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 interface Field<Complex64>
      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 interface Field<Complex64>
      Returns:
      True if this field element is NaN in magnitude. False otherwise (i.e. finite, NaN, etc.).
    • re

      public float re()
      Gets the real component of this complex number.
      Returns:
      The real component of this complex number.
    • im

      public float im()
      Gets the imaginary component of this complex number.
      Returns:
      The imaginary component of this complex number.
    • length

      public static int length(Complex64 a)
      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

      public String toString()
      Converts the complex number to a string representation.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the complex number.