Package edu.jas.arith

Class BigComplex

    • Field Detail

      • re

        public final BigRational re
        Real part of the data structure.
      • im

        public final BigRational im
        Imaginary part of the data structure.
      • random

        private static final java.util.Random random
      • logger

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

        public static final BigComplex ZERO
        The constant 0.
      • ONE

        public static final BigComplex ONE
        The constant 1.
      • I

        public static final BigComplex I
        The constant i.
    • Constructor Detail

      • BigComplex

        public BigComplex​(BigRational r,
                          BigRational i)
        The constructor creates a BigComplex object from two BigRational objects real and imaginary part.
        Parameters:
        r - real part.
        i - imaginary part.
      • BigComplex

        public BigComplex​(BigRational r)
        The constructor creates a BigComplex object from a BigRational object as real part, the imaginary part is set to 0.
        Parameters:
        r - real part.
      • BigComplex

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

        public BigComplex()
        The constructor creates a BigComplex object with real part 0 and imaginary part 0.
      • BigComplex

        public BigComplex​(java.lang.String s)
                   throws java.lang.NumberFormatException
        The constructor creates a BigComplex object from a String representation.
        Parameters:
        s - string of a BigComplex.
        Throws:
        java.lang.NumberFormatException
    • Method Detail

      • copy

        public BigComplex copy()
        Clone this.
        Specified by:
        copy in interface Element<BigComplex>
        Returns:
        Creates and returns a copy of this Element.
        See Also:
        Object.clone()
      • getIMAG

        public BigComplex getIMAG()
        Get the i element.
        Returns:
        i as BigComplex.
      • isField

        public boolean isField()
        Query if this ring is a field.
        Specified by:
        isField in interface RingFactory<BigComplex>
        Returns:
        true.
      • characteristic

        public java.math.BigInteger characteristic()
        Characteristic of this ring.
        Specified by:
        characteristic in interface RingFactory<BigComplex>
        Returns:
        characteristic of this ring.
      • fromInteger

        public BigComplex fromInteger​(java.math.BigInteger a)
        Get a BigComplex element from a BigInteger.
        Specified by:
        fromInteger in interface ElemFactory<BigComplex>
        Parameters:
        a - BigInteger.
        Returns:
        a BigComplex.
      • getRe

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

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

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

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

        public static boolean isCZERO​(BigComplex A)
        Complex number zero.
        Parameters:
        A - is a complex number.
        Returns:
        If A is 0 then true is returned, else false.
      • isCONE

        public static boolean isCONE​(BigComplex A)
        Complex number one.
        Parameters:
        A - is a complex number.
        Returns:
        If A is 1 then true is returned, else false.
      • 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<BigComplex>
        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 BigComplex.
        Specified by:
        hashCode in interface Element<BigComplex>
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashCode.
        See Also:
        Object.hashCode()
      • compareTo

        public int compareTo​(BigComplex b)
        Since complex numbers are unordered, we use lexicographical order of re and im.
        Specified by:
        compareTo in interface java.lang.Comparable<BigComplex>
        Specified by:
        compareTo in interface Element<BigComplex>
        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<BigComplex>
        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()
      • CDIF

        public static BigComplex CDIF​(BigComplex A,
                                      BigComplex B)
        Complex number difference.
        Parameters:
        A - and B are complex numbers.
        Returns:
        A-B.
      • CNEG

        public static BigComplex CNEG​(BigComplex A)
        Complex number negative.
        Parameters:
        A - is a complex number.
        Returns:
        -A
      • CCON

        public static BigComplex CCON​(BigComplex A)
        Complex number conjugate.
        Parameters:
        A - is a complex number.
        Returns:
        the complex conjugate of A.
      • CABS

        public static BigRational CABS​(BigComplex A)
        Complex number absolute value.
        Parameters:
        A - is a complex number.
        Returns:
        the absolute value of A, a rational number. Note: The square root is not jet implemented.
      • CPROD

        public static BigComplex CPROD​(BigComplex A,
                                       BigComplex B)
        Complex number product.
        Parameters:
        A - and B are complex numbers.
        Returns:
        A*B.
      • CINV

        public static BigComplex CINV​(BigComplex A)
        Complex number inverse.
        Parameters:
        A - is a non-zero complex number.
        Returns:
        S with S*A = 1.
      • CQ

        public static BigComplex CQ​(BigComplex A,
                                    BigComplex B)
        Complex number quotient.
        Parameters:
        A - and B are complex numbers, B non-zero.
        Returns:
        A/B.
      • random

        public BigComplex random​(int n)
        Complex number, random. Random rational numbers A and B are generated using random(n). Then R is the complex number with real part A and imaginary part B.
        Specified by:
        random in interface ElemFactory<BigComplex>
        Parameters:
        n - such that 0 ≤ A, B ≤ (2n-1).
        Returns:
        R.
      • random

        public BigComplex random​(int n,
                                 java.util.Random rnd)
        Complex number, random. Random rational numbers A and B are generated using random(n). Then R is the complex number with real part A and imaginary part B.
        Specified by:
        random in interface ElemFactory<BigComplex>
        Parameters:
        n - such that 0 ≤ A, B ≤ (2n-1).
        rnd - is a source for random bits.
        Returns:
        R.
      • CRAND

        public static BigComplex CRAND​(int n)
        Complex number, random. Random rational numbers A and B are generated using random(n). Then R is the complex number with real part A and imaginary part B.
        Parameters:
        n - such that 0 ≤ A, B ≤ (2n-1).
        Returns:
        R.
      • parse

        public BigComplex parse​(java.lang.String s)
        Parse complex number from string.
        Specified by:
        parse in interface ElemFactory<BigComplex>
        Parameters:
        s - String.
        Returns:
        BigComplex from s.
      • parse

        public BigComplex parse​(java.io.Reader r)
        Parse complex number from Reader.
        Specified by:
        parse in interface ElemFactory<BigComplex>
        Parameters:
        r - Reader.
        Returns:
        next BigComplex from r.
      • egcd

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

        public long bitLength()
        Returns the number of bits in the representation of this BigComplex, including a sign bit. It is equivalent to re.bitLength() + im.bitLength().)
        Returns:
        number of bits in the representation of this BigComplex, including a sign bit.