Package edu.jas.poly

Class Complex<C extends RingElem<C>>

    • Field Detail

      • logger

        private static final org.apache.logging.log4j.Logger logger
      • debug

        private static final boolean debug
      • re

        protected final C extends RingElem<C> re
        Real part of the data structure.
      • im

        protected final C extends RingElem<C> im
        Imaginary part of the data structure.
    • Constructor Detail

      • Complex

        public Complex​(ComplexRing<C> ring,
                       C r,
                       C i)
        The constructor creates a Complex object from two C objects as real and imaginary part.
        Parameters:
        ring - factory for Complex objects.
        r - real part.
        i - imaginary part.
      • Complex

        public Complex​(ComplexRing<C> ring,
                       C r)
        The constructor creates a Complex object from a C object as real part, the imaginary part is set to 0.
        Parameters:
        r - real part.
      • Complex

        public Complex​(ComplexRing<C> ring,
                       long r)
        The constructor creates a Complex object from a long element as real part, the imaginary part is set to 0.
        Parameters:
        r - real part.
      • Complex

        public Complex​(ComplexRing<C> ring)
        The constructor creates a Complex object with real part 0 and imaginary part 0.
      • Complex

        public Complex​(ComplexRing<C> ring,
                       java.lang.String s)
                throws java.lang.NumberFormatException
        The constructor creates a Complex object from a String representation.
        Parameters:
        s - string of a Complex.
        Throws:
        java.lang.NumberFormatException
    • Method Detail

      • getRe

        public C getRe()
        Get the real part.
        Returns:
        re.
      • getIm

        public C getIm()
        Get the imaginary part.
        Returns:
        im.
      • toString

        public java.lang.String toString()
        Get the String representation.
        Overrides:
        toString in class java.lang.Object
      • toScript

        public java.lang.String toScript()
        Get a scripting compatible string representation.
        Specified by:
        toScript in interface Element<C extends RingElem<C>>
        Returns:
        script compatible representation for this Element.
        See Also:
        Element.toScript()
      • toScriptFactory

        public java.lang.String toScriptFactory()
        Get a scripting compatible string representation of the factory.
        Specified by:
        toScriptFactory in interface Element<C extends RingElem<C>>
        Returns:
        script compatible representation for this ElemFactory.
        See Also:
        Element.toScriptFactory()
      • isIMAG

        public boolean isIMAG()
        Is Complex imaginary one.
        Returns:
        If this is i then true is returned, else false.
      • equals

        public boolean equals​(java.lang.Object b)
        Comparison with any other object.
        Specified by:
        equals in interface Element<C extends RingElem<C>>
        Overrides:
        equals in class java.lang.Object
        Returns:
        true if this is equal to b, else false.
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Hash code for this Complex.
        Specified by:
        hashCode in interface Element<C extends RingElem<C>>
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashCode.
        See Also:
        Object.hashCode()
      • compareTo

        public int compareTo​(Complex<C> b)
        Since complex numbers are unordered, we use lexicographical order of re and im.
        Specified by:
        compareTo in interface java.lang.Comparable<C extends RingElem<C>>
        Specified by:
        compareTo in interface Element<C extends RingElem<C>>
        Returns:
        0 if this is equal to b; 1 if re > b.re, or re == b.re and im > b.im; -1 if re < b.re, or re == b.re and im < b.im
      • signum

        public int signum()
        Since complex numbers are unordered, we use lexicographical order of re and im.
        Specified by:
        signum in interface AbelianGroupElem<C extends RingElem<C>>
        Returns:
        0 if this is equal to 0; 1 if re > 0, or re == 0 and im > 0; -1 if re < 0, or re == 0 and im < 0
        See Also:
        AbelianGroupElem.signum()
      • divide

        public Complex<C> divide​(Complex<C> B)
        Complex number divide.
        Specified by:
        divide in interface MonoidElem<C extends RingElem<C>>
        Parameters:
        B - is a complex number, non-zero.
        Returns:
        this/B.
      • quotientRemainder

        public Complex<C>[] quotientRemainder​(Complex<C> S)
        Complex number quotient and remainder.
        Specified by:
        quotientRemainder in interface MonoidElem<C extends RingElem<C>>
        Parameters:
        S - Complex.
        Returns:
        Complex[] { q, r } with q = this/S and r = rem(this,S).
      • gcd

        public Complex<C> gcd​(Complex<C> S)
        Complex number greatest common divisor.
        Specified by:
        gcd in interface RingElem<C extends RingElem<C>>
        Parameters:
        S - Complex.
        Returns:
        gcd(this,S).
      • egcd

        public Complex<C>[] egcd​(Complex<C> S)
        Complex extended greatest common divisor.
        Specified by:
        egcd in interface RingElem<C extends RingElem<C>>
        Parameters:
        S - Complex.
        Returns:
        [ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).