Package mandelbrot

Class Complex


  • public class Complex
    extends java.lang.Object
    The Complex class represents a complex number. Complex numbers are immutable: their values cannot be changed after they are created. It includes methods for addition, subtraction, multiplication, division, conjugation, and other common functions on complex numbers.
    • Constructor Summary

      Constructors 
      Constructor Description
      Complex​(double real, double imaginary)
      Initializes a complex number with the specified real and imaginary parts.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Complex add​(Complex addend)
      Returns a Complex whose value is (this + addend).
      boolean equals​(java.lang.Object other)
      Test for equality with another object.
      static Complex real​(double real)
      Creates a complex number with the specified real part and an imaginary part equal to zero.
      Complex scale​(double lambda)
      Returns the scalar multiplication of this complex number.
      java.lang.String toString()
      Returns a string representation of this complex number.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Complex

        public Complex​(double real,
                       double imaginary)
        Initializes a complex number with the specified real and imaginary parts.
        Parameters:
        real - the real part
        imaginary - the imaginary part
    • Method Detail

      • real

        public static Complex real​(double real)
        Creates a complex number with the specified real part and an imaginary part equal to zero.
        Parameters:
        real - the real component
        Returns:
        the complex real + 0i
      • add

        public Complex add​(Complex addend)
        Returns a Complex whose value is (this + addend).
        Parameters:
        addend - a complex
        Returns:
        the complex number whose value is this + addend
      • scale

        public Complex scale​(double lambda)
        Returns the scalar multiplication of this complex number.
        Parameters:
        lambda - a scalar number
        Returns:
        the complex number lambda * this
      • equals

        public boolean equals​(java.lang.Object other)
        Test for equality with another object. If both the real and imaginary parts of two complex numbers are considered equal according to Helpers.doubleCompare (i.e., within Helpers.RANGE), the two Complex objects are considered to be equal.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - Object to test for equality with this instance.
        Returns:
        true if the objects are equal, false if object is null, not an instance of Complex, or not equal to this instance.
      • toString

        public java.lang.String toString()
        Returns a string representation of this complex number.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this complex number of the form 42.0 - 1024.0i.