Class DoubleComplex

java.lang.Object
com.xinapse.image.Complex
com.xinapse.image.DoubleComplex

public final class DoubleComplex extends Complex
A complex (real, imaginary) number, with double precision.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new DoubleComplex number, with zero real and imaginary parts.
    DoubleComplex(double r, double i)
    Creates a new DoubleComplex number, with the real and imaginary parts specified by the arguments.
    Creates a new DoubleComplex number, with the real and imaginary parts copied from an existing Complex number.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Complex cmplx)
    Adds the value of this complex number to another complex number, and returns the result.
    Returns the complex conjugate of this complex number.
    divide(Complex cmplx)
    Divides this complex by another complex number, and returns the result.
    boolean
    Determines whether another object is equal to this DoubleComplex number.
    Returns the exponential of this complex number multiplied by i.
    double
    Returns the polar angle of this complex number.
    static double[]
    getArg(double[] complexArray)
    Returns a double[] of phases of an array of interleaved complex real/imaginary components.
    static double[]
    getArg(double[] complexArray, int from, int to)
    Returns a double[] of phases of an array of interleaved complex real/imaginary components within a specified range of indices.
    static double[]
    getArg(Complex[] complexArray, int from, int to)
    Returns a double[] of phases of an array of Complex, within a specified range of indices.
    double
    Returns the imaginary part of this complex number.
    static double[]
    getImag(double[] complexArray)
    Returns a double[] of imag values of an array of interleaved complex imag/imaginary components.
    static double[]
    getImag(double[] complexArray, int from, int to)
    Returns a double[] of imaginary values from an array of interleaved complex real/imaginary components within a specified range of indices.
    static double[]
    getImag(Complex[] complexArray)
    Returns a double[] of imaginary components of an array of Complex.
    static double[]
    getImag(Complex[] complexArray, int from, int to)
    Returns a double[] of imaginary components of an array of Complex, within a specified range of indices.
    double
    Returns the modulus of this complex number.
    static double[]
    getMod(double[] complexArray)
    Returns a double[] of magnitudes of an array of interleaved complex real/imaginary components.
    static double[]
    getMod(double[] complexArray, int from, int to)
    Returns a double[] of magnitudes of an array of interleaved complex real/imaginary components within a specified range of indices.
    static double[]
    getMod(Complex[] complexArray)
    Returns a double[] of magnitudes of an array of Complex.
    static double[]
    getMod(Complex[] complexArray, int from, int to)
    Returns a double[] of magnitudes of an array of Complex, within a specified range of indices.
    double
    Returns the square of the modulus of this complex number.
    double
    Returns the real part of this complex number.
    static double[]
    getReal(double[] complexArray)
    Returns a double[] of real values of an array of interleaved complex real/imaginary components.
    static double[]
    getReal(double[] complexArray, int from, int to)
    Returns a double[] of real values of an array of interleaved complex real/imaginary components within a specified range of indices.
    static double[]
    getReal(Complex[] complexArray)
    Returns a double[] of real components of an array of Complex.
    static double[]
    getReal(Complex[] complexArray, int from, int to)
    Returns a double[] of real components of an array of Complex, within a specified range of indices.
    Returns this complex number divided by its absolute value.
    int
    Returns a hash code value for this DoubleComplex number.
    boolean
    Tests whether this complex number is zero.
    log()
    Returns the natural log of this complex number.
    Multiplies this complex number by another complex number, and returns the result.
    polar(double mod, double arg)
    Creates a new DoubleComplex given the modulus and argument (in radians).
    random(double sd, Random random)
    Creates a new random DoubleComplex from a distribution with zero mean, and the specified standard deviation.
    scale(double factor)
    Scales this Complex by a real scalar value and returns the result.
    Subtracts another complex number from this complex number, and returns the result.
    static double[]
    Returns a double[] of interleaved read/imaginary components of an array of Complex.
    static double[]
    toInterleavedDoubleArray(Complex[] complexArray, int from, int to)
    Returns a double[] of interleaved read/imaginary components of an array of Complex, within a specified range of indices.
    Returns a string representation of this complex number.

    Methods inherited from class Complex

    getValue

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DoubleComplex

      public DoubleComplex()
      Creates a new DoubleComplex number, with zero real and imaginary parts.
    • DoubleComplex

      public DoubleComplex(double r, double i)
      Creates a new DoubleComplex number, with the real and imaginary parts specified by the arguments.
      Parameters:
      r - the real part of the complex number.
      i - the imaginary part of the complex number.
    • DoubleComplex

      public DoubleComplex(Complex c)
      Creates a new DoubleComplex number, with the real and imaginary parts copied from an existing Complex number.
      Parameters:
      c - the Complex number to copy.
  • Method Details

    • polar

      public static DoubleComplex polar(double mod, double arg)
      Creates a new DoubleComplex given the modulus and argument (in radians).
      Parameters:
      mod - the modulus.
      arg - the argument in radians.
      Returns:
      a new DoubleComplex from the modulus and argument.
    • random

      public static DoubleComplex random(double sd, Random random)
      Creates a new random DoubleComplex from a distribution with zero mean, and the specified standard deviation.
      Parameters:
      sd - the standard deviation.
      random - the random number generator.
      Returns:
      a new random DoubleComplex.
    • getReal

      public double getReal()
      Description copied from class: Complex
      Returns the real part of this complex number.
      Specified by:
      getReal in class Complex
      Returns:
      the real part of this complex number.
    • getImag

      public double getImag()
      Description copied from class: Complex
      Returns the imaginary part of this complex number.
      Specified by:
      getImag in class Complex
      Returns:
      the imaginary part of this complex number.
    • getArg

      public double getArg()
      Description copied from class: Complex
      Returns the polar angle of this complex number.
      Specified by:
      getArg in class Complex
      Returns:
      the polar angle of this complex number.
    • getMod

      public double getMod()
      Description copied from class: Complex
      Returns the modulus of this complex number.
      Specified by:
      getMod in class Complex
      Returns:
      the modulus of this complex number.
    • getModSq

      public double getModSq()
      Description copied from class: Complex
      Returns the square of the modulus of this complex number.
      Specified by:
      getModSq in class Complex
      Returns:
      the square of the modulus of this complex number.
    • getSign

      public Complex getSign()
      Description copied from class: Complex
      Returns this complex number divided by its absolute value.
      Specified by:
      getSign in class Complex
      Returns:
      this complex number divided by its absolute value.
    • add

      public DoubleComplex add(Complex cmplx)
      Description copied from class: Complex
      Adds the value of this complex number to another complex number, and returns the result.
      Specified by:
      add in class Complex
      Parameters:
      cmplx - the complex number to add.
      Returns:
      the result of adding this to another complex number.
    • subtract

      public DoubleComplex subtract(Complex cmplx)
      Description copied from class: Complex
      Subtracts another complex number from this complex number, and returns the result.
      Specified by:
      subtract in class Complex
      Parameters:
      cmplx - the complex number to subtract.
      Returns:
      the result of subtracting another complex number from this.
    • multiply

      public DoubleComplex multiply(Complex cmplx)
      Description copied from class: Complex
      Multiplies this complex number by another complex number, and returns the result.
      Specified by:
      multiply in class Complex
      Parameters:
      cmplx - the complex by which to multiply.
      Returns:
      the result of multiplying this by another complex number.
    • divide

      public DoubleComplex divide(Complex cmplx)
      Description copied from class: Complex
      Divides this complex by another complex number, and returns the result.
      Specified by:
      divide in class Complex
      Parameters:
      cmplx - the complex by which to divide.
      Returns:
      the result of dividing this by another complex number.
    • scale

      public DoubleComplex scale(double factor)
      Description copied from class: Complex
      Scales this Complex by a real scalar value and returns the result.
      Specified by:
      scale in class Complex
      Parameters:
      factor - the real scalar value by which to scale.
      Returns:
      the result of scaling this Complex by a real scalar value.
    • conj

      public DoubleComplex conj()
      Description copied from class: Complex
      Returns the complex conjugate of this complex number.
      Specified by:
      conj in class Complex
      Returns:
      the complex conjugate of this complex number.
    • expi

      public DoubleComplex expi()
      Description copied from class: Complex
      Returns the exponential of this complex number multiplied by i.
      Specified by:
      expi in class Complex
      Returns:
      the exponential of this complex number multiplied by i.
    • log

      public DoubleComplex log()
      Description copied from class: Complex
      Returns the natural log of this complex number.
      Specified by:
      log in class Complex
      Returns:
      the natural log of this complex number.
    • isZero

      public boolean isZero()
      Description copied from class: Complex
      Tests whether this complex number is zero.
      Specified by:
      isZero in class Complex
      Returns:
      true if both the real and imaginary components are zero; false otherwise.
    • toInterleavedDoubleArray

      public static double[] toInterleavedDoubleArray(Complex[] complexArray)
      Returns a double[] of interleaved read/imaginary components of an array of Complex.
      Parameters:
      complexArray - the array of Complex.
      Returns:
      a double[] of of interleaved read/imaginary components.
    • toInterleavedDoubleArray

      public static double[] toInterleavedDoubleArray(Complex[] complexArray, int from, int to)
      Returns a double[] of interleaved read/imaginary components of an array of Complex, within a specified range of indices.
      Parameters:
      complexArray - the array of Complex.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of of interleaved read/imaginary components.
    • getReal

      public static double[] getReal(Complex[] complexArray)
      Returns a double[] of real components of an array of Complex.
      Parameters:
      complexArray - the array of Complex.
      Returns:
      a double[] of real components.
    • getReal

      public static double[] getReal(Complex[] complexArray, int from, int to)
      Returns a double[] of real components of an array of Complex, within a specified range of indices.
      Parameters:
      complexArray - the array of Complex.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of real components.
    • getReal

      public static double[] getReal(double[] complexArray)
      Returns a double[] of real values of an array of interleaved complex real/imaginary components.
      Parameters:
      complexArray - the array of interleaved complex real/imaginary components.
      Returns:
      a double[] of real values.
    • getReal

      public static double[] getReal(double[] complexArray, int from, int to)
      Returns a double[] of real values of an array of interleaved complex real/imaginary components within a specified range of indices.
      Parameters:
      complexArray - the array of interleaved complex real/imaginary components.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of real values.
    • getImag

      public static double[] getImag(Complex[] complexArray)
      Returns a double[] of imaginary components of an array of Complex.
      Parameters:
      complexArray - the array of Complex.
      Returns:
      a double[] of imaginary components.
    • getImag

      public static double[] getImag(Complex[] complexArray, int from, int to)
      Returns a double[] of imaginary components of an array of Complex, within a specified range of indices.
      Parameters:
      complexArray - the array of Complex.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of imaginary components.
    • getImag

      public static double[] getImag(double[] complexArray)
      Returns a double[] of imag values of an array of interleaved complex imag/imaginary components.
      Parameters:
      complexArray - the array of interleaved complex imag/imaginary components.
      Returns:
      a double[] of imag values.
    • getImag

      public static double[] getImag(double[] complexArray, int from, int to)
      Returns a double[] of imaginary values from an array of interleaved complex real/imaginary components within a specified range of indices.
      Parameters:
      complexArray - the array of interleaved complex real/imaginary components.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of imaginary values.
    • getMod

      public static double[] getMod(Complex[] complexArray)
      Returns a double[] of magnitudes of an array of Complex.
      Parameters:
      complexArray - the array of Complex.
      Returns:
      a double[] of magnitudes.
    • getMod

      public static double[] getMod(Complex[] complexArray, int from, int to)
      Returns a double[] of magnitudes of an array of Complex, within a specified range of indices.
      Parameters:
      complexArray - the array of Complex.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of magnitudes.
    • getMod

      public static double[] getMod(double[] complexArray) throws CancelledException
      Returns a double[] of magnitudes of an array of interleaved complex real/imaginary components.
      Parameters:
      complexArray - the array of interleaved complex real/imaginary components.
      Returns:
      a double[] of magnitudes.
      Throws:
      CancelledException - if the operation takes too long to complete.
    • getMod

      public static double[] getMod(double[] complexArray, int from, int to) throws CancelledException
      Returns a double[] of magnitudes of an array of interleaved complex real/imaginary components within a specified range of indices.
      Parameters:
      complexArray - the array of interleaved complex real/imaginary components.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of magnitudes.
      Throws:
      CancelledException - if the operation takes too long to complete.
    • getArg

      public static double[] getArg(Complex[] complexArray, int from, int to)
      Returns a double[] of phases of an array of Complex, within a specified range of indices.
      Parameters:
      complexArray - the array of Complex.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of phases.
    • getArg

      public static double[] getArg(double[] complexArray) throws CancelledException
      Returns a double[] of phases of an array of interleaved complex real/imaginary components.
      Parameters:
      complexArray - the array of interleaved complex real/imaginary components.
      Returns:
      a double[] of phases.
      Throws:
      CancelledException - if the operation takes too long to complete.
    • getArg

      public static double[] getArg(double[] complexArray, int from, int to) throws CancelledException
      Returns a double[] of phases of an array of interleaved complex real/imaginary components within a specified range of indices.
      Parameters:
      complexArray - the array of interleaved complex real/imaginary components.
      from - the initial index of the range to be extracted, inclusive.
      to - the final index of the range to be extracted, exclusive.
      Returns:
      a double[] of phases.
      Throws:
      CancelledException - if the operation takes too long to complete.
    • equals

      public boolean equals(Object o)
      Determines whether another object is equal to this DoubleComplex number.
      The result is true if and only if the argument is not null and is a Complex object that has the same real and imaginary components as this DoubleComplex object.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with.
      Returns:
      true if the objects are the same; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this DoubleComplex number.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this DoubleComplex number.
    • toString

      public String toString()
      Description copied from class: Complex
      Returns a string representation of this complex number.
      Specified by:
      toString in class Complex
      Returns:
      string representation of this complex.