Package edu.jas.poly

Class GenWordPolynomial<C extends RingElem<C>>

    • Method Detail

      • length

        public int length()
        Length of GenWordPolynomial.
        Returns:
        number of coefficients of this GenWordPolynomial.
      • getMap

        public java.util.SortedMap<Word,​CgetMap()
        Word to coefficient map of GenWordPolynomial.
        Returns:
        val as unmodifiable SortedMap.
      • doPutToMap

        public void doPutToMap​(Word e,
                               C c)
        Put a Word to coefficient entry into the internal map of this GenWordPolynomial. Note: Do not use this method unless you are constructing a new polynomial. this is modified and breaks the immutability promise of this class.
        Parameters:
        c - coefficient.
        e - word.
      • doRemoveFromMap

        public void doRemoveFromMap​(Word e,
                                    C c)
        Remove a Word to coefficient entry from the internal map of this GenWordPolynomial. Note: Do not use this method unless you are constructing a new polynomial. this is modified and breaks the immutability promise of this class.
        Parameters:
        e - Word.
        c - expected coefficient, null for ignore.
      • doPutToMap

        public void doPutToMap​(java.util.SortedMap<Word,​C> vals)
        Put an a sorted map of words to coefficients into the internal map of this GenWordPolynomial. Note: Do not use this method unless you are constructing a new polynomial. this is modified and breaks the immutability promise of this class.
        Parameters:
        vals - sorted map of wordss and coefficients.
      • toString

        public java.lang.String toString()
        String representation of GenWordPolynomial.
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • 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()
      • isConstant

        public boolean isConstant()
        Is GenWordPolynomial<C> a constant.
        Returns:
        If this is a constant polynomial then true is returned, else false.
      • isHomogeneous

        public boolean isHomogeneous()
        Is GenWordPolynomial<C> homogeneous.
        Returns:
        true, if this is homogeneous, 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 polynomial.
        Specified by:
        hashCode in interface Element<C extends RingElem<C>>
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashCode.
        See Also:
        Object.hashCode()
      • numberOfVariables

        public int numberOfVariables()
        Number of variables.
        Returns:
        ring.alphabet.length().
      • leadingMonomial

        public java.util.Map.Entry<Word,​CleadingMonomial()
        Leading monomial.
        Returns:
        first map entry.
      • leadingWord

        public Word leadingWord()
        Leading word.
        Returns:
        first highest word.
      • trailingWord

        public Word trailingWord()
        Trailing word.
        Returns:
        last lowest word.
      • trailingBaseCoefficient

        public C trailingBaseCoefficient()
        Trailing base coefficient.
        Returns:
        coefficient of constant term.
      • coefficient

        public C coefficient​(Word e)
        Coefficient.
        Parameters:
        e - word.
        Returns:
        coefficient for given word.
      • degree

        public long degree()
        Maximal degree.
        Returns:
        maximal degree in any variables.
      • maxNorm

        public C maxNorm()
        GenWordPolynomial maximum norm.
        Returns:
        ||this||.
      • sumNorm

        public C sumNorm()
        GenWordPolynomial sum norm.
        Returns:
        sum of all absolute values of coefficients.
      • sum

        public GenWordPolynomial<Csum​(C a,
                                        Word e)
        GenWordPolynomial addition. This method is not very efficient, since this is copied.
        Parameters:
        a - coefficient.
        e - word.
        Returns:
        this + a e.
      • sum

        public GenWordPolynomial<Csum​(C a)
        GenWordPolynomial addition. This method is not very efficient, since this is copied.
        Parameters:
        a - coefficient.
        Returns:
        this + a x0.
      • subtract

        public GenWordPolynomial<Csubtract​(C a,
                                             Word e)
        GenWordPolynomial subtraction. This method is not very efficient, since this is copied.
        Parameters:
        a - coefficient.
        e - word.
        Returns:
        this - a e.
      • subtract

        public GenWordPolynomial<Csubtract​(C a)
        GenWordPolynomial subtract. This method is not very efficient, since this is copied.
        Parameters:
        a - coefficient.
        Returns:
        this + a x0.
      • multiply

        public GenWordPolynomial<Cmultiply​(C s)
        GenWordPolynomial multiplication. Product with coefficient ring element.
        Parameters:
        s - coefficient.
        Returns:
        this*s.
      • multiply

        public GenWordPolynomial<Cmultiply​(C s,
                                             C t)
        GenWordPolynomial multiplication. Product with coefficient ring element.
        Parameters:
        s - coefficient.
        t - coefficient.
        Returns:
        s*this*t.
      • monic

        public GenWordPolynomial<Cmonic()
        GenWordPolynomial monic, i.e. leadingCoefficient == 1. If leadingCoefficient is not invertible returns this unmodified.
        Returns:
        monic(this).
      • multiply

        public GenWordPolynomial<Cmultiply​(C s,
                                             Word e)
        GenWordPolynomial multiplication. Product with ring element and word.
        Parameters:
        s - coefficient.
        e - left word.
        Returns:
        this * s e.
      • multiply

        public GenWordPolynomial<Cmultiply​(Word e,
                                             Word f)
        GenWordPolynomial left and right multiplication. Product with ring element and two words.
        Parameters:
        e - left word.
        f - right word.
        Returns:
        e * this * f.
      • multiply

        public GenWordPolynomial<Cmultiply​(C s,
                                             Word e,
                                             Word f)
        GenWordPolynomial left and right multiplication. Product with ring element and two words.
        Parameters:
        s - coefficient.
        e - left word.
        f - right word.
        Returns:
        e * this * s * f.
      • multiply

        public GenWordPolynomial<Cmultiply​(C s,
                                             Word e,
                                             C t,
                                             Word f)
        GenWordPolynomial left and right multiplication. Product with ring element and two words.
        Parameters:
        s - coefficient.
        e - left word.
        t - coefficient.
        f - right word.
        Returns:
        s * e * this * t * f.
      • multiply

        public GenWordPolynomial<Cmultiply​(Word e)
        GenWordPolynomial multiplication. Product with word.
        Parameters:
        e - word (!= null).
        Returns:
        this * e.
      • multiply

        public GenWordPolynomial<Cmultiply​(java.util.Map.Entry<Word,​C> m)
        GenWordPolynomial multiplication. Product with 'monomial'.
        Parameters:
        m - 'monomial'.
        Returns:
        this * m.
      • divide

        public GenWordPolynomial<Cdivide​(C s)
        GenWordPolynomial division. Division by coefficient ring element. Fails, if exact division is not possible.
        Parameters:
        s - coefficient.
        Returns:
        this/s.
      • quotientRemainder

        public GenWordPolynomial<C>[] quotientRemainder​(GenWordPolynomial<C> S)
        GenWordPolynomial division with remainder. Fails, if exact division by leading base coefficient is not possible. Meaningful only for univariate polynomials over fields, but works in any case.
        Specified by:
        quotientRemainder in interface MonoidElem<C extends RingElem<C>>
        Parameters:
        S - nonzero GenWordPolynomial with invertible leading coefficient.
        Returns:
        [ quotient , remainder ] with this = quotient * S + remainder and deg(remainder) < deg(S) or remainder = 0.
        See Also:
        .
      • divide

        public GenWordPolynomial<Cdivide​(GenWordPolynomial<C> S)
        GenWordPolynomial division. Fails, if exact division by leading base coefficient is not possible. Meaningful only for univariate polynomials over fields, but works in any case.
        Specified by:
        divide in interface MonoidElem<C extends RingElem<C>>
        Parameters:
        S - nonzero GenWordPolynomial with invertible leading coefficient.
        Returns:
        quotient with this = quotient * S + remainder.
        See Also:
        .
      • remainder

        public GenWordPolynomial<Cremainder​(GenWordPolynomial<C> S)
        GenWordPolynomial remainder. Fails, if exact division by leading base coefficient is not possible. Meaningful only for univariate polynomials over fields, but works in any case.
        Specified by:
        remainder in interface MonoidElem<C extends RingElem<C>>
        Parameters:
        S - nonzero GenWordPolynomial with invertible leading coefficient.
        Returns:
        remainder with this = quotient * S + remainder.
        See Also:
        .
      • egcd

        public GenWordPolynomial<C>[] egcd​(GenWordPolynomial<C> S)
        GenWordPolynomial extended greatest common divisor. Only for univariate polynomials over fields.
        Specified by:
        egcd in interface RingElem<C extends RingElem<C>>
        Parameters:
        S - GenWordPolynomial.
        Returns:
        [ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).
      • hegcd

        public GenWordPolynomial<C>[] hegcd​(GenWordPolynomial<C> S)
        GenWordPolynomial half extended greatest common divisor. Only for univariate polynomials over fields.
        Parameters:
        S - GenWordPolynomial.
        Returns:
        [ gcd(this,S), a ] with a*this + b*S = gcd(this,S).
      • modInverse

        public GenWordPolynomial<CmodInverse​(GenWordPolynomial<C> m)
        GenWordPolynomial modular inverse. Only for univariate polynomials over fields.
        Parameters:
        m - GenWordPolynomial.
        Returns:
        a with with a*this = 1 mod m.
      • coefficientIterator

        public java.util.Iterator<CcoefficientIterator()
        Iterator over coefficients.
        Returns:
        val.values().iterator().
      • wordIterator

        public java.util.Iterator<WordwordIterator()
        Iterator over words.
        Returns:
        val.keySet().iterator().
      • iterator

        public java.util.Iterator<WordMonomial<C>> iterator()
        Iterator over monomials.
        Specified by:
        iterator in interface java.lang.Iterable<C extends RingElem<C>>
        Returns:
        a PolyIterator.
      • map

        public GenWordPolynomial<Cmap​(UnaryFunctor<? super C,​C> f)
        Map a unary function to the coefficients.
        Parameters:
        f - evaluation functor.
        Returns:
        new polynomial with coefficients f(this(e)).