Class Complex

java.lang.Object
calculator.atoms.Complex
All Implemented Interfaces:
Atom, Expression

public class Complex extends Object implements Atom
Complex Number type is used to represent complex e.g. 3 + 2i
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Complex(double real, double imaginary)
    Constructor method
    Complex(org.apache.commons.numbers.complex.Complex value)
    Constructor method from an existing Complex object
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accepts the specific AtomVisitor
    void
    accept is a method needed to implement the visitor design pattern
    Applies an Binary between two atoms of the same concrete type The function supposes that both atoms are of the same concrete type
    Applies an operation on the atom
    Applies an operation between two atoms of the same concrete type The function supposes that both atoms are of the same concrete type
    boolean
     
    org.apache.commons.numbers.complex.Complex
    getter method to obtain the value contained in the object
    int
     
    boolean
    Returns if a complex is a NaN
    static Complex
    nan()
    Returns a Complex representing a NaN
     

    Methods inherited from class Object

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

    • Complex

      public Complex(double real, double imaginary)
      Constructor method
      Parameters:
      real - The real part
      imaginary - The imaginary part
    • Complex

      public Complex(org.apache.commons.numbers.complex.Complex value)
      Constructor method from an existing Complex object
      Parameters:
      value - The commons-numbers Complex object
  • Method Details

    • nan

      public static Complex nan()
      Returns a Complex representing a NaN
      Returns:
      a NaN Complex
    • isNaN

      public boolean isNaN()
      Returns if a complex is a NaN
      Returns:
      true iff the complex represents a NaN
    • getValue

      public org.apache.commons.numbers.complex.Complex getValue()
      getter method to obtain the value contained in the object
      Returns:
      The commons-numbers Complex number contained in the object
    • apply

      public Complex apply(Operation o, Atom a)
      Description copied from interface: Atom
      Applies an operation between two atoms of the same concrete type The function supposes that both atoms are of the same concrete type
      Specified by:
      apply in interface Atom
      Parameters:
      o - the operation to apply
      a - the other atom
      Returns:
      the result of the operation having the same type as a
      See Also:
    • apply

      public Atom apply(BinaryFunction f, Atom a)
      Description copied from interface: Atom
      Applies an Binary between two atoms of the same concrete type The function supposes that both atoms are of the same concrete type
      Specified by:
      apply in interface Atom
      Parameters:
      f - the binary function to with this atom as first parameter
      a - the other atom
      Returns:
      the result of the operation having the same type as a
      See Also:
    • apply

      public Complex apply(UnaryFunction o)
      Description copied from interface: Atom
      Applies an operation on the atom
      Specified by:
      apply in interface Atom
      Parameters:
      o - the unary operation to apply
      Returns:
      the result of the operation
    • accept

      public void accept(AtomVisitor v)
      Description copied from interface: Atom
      accepts the specific AtomVisitor
      Specified by:
      accept in interface Atom
      Parameters:
      v - The Atomvisitor object being passed as a parameter
    • accept

      public void accept(Visitor v)
      Description copied from interface: Expression
      accept is a method needed to implement the visitor design pattern
      Specified by:
      accept in interface Expression
      Parameters:
      v - The visitor object being passed as a parameter
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object