Documentation of 'jsat.math.Complex' Java class
Complex
jsat.math

Class Complex

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class Complex
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    A class for representing a complex value by a real and imaginary double pair.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Complex(double real, double imag)
      Creates a new Complex number
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Complex add(Complex c)
      Creates a new complex number containing the resulting addition of this and another
      static void cDiv(double a, double b, double c, double d, double[] results)
      Performs a complex division operation.
      static void cMul(double a, double b, double c, double d, double[] results)
      Performs a complex multiplication
      Complex divide(Complex c)
      Creates a new complex number containing the resulting division of this by another
      boolean equals(java.lang.Object obj) 
      boolean equals(java.lang.Object obj, double eps)
      Checks if this is approximately equal to another Complex object
      double getArg()
      Computes the Argument, also called phase, of this complex number.
      Complex getConjugate()
      Returns a new complex number representing the complex conjugate of this one
      double getImag()
      Returns the imaginary part of this complex number
      double getMagnitude()
      Computes the magnitude of this complex number, which is sqrt(Re2+Im2)
      double getReal()
      Returns the real part of this complex number
      int hashCode() 
      static Complex I()
      Returns the complex number representing sqrt(-1)
      Complex multiply(Complex c)
      Creates a new complex number containing the resulting multiplication between this and another
      void mutableAdd(Complex c)
      Alters this complex number to contain the result of the addition of another
      void mutableAdd(double r, double i)
      Alters this complex number as if an addition of another complex number was performed.
      void mutableDivide(Complex c)
      Alters this complex number to contain the result of the division by another
      void mutableDivide(double c, double d)
      Alters this complex number as if a division by another complex number was performed.
      void mutableMultiply(Complex c)
      Alters this complex number to contain the result of the multiplication of another
      void mutableMultiply(double c, double d)
      Alters this complex number as if a multiplication of another complex number was performed.
      void mutableSubtract(Complex c)
      Alters this complex number to contain the result of the subtraction of another
      void mutableSubtract(double r, double i)
      Alters this complex number as if a subtraction of another complex number was performed.
      void mutateConjugate()
      Alters this complex number so that it represents its complex conjugate instead.
      void setImag(double imag)
      Sets the imaginary value part of this complex number
      void setReal(double r)
      Sets the real value part of this complex number
      Complex subtract(Complex c)
      Creates a new complex number containing the resulting subtracting another from this one
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Complex

        public Complex(double real,
                       double imag)
        Creates a new Complex number
        Parameters:
        real - the real part of the number
        imag - the imaginary part of the number
    • Method Detail

      • I

        public static Complex I()
        Returns the complex number representing sqrt(-1)
        Returns:
        the complex number i
      • getReal

        public double getReal()
        Returns the real part of this complex number
        Returns:
        the real part of this complex number
      • setReal

        public void setReal(double r)
        Sets the real value part of this complex number
        Parameters:
        r - the new real value
      • setImag

        public void setImag(double imag)
        Sets the imaginary value part of this complex number
        Parameters:
        imag - the new imaginary value
      • getImag

        public double getImag()
        Returns the imaginary part of this complex number
        Returns:
        the imaginary part of this complex number
      • mutableAdd

        public void mutableAdd(double r,
                               double i)
        Alters this complex number as if an addition of another complex number was performed.
        Parameters:
        r - the real part of the other number
        i - the imaginary part of the other number
      • mutableAdd

        public void mutableAdd(Complex c)
        Alters this complex number to contain the result of the addition of another
        Parameters:
        c - the complex value to add to this
      • add

        public Complex add(Complex c)
        Creates a new complex number containing the resulting addition of this and another
        Parameters:
        c - the number to add
        Returns:
        this+c
      • mutableSubtract

        public void mutableSubtract(double r,
                                    double i)
        Alters this complex number as if a subtraction of another complex number was performed.
        Parameters:
        r - the real part of the other number
        i - the imaginary part of the other number
      • mutableSubtract

        public void mutableSubtract(Complex c)
        Alters this complex number to contain the result of the subtraction of another
        Parameters:
        c - the number to subtract
      • subtract

        public Complex subtract(Complex c)
        Creates a new complex number containing the resulting subtracting another from this one
        Parameters:
        c - the number to subtract
        Returns:
        this-c
      • cMul

        public static void cMul(double a,
                                double b,
                                double c,
                                double d,
                                double[] results)
        Performs a complex multiplication
        Parameters:
        a - the real part of the first number
        b - the imaginary part of the first number
        c - the real part of the second number
        d - the imaginary part of the second number
        results - an array to store the real and imaginary results in. First index is the real, 2nd is the imaginary.
      • mutableMultiply

        public void mutableMultiply(double c,
                                    double d)
        Alters this complex number as if a multiplication of another complex number was performed.
        Parameters:
        c - the real part of the other number
        d - the imaginary part of the other number
      • mutableMultiply

        public void mutableMultiply(Complex c)
        Alters this complex number to contain the result of the multiplication of another
        Parameters:
        c - the number to multiply by
      • multiply

        public Complex multiply(Complex c)
        Creates a new complex number containing the resulting multiplication between this and another
        Parameters:
        c - the number to multiply by
        Returns:
        this*c
      • cDiv

        public static void cDiv(double a,
                                double b,
                                double c,
                                double d,
                                double[] results)
        Performs a complex division operation.
        The standard complex division performs a set of operations that is suseptible to both overflow and underflow. This method is more numerically stable while still being relatively fast to execute.
        Parameters:
        a - the real part of the first number
        b - the imaginary part of the first number
        c - the real part of the second number
        d - the imaginary part of the second number
        results - an array to store the real and imaginary results in. First index is the real, 2nd is the imaginary.
      • mutableDivide

        public void mutableDivide(double c,
                                  double d)
        Alters this complex number as if a division by another complex number was performed.
        Parameters:
        c - the real part of the other number
        d - the imaginary part of the other number
      • mutableDivide

        public void mutableDivide(Complex c)
        Alters this complex number to contain the result of the division by another
        Parameters:
        c - the number to divide by
      • divide

        public Complex divide(Complex c)
        Creates a new complex number containing the resulting division of this by another
        Parameters:
        c - the number to divide by
        Returns:
        this/c
      • getMagnitude

        public double getMagnitude()
        Computes the magnitude of this complex number, which is sqrt(Re2+Im2)
        Returns:
        the magnitude of this complex number
      • getArg

        public double getArg()
        Computes the Argument, also called phase, of this complex number. Unless the result is Double.NaN, which occurs only for complex zero, the result will be in the range [-pi, pi]
        Returns:
        the argument of this complex number
      • mutateConjugate

        public void mutateConjugate()
        Alters this complex number so that it represents its complex conjugate instead.
      • getConjugate

        public Complex getConjugate()
        Returns a new complex number representing the complex conjugate of this one
        Returns:
        the complex conjugate of this
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object obj,
                              double eps)
        Checks if this is approximately equal to another Complex object
        Parameters:
        obj - the object to compare against
        eps - the maximum acceptable difference between values to be considered equal
        Returns:
        true if the objects are approximately equal

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.