Class Complex

  • All Implemented Interfaces:
    java.io.Serializable

    public class Complex
    extends java.lang.Object
    implements java.io.Serializable
    A support class for complex numbers.
    Author:
    talonso
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Complex​(double r, double i)
      Explicit constructor.
    • Constructor Detail

      • Complex

        public Complex​(double r,
                       double i)
        Explicit constructor.
        Parameters:
        r - Real.
        i - Imaginary.
    • Method Detail

      • getReal

        public double getReal()
        Real part
        Returns:
        the real
      • getImaginary

        public double getImaginary()
        Imaginary part
        Returns:
        the imaginary
      • add

        public Complex add​(Complex a)
        Add operation.
        Parameters:
        a - A complex number.
        Returns:
        The sum of both.
      • multiply

        public Complex multiply​(double x)
        Multiplies a complex by a scalar.
        Parameters:
        x - A number.
        Returns:
        this*x.
      • exponential

        public Complex exponential()
        Returns the exponential function of certain Complex.
        Returns:
        Exp(this) as a new Complex.
      • toString

        public java.lang.String toString()
        Converts a Complex into a String of the form ( a + bi).
        This enables the Complex to be easily printed. For example, if z was 2 - 5i, then
         System.out.println("z = " + z);
         
        would print
             z = (2 - 5i)
         
        Overrides:
        toString in class java.lang.Object
        Returns:
        String containing the cartesian coordinate representation