Class UnivariatePolynomialZ64

    • Method Summary

      Modifier and Type Method Description
      lPoly add​(long val)
      Add constant to this.
      lPoly add​(lPoly oth)
      Adds oth to this.
      lPoly addMonomial​(long coefficient, int exponent)
      Adds coefficient*x^exponent to this
      lPoly addMul​(lPoly oth, long factor)
      Adds oth * factor to this
      AMultivariatePolynomial asMultivariate​(Comparator<DegreeVector> ordering)
      Convert to multivariate polynomial
      long cc()
      Returns the constant coefficient of this poly
      lPoly ccAsPoly()
      Returns the constant coefficient as a constant poly
      UnivariatePolynomialZ64 clone()
      Deep copy of this
      BigInteger coefficientRingCardinality()
      Returns cardinality of the coefficient ring of this poly
      BigInteger coefficientRingCharacteristic()
      Returns characteristic of the coefficient ring of this poly
      BigInteger coefficientRingPerfectPowerBase()
      Returns base so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
      BigInteger coefficientRingPerfectPowerExponent()
      Returns exponent so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
      String coefficientRingToString​(IStringifier<UnivariatePolynomialZ64> stringifier)
      String representation of the coefficient ring of this
      int compareTo​(lPoly o)  
      AMultivariatePolynomial composition​(AMultivariatePolynomial value)
      Calculates the composition of this(oth)
      lPoly composition​(lPoly value)
      Calculates the composition of this(oth) (new instance, so the content of this is not changed))
      static UnivariatePolynomialZ64 constant​(long value)
      Returns constant with specified value
      long content()
      Returns the content of this poly (gcd of its coefficients)
      lPoly contentAsPoly()
      Returns the content of this (gcd of coefficients) as a constant poly
      static UnivariatePolynomialZ64 create​(long... data)
      Creates Z[x] polynomial from the specified coefficients
      UnivariatePolynomialZ64[] createArray​(int length)
      overcome Java generics...
      UnivariatePolynomialZ64[][] createArray2d​(int length)
      overcome Java generics...
      UnivariatePolynomialZ64[][] createArray2d​(int length1, int length2)
      overcome Java generics...
      lPoly createConstant​(long val)
      Creates constant polynomial with specified value (with the same coefficient ring)
      UnivariatePolynomialZ64 createFromArray​(long[] data)
      Creates new poly with the specified coefficients (over the same ring)
      lPoly createLinear​(long cc, long lc)
      Creates linear polynomial of form cc + x * lc (with the same coefficient ring)
      lPoly createMonomial​(int degree)
      Creates new monomial x^degree (with the same coefficient ring)
      UnivariatePolynomialZ64 createMonomial​(long coefficient, int degree)
      Creates monomial coefficient * x^degree (with the same coefficient ring)
      lPoly createOne()
      Returns the new instance of unit polynomial (with the same coefficient ring)
      lPoly createZero()
      Returns the new instance of zero polynomial (with the same coefficient ring)
      lPoly decrement()
      Subtracts 1 from this
      int degree()
      Returns the degree of this polynomial
      UnivariatePolynomialZ64 derivative()
      Returns the formal derivative of this poly (new instance, so the content of this is not changed)
      UnivariatePolynomialZ64 divideByLC​(UnivariatePolynomialZ64 other)
      Divides this polynomial by the leading coefficient of other or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the other.lc().
      UnivariatePolynomialZ64 divideOrNull​(long factor)
      Divides this polynomial by a factor or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the factor.
      void ensureInternalCapacity​(int desiredCapacity)
      ensures that internal storage has enough size to store desiredCapacity elements
      boolean equals​(Object obj)  
      long evaluate​(long point)
      Evaluates this poly at a given point (via Horner method).
      long evaluateAtRational​(long num, long den)
      Evaluates this poly at a given rational point num/den
      int firstNonZeroCoefficientPosition()
      Returns position of the first non-zero coefficient, that is common monomial exponent (e.g.
      long get​(int i)
      Returns the i-th coefficient of this poly (coefficient before x^i)
      lPoly getAsPoly​(int i)
      Returns i-th coefficient of this as a constant polynomial
      long[] getDataReferenceUnsafe()
      internal API >>> direct unsafe access to internal storage
      UnivariatePolynomialZ64 getRange​(int from, int to)
      Creates polynomial formed from the coefficients of this starting from from (inclusive) to to (exclusive)
      int hashCode()  
      lPoly increment()
      Adds 1 to this
      boolean isConstant()
      Returns true if this polynomial has only constant term
      boolean isMonic()
      Returns true if this polynomial is monic
      boolean isMonomial()
      Returns true if this polynomial has only one monomial term
      boolean isOne()
      Returns true if this is one
      boolean isOverField()
      Returns whether the coefficient ring of this polynomial is a field
      boolean isOverFiniteField()
      Returns whether the coefficient ring of this polynomial is a finite field
      boolean isOverPerfectPower()
      Returns whether the coefficientRingCardinality() is a perfect power
      boolean isOverZ()
      Returns whether the coefficient ring of this polynomial is Z
      boolean isUnitCC()
      Returns true if constant term is equal to one
      boolean isZero()
      Returns true if this is zero
      boolean isZeroAt​(int i)
      Returns whether i-th coefficient of this is zero
      long lc()
      Returns the leading coefficient of this poly
      lPoly lcAsPoly()
      Returns the leading coefficient as a constant poly
      <T> UnivariatePolynomial<T> mapCoefficients​(Ring<T> ring, LongFunction<T> mapper)
      Applies transformation function to this and returns the result.
      long maxAbsCoefficient()
      Returns max coefficient (by absolute value) of this poly
      double mignotteBound()
      Returns Mignotte's bound (sqrt(n+1) * 2^n max |this|)
      UnivariatePolynomialZp64 modulus​(long modulus)
      Reduces (copied) polynomial modulo modulus and returns the result.
      UnivariatePolynomialZp64 modulus​(long modulus, boolean copy)
      Reduces this polynomial modulo modulus and returns the result.
      UnivariatePolynomialZp64 modulus​(IntegersZp64 ring)
      Reduces (copied) polynomial modulo modulus and returns the result.
      UnivariatePolynomialZp64 modulus​(IntegersZp64 ring, boolean copy)
      Reduces this polynomial modulo modulus and returns the result.
      UnivariatePolynomialZ64 monic()
      Sets this to its monic part (that is this divided by its leading coefficient), or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the lc().
      UnivariatePolynomialZ64 monic​(long factor)
      Sets this to its monic part multiplied by the factor;
      lPoly monicWithLC​(lPoly other)
      Sets this to its monic part multiplied by the leading coefficient of other;
      static UnivariatePolynomialZ64 monomial​(long coefficient, int exponent)
      Creates monomial coefficient * x^exponent
      lPoly multiply​(long factor)
      Multiplies this by factor
      UnivariatePolynomialZ64 multiply​(UnivariatePolynomialZ64 oth)
      Multiplies this by oth
      UnivariatePolynomialZ64 multiplyByBigInteger​(BigInteger factor)
      Multiplies this by factor
      lPoly multiplyByLC​(lPoly other)
      Multiply this by the leading coefficient of other
      lPoly negate()
      Negates this and returns
      double norm1()
      Returns L1 norm of this polynomial, i.e.
      double norm2()
      Returns L2 norm of this polynomial, i.e.
      double normMax()
      Returns max coefficient (by absolute value) of this poly
      static UnivariatePolynomialZ64 one()
      Creates unit polynomial
      static UnivariatePolynomialZ64 parse​(String string)
      Parse string into polynomial
      UnivariatePolynomialZ64 parsePoly​(String string)  
      lPoly primitivePart()
      Reduces poly to its primitive part (primitive part will always have positive l.c.)
      lPoly primitivePartSameSign()
      Reduces poly to its primitive part, so that primitive part will have the same signum as the initial poly
      lPoly reverse()
      Reverses the coefficients of this
      boolean sameCoefficientRingWith​(UnivariatePolynomialZ64 oth)
      Returns whether oth and this have the same coefficient ring
      lPoly set​(int i, long el)
      Sets i-th element of this poly with the specified value
      lPoly set​(lPoly oth)
      Sets the content of this to oth
      lPoly setAndDestroy​(lPoly oth)
      Sets the content of this with oth and destroys oth
      UnivariatePolynomialZ64 setCoefficientRingFrom​(UnivariatePolynomialZ64 univariatePolynomialZ64)
      Set the coefficient ring from specified poly
      lPoly setFrom​(int indexInThis, lPoly poly, int indexInPoly)
      Sets i-th element of this by j-th element of other poly
      lPoly setLC​(long lc)
      Sets hte leading coefficient of this poly with specified value
      lPoly setZero​(int i)
      Fills i-th element with zero
      lPoly shift​(long value)
      Shifts variable x -> x + value and returns the result (new instance)
      lPoly shiftLeft​(int offset)
      Returns the quotient this / x^offset, it is polynomial with coefficient list formed by shifting coefficients of this to the left by offset.
      lPoly shiftRight​(int offset)
      Multiplies this by the x^offset.
      int signumOfLC()
      Gives signum of the leading coefficient
      UnivariatePolynomialZ64 square()
      Squares this
      LongStream stream()
      Returns a sequential Stream with coefficients of this as its source.
      Stream<lPoly> streamAsPolys()
      Stream polynomial coefficients as constant polynomials
      lPoly subtract​(long val)
      Subtract constant from this.
      lPoly subtract​(lPoly oth)
      Subtracts oth from this.
      lPoly subtract​(lPoly oth, long factor, int exponent)
      Subtracts factor * x^exponent * oth from this
      UnivariatePolynomial<BigInteger> toBigPoly()
      Converts this to a polynomial over BigIntegers
      String toString()  
      String toString​(IStringifier<lPoly> stringifier)
      convert this to string with the use of stringifier
      String toStringForCopy()  
      lPoly toZero()
      Sets this to zero
      lPoly truncate​(int newDegree)
      Returns the remainder this rem x^(newDegree + 1), it is polynomial formed by coefficients of this from zero to newDegree (both inclusive)
      static UnivariatePolynomialZ64 zero()
      Creates zero polynomial
    • Method Detail

      • create

        public static UnivariatePolynomialZ64 create​(long... data)
        Creates Z[x] polynomial from the specified coefficients
        Parameters:
        data - coefficients
        Returns:
        Z[x] polynomial
      • monomial

        public static UnivariatePolynomialZ64 monomial​(long coefficient,
                                                       int exponent)
        Creates monomial coefficient * x^exponent
        Parameters:
        coefficient - monomial coefficient
        exponent - monomial exponent
        Returns:
        coefficient * x^exponent
      • constant

        public static UnivariatePolynomialZ64 constant​(long value)
        Returns constant with specified value
        Returns:
        constant with specified value
      • setCoefficientRingFrom

        public UnivariatePolynomialZ64 setCoefficientRingFrom​(UnivariatePolynomialZ64 univariatePolynomialZ64)
        Description copied from interface: IPolynomial
        Set the coefficient ring from specified poly
        Parameters:
        univariatePolynomialZ64 - the polynomial
        Returns:
        a copy of this with the coefficient ring taken from poly
      • modulus

        public UnivariatePolynomialZp64 modulus​(long modulus,
                                                boolean copy)
        Reduces this polynomial modulo modulus and returns the result.
        Parameters:
        modulus - the modulus
        copy - whether to copy the internal data or reduce inplace (in which case the data of this will be lost)
        Returns:
        this modulo modulus
      • modulus

        public UnivariatePolynomialZp64 modulus​(long modulus)
        Reduces (copied) polynomial modulo modulus and returns the result.
        Parameters:
        modulus - the modulus
        Returns:
        a copy of this modulo modulus
      • modulus

        public UnivariatePolynomialZp64 modulus​(IntegersZp64 ring,
                                                boolean copy)
        Reduces this polynomial modulo modulus and returns the result.
        Parameters:
        ring - the modulus
        copy - whether to copy the internal data or reduce inplace (in which case the data of this will be lost)
        Returns:
        this modulo modulus
      • modulus

        public UnivariatePolynomialZp64 modulus​(IntegersZp64 ring)
        Reduces (copied) polynomial modulo modulus and returns the result.
        Parameters:
        ring - the modulus
        Returns:
        a copy of this modulo modulus
      • mignotteBound

        public double mignotteBound()
        Returns Mignotte's bound (sqrt(n+1) * 2^n max |this|)
        Returns:
        Mignotte's bound
      • evaluateAtRational

        public long evaluateAtRational​(long num,
                                       long den)
        Evaluates this poly at a given rational point num/den
        Parameters:
        num - point numerator
        den - point denominator
        Returns:
        value at num/den
        Throws:
        ArithmeticException - if the result is not integer
      • getRange

        public UnivariatePolynomialZ64 getRange​(int from,
                                                int to)
        Description copied from interface: IUnivariatePolynomial
        Creates polynomial formed from the coefficients of this starting from from (inclusive) to to (exclusive)
        Parameters:
        from - the initial index of the range to be copied, inclusive
        to - the final index of the range to be copied, exclusive.
        Returns:
        polynomial formed from the range of coefficients of this
      • createArray2d

        public UnivariatePolynomialZ64[][] createArray2d​(int length1,
                                                         int length2)
        Description copied from interface: IPolynomial
        overcome Java generics...
      • sameCoefficientRingWith

        public boolean sameCoefficientRingWith​(UnivariatePolynomialZ64 oth)
        Description copied from interface: IPolynomial
        Returns whether oth and this have the same coefficient ring
        Parameters:
        oth - other polynomial
        Returns:
        whether this and oth are over the same coefficient ring
      • createFromArray

        public UnivariatePolynomialZ64 createFromArray​(long[] data)
        Creates new poly with the specified coefficients (over the same ring)
        Parameters:
        data - the data
        Returns:
        polynomial
      • createMonomial

        public UnivariatePolynomialZ64 createMonomial​(long coefficient,
                                                      int degree)
        Creates monomial coefficient * x^degree (with the same coefficient ring)
        Parameters:
        coefficient - monomial coefficient
        degree - monomial degree
        Returns:
        coefficient * x^degree
      • isOverField

        public boolean isOverField()
        Description copied from interface: IPolynomial
        Returns whether the coefficient ring of this polynomial is a field
        Returns:
        whether the coefficient ring of this polynomial is a field
      • isOverFiniteField

        public boolean isOverFiniteField()
        Description copied from interface: IPolynomial
        Returns whether the coefficient ring of this polynomial is a finite field
        Returns:
        whether the coefficient ring of this polynomial is a finite field
      • isOverZ

        public boolean isOverZ()
        Description copied from interface: IPolynomial
        Returns whether the coefficient ring of this polynomial is Z
        Returns:
        whether the coefficient ring of this polynomial is Z
      • coefficientRingCardinality

        public BigInteger coefficientRingCardinality()
        Description copied from interface: IPolynomial
        Returns cardinality of the coefficient ring of this poly
        Returns:
        cardinality of the coefficient ring
      • coefficientRingCharacteristic

        public BigInteger coefficientRingCharacteristic()
        Description copied from interface: IPolynomial
        Returns characteristic of the coefficient ring of this poly
        Returns:
        characteristic of the coefficient ring
      • isOverPerfectPower

        public boolean isOverPerfectPower()
        Description copied from interface: IPolynomial
        Returns whether the coefficientRingCardinality() is a perfect power
        Returns:
        whether the coefficientRingCardinality() is a perfect power
      • coefficientRingPerfectPowerBase

        public BigInteger coefficientRingPerfectPowerBase()
        Description copied from interface: IPolynomial
        Returns base so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
        Returns:
        base so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
      • coefficientRingPerfectPowerExponent

        public BigInteger coefficientRingPerfectPowerExponent()
        Description copied from interface: IPolynomial
        Returns exponent so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
        Returns:
        exponent so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
      • content

        public long content()
        Returns the content of this poly (gcd of its coefficients)
        Returns:
        polynomial content
      • monic

        public UnivariatePolynomialZ64 monic()
        Description copied from interface: IPolynomial
        Sets this to its monic part (that is this divided by its leading coefficient), or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the lc(). NOTE: if null is returned, the content of this is destroyed.
        Returns:
        monic this or null
      • monic

        public UnivariatePolynomialZ64 monic​(long factor)
        Sets this to its monic part multiplied by the factor;
        Parameters:
        factor - the factor
        Returns:
        this
      • divideOrNull

        public UnivariatePolynomialZ64 divideOrNull​(long factor)
        Divides this polynomial by a factor or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the factor. NOTE: is null is returned, the content of this is destroyed.
        Parameters:
        factor - the factor
        Returns:
        this divided by the factor or null
      • divideByLC

        public UnivariatePolynomialZ64 divideByLC​(UnivariatePolynomialZ64 other)
        Description copied from interface: IPolynomial
        Divides this polynomial by the leading coefficient of other or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the other.lc(). NOTE: if null is returned, the content of this is destroyed.
        Parameters:
        other - the polynomial
        Returns:
        this divided by the other.lc() or null if exact division is not possible
      • multiplyByBigInteger

        public UnivariatePolynomialZ64 multiplyByBigInteger​(BigInteger factor)
        Description copied from interface: IPolynomial
        Multiplies this by factor
        Parameters:
        factor - the factor
        Returns:
        this * factor
      • derivative

        public UnivariatePolynomialZ64 derivative()
        Description copied from interface: IUnivariatePolynomial
        Returns the formal derivative of this poly (new instance, so the content of this is not changed)
        Returns:
        the formal derivative
      • degree

        public final int degree()
        Description copied from interface: IPolynomial
        Returns the degree of this polynomial
        Specified by:
        degree in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        the degree
      • get

        public final long get​(int i)
        Returns the i-th coefficient of this poly (coefficient before x^i)
      • set

        public final lPoly set​(int i,
                               long el)
        Sets i-th element of this poly with the specified value
      • setLC

        public final lPoly setLC​(long lc)
        Sets hte leading coefficient of this poly with specified value
      • firstNonZeroCoefficientPosition

        public final int firstNonZeroCoefficientPosition()
        Description copied from interface: IUnivariatePolynomial
        Returns position of the first non-zero coefficient, that is common monomial exponent (e.g. 2 for x^2 + x^3 + ...). In the case of zero polynomial, -1 returned
        Specified by:
        firstNonZeroCoefficientPosition in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        position of the first non-zero coefficient or -1 if this is zero
      • lc

        public final long lc()
        Returns the leading coefficient of this poly
        Returns:
        leading coefficient
      • lcAsPoly

        public final lPoly lcAsPoly()
        Description copied from interface: IPolynomial
        Returns the leading coefficient as a constant poly
        Specified by:
        lcAsPoly in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
      • ccAsPoly

        public final lPoly ccAsPoly()
        Description copied from interface: IPolynomial
        Returns the constant coefficient as a constant poly
        Specified by:
        ccAsPoly in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
      • getAsPoly

        public lPoly getAsPoly​(int i)
        Description copied from interface: IUnivariatePolynomial
        Returns i-th coefficient of this as a constant polynomial
        Specified by:
        getAsPoly in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        i - index in this
        Returns:
        i-th coefficient of this as a constant polynomial
      • cc

        public final long cc()
        Returns the constant coefficient of this poly
        Returns:
        constant coefficient
      • ensureInternalCapacity

        public final void ensureInternalCapacity​(int desiredCapacity)
        Description copied from interface: IUnivariatePolynomial
        ensures that internal storage has enough size to store desiredCapacity elements
        Specified by:
        ensureInternalCapacity in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
      • createMonomial

        public final lPoly createMonomial​(int degree)
        Description copied from interface: IUnivariatePolynomial
        Creates new monomial x^degree (with the same coefficient ring)
        Specified by:
        createMonomial in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        degree - monomial degree
        Returns:
        new monomial coefficient * x^degree
      • createLinear

        public final lPoly createLinear​(long cc,
                                        long lc)
        Creates linear polynomial of form cc + x * lc (with the same coefficient ring)
        Parameters:
        cc - the constant coefficient
        lc - the leading coefficient
        Returns:
        cc + x * lc
      • createConstant

        public final lPoly createConstant​(long val)
        Creates constant polynomial with specified value (with the same coefficient ring)
        Specified by:
        createConstant in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        val - the value
        Returns:
        constant polynomial with specified value
      • createZero

        public final lPoly createZero()
        Description copied from interface: IPolynomial
        Returns the new instance of zero polynomial (with the same coefficient ring)
        Specified by:
        createZero in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        new instance of 0
      • createOne

        public final lPoly createOne()
        Description copied from interface: IPolynomial
        Returns the new instance of unit polynomial (with the same coefficient ring)
        Specified by:
        createOne in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        new instance of 1
      • isZeroAt

        public final boolean isZeroAt​(int i)
        Description copied from interface: IUnivariatePolynomial
        Returns whether i-th coefficient of this is zero
        Specified by:
        isZeroAt in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        i - the position
        Returns:
        whether i-th coefficient of this is zero
      • setZero

        public final lPoly setZero​(int i)
        Description copied from interface: IUnivariatePolynomial
        Fills i-th element with zero
        Specified by:
        setZero in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        i - position
        Returns:
        self
      • setFrom

        public final lPoly setFrom​(int indexInThis,
                                   lPoly poly,
                                   int indexInPoly)
        Description copied from interface: IUnivariatePolynomial
        Sets i-th element of this by j-th element of other poly
        Specified by:
        setFrom in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        indexInThis - index in self
        poly - other polynomial
        indexInPoly - index in other polynomial
        Returns:
        self
      • isZero

        public final boolean isZero()
        Description copied from interface: IPolynomial
        Returns true if this is zero
        Specified by:
        isZero in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        whether this is zero
      • isOne

        public final boolean isOne()
        Description copied from interface: IPolynomial
        Returns true if this is one
        Specified by:
        isOne in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        whether this is one
      • isMonic

        public final boolean isMonic()
        Description copied from interface: IPolynomial
        Returns true if this polynomial is monic
        Specified by:
        isMonic in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        whether this is monic
      • isUnitCC

        public final boolean isUnitCC()
        Description copied from interface: IPolynomial
        Returns true if constant term is equal to one
        Specified by:
        isUnitCC in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        whether constant term is 1
      • isConstant

        public final boolean isConstant()
        Description copied from interface: IPolynomial
        Returns true if this polynomial has only constant term
        Specified by:
        isConstant in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        whether this is constant
      • isMonomial

        public final boolean isMonomial()
        Description copied from interface: IPolynomial
        Returns true if this polynomial has only one monomial term
        Specified by:
        isMonomial in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        whether this has only one monomial term
      • signumOfLC

        public final int signumOfLC()
        Description copied from interface: IPolynomial
        Gives signum of the leading coefficient
        Specified by:
        signumOfLC in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        signum of the leading coefficient
      • norm1

        public final double norm1()
        Returns L1 norm of this polynomial, i.e. sum of abs coefficients
        Returns:
        L1 norm of this
      • norm2

        public final double norm2()
        Returns L2 norm of this polynomial, i.e. a square root of a sum of coefficient squares.
        Returns:
        L2 norm of this
      • normMax

        public final double normMax()
        Returns max coefficient (by absolute value) of this poly
        Returns:
        max coefficient (by absolute value)
      • maxAbsCoefficient

        public final long maxAbsCoefficient()
        Returns max coefficient (by absolute value) of this poly
        Returns:
        max coefficient (by absolute value)
      • toZero

        public final lPoly toZero()
        Description copied from interface: IPolynomial
        Sets this to zero
        Specified by:
        toZero in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        this := zero
      • set

        public final lPoly set​(lPoly oth)
        Description copied from interface: IPolynomial
        Sets the content of this to oth
        Specified by:
        set in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        oth - the polynomial
        Returns:
        this := oth
      • setAndDestroy

        public final lPoly setAndDestroy​(lPoly oth)
        Description copied from interface: IUnivariatePolynomial
        Sets the content of this with oth and destroys oth
        Specified by:
        setAndDestroy in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        oth - the polynomial (will be destroyed)
        Returns:
        this := oth
      • shiftLeft

        public final lPoly shiftLeft​(int offset)
        Description copied from interface: IUnivariatePolynomial
        Returns the quotient this / x^offset, it is polynomial with coefficient list formed by shifting coefficients of this to the left by offset.
        Specified by:
        shiftLeft in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        offset - shift amount
        Returns:
        the quotient this / x^offset
      • shiftRight

        public final lPoly shiftRight​(int offset)
        Description copied from interface: IUnivariatePolynomial
        Multiplies this by the x^offset.
        Specified by:
        shiftRight in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        offset - monomial exponent
        Returns:
        this * x^offset
      • truncate

        public final lPoly truncate​(int newDegree)
        Description copied from interface: IUnivariatePolynomial
        Returns the remainder this rem x^(newDegree + 1), it is polynomial formed by coefficients of this from zero to newDegree (both inclusive)
        Specified by:
        truncate in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        newDegree - new degree
        Returns:
        remainder this rem x^(newDegree + 1)
      • reverse

        public final lPoly reverse()
        Description copied from interface: IUnivariatePolynomial
        Reverses the coefficients of this
        Specified by:
        reverse in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        reversed polynomial
      • contentAsPoly

        public final lPoly contentAsPoly()
        Description copied from interface: IPolynomial
        Returns the content of this (gcd of coefficients) as a constant poly
        Specified by:
        contentAsPoly in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
      • primitivePart

        public final lPoly primitivePart()
        Description copied from interface: IPolynomial
        Reduces poly to its primitive part (primitive part will always have positive l.c.)
        Specified by:
        primitivePart in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        primitive part (poly will be modified)
      • primitivePartSameSign

        public final lPoly primitivePartSameSign()
        Description copied from interface: IPolynomial
        Reduces poly to its primitive part, so that primitive part will have the same signum as the initial poly
        Specified by:
        primitivePartSameSign in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        primitive part (poly will be modified)
      • evaluate

        public final long evaluate​(long point)
        Evaluates this poly at a given point (via Horner method).
        Parameters:
        point - point
        Returns:
        value at point
      • composition

        public final lPoly composition​(lPoly value)
        Description copied from interface: IUnivariatePolynomial
        Calculates the composition of this(oth) (new instance, so the content of this is not changed))
        Specified by:
        composition in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        value - polynomial
        Returns:
        composition this(oth)
      • shift

        public final lPoly shift​(long value)
        Shifts variable x -> x + value and returns the result (new instance)
        Parameters:
        value - shift amount
        Returns:
        a copy of this with x -> x + value
      • monicWithLC

        public lPoly monicWithLC​(lPoly other)
        Description copied from interface: IPolynomial
        Sets this to its monic part multiplied by the leading coefficient of other;
        Specified by:
        monicWithLC in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        other - other polynomial
        Returns:
        monic part multiplied by the leading coefficient of other or null if exact division by the reduced leading coefficient is not possible
      • add

        public final lPoly add​(long val)
        Add constant to this.
        Parameters:
        val - some number
        Returns:
        this + val
      • subtract

        public final lPoly subtract​(long val)
        Subtract constant from this.
        Parameters:
        val - some number
        Returns:
        this + val
      • decrement

        public final lPoly decrement()
        Description copied from interface: IPolynomial
        Subtracts 1 from this
        Specified by:
        decrement in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        this - 1
      • increment

        public final lPoly increment()
        Description copied from interface: IPolynomial
        Adds 1 to this
        Specified by:
        increment in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        this + 1
      • add

        public final lPoly add​(lPoly oth)
        Description copied from interface: IPolynomial
        Adds oth to this.
        Specified by:
        add in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        oth - the polynomial
        Returns:
        this + oth
      • addMonomial

        public final lPoly addMonomial​(long coefficient,
                                       int exponent)
        Adds coefficient*x^exponent to this
        Parameters:
        coefficient - monomial coefficient
        exponent - monomial exponent
        Returns:
        this + coefficient*x^exponent
      • addMul

        public final lPoly addMul​(lPoly oth,
                                  long factor)
        Adds oth * factor to this
        Parameters:
        oth - the polynomial
        factor - the factor
        Returns:
        this + oth * factor modulo modulus
      • subtract

        public final lPoly subtract​(lPoly oth)
        Description copied from interface: IPolynomial
        Subtracts oth from this.
        Specified by:
        subtract in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        oth - the polynomial
        Returns:
        this - oth
      • subtract

        public final lPoly subtract​(lPoly oth,
                                    long factor,
                                    int exponent)
        Subtracts factor * x^exponent * oth from this
        Parameters:
        oth - the polynomial
        factor - the factor
        exponent - the exponent
        Returns:
        this - factor * x^exponent * oth
      • negate

        public final lPoly negate()
        Description copied from interface: IPolynomial
        Negates this and returns
        Specified by:
        negate in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Returns:
        this negated
      • multiplyByLC

        public lPoly multiplyByLC​(lPoly other)
        Description copied from interface: IPolynomial
        Multiply this by the leading coefficient of other
        Specified by:
        multiplyByLC in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        other - polynomial
        Returns:
        this * lc(other)
      • multiply

        public final lPoly multiply​(long factor)
        Description copied from interface: IPolynomial
        Multiplies this by factor
        Specified by:
        multiply in interface IPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
        Parameters:
        factor - the factor
        Returns:
        this * factor
      • getDataReferenceUnsafe

        public final long[] getDataReferenceUnsafe()
        internal API >>> direct unsafe access to internal storage
      • compareTo

        public final int compareTo​(lPoly o)
        Specified by:
        compareTo in interface Comparable<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
      • toString

        public String toString​(IStringifier<lPoly> stringifier)
        Description copied from interface: Stringifiable
        convert this to string with the use of stringifier
        Specified by:
        toString in interface Stringifiable<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
      • toStringForCopy

        public String toStringForCopy()
      • streamAsPolys

        public Stream<lPoly> streamAsPolys()
        Description copied from interface: IUnivariatePolynomial
        Stream polynomial coefficients as constant polynomials
        Specified by:
        streamAsPolys in interface IUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
      • stream

        public final LongStream stream()
        Returns a sequential Stream with coefficients of this as its source.
        Returns:
        a sequential Stream over the coefficients in this polynomial
      • mapCoefficients

        public final <T> UnivariatePolynomial<T> mapCoefficients​(Ring<T> ring,
                                                                 LongFunction<T> mapper)
        Applies transformation function to this and returns the result. This method is equivalent of stream().mapToObj(mapper).collect(new PolynomialCollector<>(ring)).
        Type Parameters:
        T - result elements type
        Parameters:
        ring - ring of the new polynomial
        mapper - function that maps coefficients of this to coefficients of the result
        Returns:
        a new polynomial with the coefficients obtained from this by applying mapper
      • equals

        public final boolean equals​(Object obj)
        Overrides:
        equals in class Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object