Documentation of 'math.jwave.datatypes.Complex' Java class
Complex
math.jwave.datatypes

Class Complex



  • public class Complex
    extends java.lang.Object
    A class to represent a Complex Number. A Complex object is immutable once created; the add, subtract and multiply routines return newly-created Complex objects containing each requested result.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Complex()
      Standard constructor.
      Complex(Complex c)
      Copy constructor.
      Complex(double r, double j)
      Constructor taking real and imaginary number.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Complex add(Complex c)
      Add another complex number to this one and return.
      void addImag(double j)
      Add to imaginary number.
      void addReal(double r)
      Add to real number.
      Complex conjugate()
      Returns the conjugate complex number of this complex number.
      Complex div(Complex c)
      Divide this complex number by another one.
      Complex div(double s)
      Divide this complex number by a scalar.
      boolean equals(java.lang.Object obj)
      Compare this Complex number with another one.
      double getImag()
      Return the imaginary number.
      double getMag()
      Calculate the magnitude of the complex number.
      double getPhi()
      Calculates the angle phi of a complex number.
      double getReal()
      Return the real number.
      int hashCode()
      Generates a hash code for this object.
      Complex mul(Complex c)
      Multiply this complex number times another one.
      Complex mul(double s)
      Multiply this complex number times a scalar.
      void mulImag(double s)
      multiply scalar to imaginary number.
      void mulReal(double s)
      multiply scalar to real number.
      void setImag(double j)
      Set the imaginary number.
      void setReal(double r)
      Set the real number.
      void show()
      Print this complex number to console.
      void show(java.lang.String ident)
      Print this complex number to console with an identifier before.
      void showMag()
      Print magnitude to console out.
      void showPhi()
      Print angle to console out.
      Complex sub(Complex c)
      Subtract another complex number from this one.
      double[] toArr()
      Returns the stored values as new double array: [ real, imag ].
      java.lang.String toString()
      Display the current Complex as a String, for usage in println( ) and elsewhere.
      • Methods inherited from class java.lang.Object

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

      • Complex

        public Complex()
        Standard constructor.
      • Complex

        public Complex(Complex c)
        Copy constructor.
        Parameters:
        c - complex number
      • Complex

        public Complex(double r,
                       double j)
        Constructor taking real and imaginary number.
        Parameters:
        r - real number
        j - imaginary number
    • Method Detail

      • toString

        public java.lang.String toString()
        Display the current Complex as a String, for usage in println( ) and elsewhere.
        Overrides:
        toString in class java.lang.Object
      • getReal

        public double getReal()
        Return the real number.
        Returns:
        real number of this complex number
      • getImag

        public double getImag()
        Return the imaginary number.
        Returns:
        imaginary number of this complex number
      • setReal

        public void setReal(double r)
        Set the real number.
        Parameters:
        r - the real number
      • setImag

        public void setImag(double j)
        Set the imaginary number.
        Parameters:
        j - the imaginary number
      • addReal

        public void addReal(double r)
        Add to real number.
        Parameters:
        r - the real number
      • addImag

        public void addImag(double j)
        Add to imaginary number.
        Parameters:
        j - the imaginary number
      • mulReal

        public void mulReal(double s)
        multiply scalar to real number.
        Parameters:
        s - scalar
      • mulImag

        public void mulImag(double s)
        multiply scalar to imaginary number.
        Parameters:
        s - scalar
      • getMag

        public double getMag()
        Calculate the magnitude of the complex number.
        Returns:
        magnitude of this complex number
      • getPhi

        public double getPhi()
        Calculates the angle phi of a complex number.
        Returns:
        angle of this complex number
      • toArr

        public double[] toArr()
        Returns the stored values as new double array: [ real, imag ].
        Returns:
        returns stored values as array [ real, imag ]
      • conjugate

        public Complex conjugate()
        Returns the conjugate complex number of this complex number.
        Returns:
        new object of Complex keeping the result
      • add

        public Complex add(Complex c)
        Add another complex number to this one and return.
        Parameters:
        c - complex number
        Returns:
        new object of Complex keeping the result
      • sub

        public Complex sub(Complex c)
        Subtract another complex number from this one.
        Parameters:
        c - complex number
        Returns:
        new object of Complex keeping the result
      • mul

        public Complex mul(Complex c)
        Multiply this complex number times another one.
        Parameters:
        c - complex number
        Returns:
        new object of Complex keeping the result
      • mul

        public Complex mul(double s)
        Multiply this complex number times a scalar.
        Parameters:
        s - scalar
        Returns:
        new object of Complex keeping the result
      • div

        public Complex div(Complex c)
        Divide this complex number by another one.
        Parameters:
        c - complex number
        Returns:
        new object of Complex keeping the result
      • div

        public Complex div(double s)
        Divide this complex number by a scalar.
        Parameters:
        s - scalar
        Returns:
        new object of Complex keeping the result
      • hashCode

        public int hashCode()
        Generates a hash code for this object.
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()
      • equals

        public boolean equals(java.lang.Object obj)
        Compare this Complex number with another one.
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • show

        public void show()
        Print this complex number to console.
      • show

        public void show(java.lang.String ident)
        Print this complex number to console with an identifier before.
        Parameters:
        ident - string to label this complex number
      • showMag

        public void showMag()
        Print magnitude to console out.
      • showPhi

        public void showPhi()
        Print angle to console out.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.