Package cc.redberry.rings.poly.univar
Class UnivariatePolynomialZp64
java.lang.Object
cc.redberry.rings.poly.univar.UnivariatePolynomialZp64
- All Implemented Interfaces:
Stringifiable<UnivariatePolynomialZp64>
,IPolynomial<UnivariatePolynomialZp64>
,IUnivariatePolynomial<UnivariatePolynomialZp64>
,Serializable
,Comparable<UnivariatePolynomialZp64>
public final class UnivariatePolynomialZp64 extends Object
Univariate polynomial over Zp ring with modulus in the range of
[2, 2^62)
(the last value is specified by
MachineArithmetic.MAX_SUPPORTED_MODULUS_BITS
. Fast methods from IntegersZp64
are used to perform all
arithmetic operations.- Since:
- 1.0
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description IntegersZp64
ring
The coefficient ring -
Method Summary
Modifier and Type Method Description UnivariatePolynomialZp64
add(long val)
Add constant to this.UnivariatePolynomialZp64
add(UnivariatePolynomialZp64 oth)
Addsoth
tothis
.UnivariatePolynomialZp64
addMonomial(long coefficient, int exponent)
Addscoefficient*x^exponent
tothis
UnivariatePolynomialZp64
addMul(UnivariatePolynomialZp64 oth, long factor)
Addsoth * factor
tothis
MultivariatePolynomialZp64
asMultivariate()
Convert to multivariate polynomialMultivariatePolynomialZp64
asMultivariate(Comparator<DegreeVector> ordering)
Convert to multivariate polynomialUnivariatePolynomialZ64
asPolyZ(boolean copy)
Returns Z[x] polynomial formed from the coefficients of this.UnivariatePolynomialZ64
asPolyZSymmetric()
Returns Z[x] polynomial formed from the coefficients of this represented in symmetric modular form (-modulus/2 <= cfx <= modulus/2
).long
cc()
Returns the constant coefficient of this polyUnivariatePolynomialZp64
ccAsPoly()
Returns the constant coefficient as a constant polyUnivariatePolynomialZp64
clone()
Deep copy of thisBigInteger
coefficientRingCardinality()
Returns cardinality of the coefficient ring of this polyBigInteger
coefficientRingCharacteristic()
Returns characteristic of the coefficient ring of this polyBigInteger
coefficientRingPerfectPowerBase()
Returnsbase
so thatcoefficientRingCardinality() == base^exponent
or null if cardinality is not finiteBigInteger
coefficientRingPerfectPowerExponent()
Returnsexponent
so thatcoefficientRingCardinality() == base^exponent
or null if cardinality is not finiteString
coefficientRingToString(IStringifier<UnivariatePolynomialZp64> stringifier)
String representation of the coefficient ring of thisint
compareTo(UnivariatePolynomialZp64 o)
MultivariatePolynomialZp64
composition(AMultivariatePolynomial value)
Calculates the composition of this(oth)UnivariatePolynomialZp64
composition(UnivariatePolynomialZp64 value)
Calculates the composition of this(oth) (new instance, so the content of this is not changed))static UnivariatePolynomialZp64
constant(long modulus, long value)
Creates constant polynomial with specified valuestatic UnivariatePolynomialZp64
constant(IntegersZp64 ring, long value)
Creates constant polynomial with specified valuelong
content()
Returns the content of this poly (gcd of its coefficients)UnivariatePolynomialZp64
contentAsPoly()
Returns the content of this (gcd of coefficients) as a constant polystatic UnivariatePolynomialZp64
create(long modulus, long[] data)
Creates poly with specified coefficients represented as signed integers reducing them modulomodulus
static UnivariatePolynomialZp64
create(IntegersZp64 ring, long[] data)
Creates poly with specified coefficients represented as signed integers reducing them modulomodulus
UnivariatePolynomialZp64[]
createArray(int length)
overcome Java generics...UnivariatePolynomialZp64[]
createArray(UnivariatePolynomialZp64 a, UnivariatePolynomialZp64 b)
overcome Java generics...UnivariatePolynomialZp64[][]
createArray2d(int length)
overcome Java generics...UnivariatePolynomialZp64[][]
createArray2d(int length1, int length2)
overcome Java generics...UnivariatePolynomialZp64
createConstant(long val)
Creates constant polynomial with specified value (with the same coefficient ring)UnivariatePolynomialZp64
createFromArray(long[] newData)
Creates new poly with the specified coefficients (over the same ring)UnivariatePolynomialZp64
createLinear(long cc, long lc)
Creates linear polynomial of formcc + x * lc
(with the same coefficient ring)UnivariatePolynomialZp64
createMonomial(int degree)
Creates new monomialx^degree
(with the same coefficient ring)UnivariatePolynomialZp64
createMonomial(long coefficient, int newDegree)
Creates monomialcoefficient * x^degree
(with the same coefficient ring)UnivariatePolynomialZp64
createOne()
Returns the new instance of unit polynomial (with the same coefficient ring)static UnivariatePolynomialZp64
createUnsafe(long modulus, long[] data)
data is not reduced modulo modulusstatic UnivariatePolynomialZp64
createUnsafe(IntegersZp64 ring, long[] data)
data is not reduced modulo modulusUnivariatePolynomialZp64
createZero()
Returns the new instance of zero polynomial (with the same coefficient ring)UnivariatePolynomialZp64
decrement()
Subtracts 1 from thisint
degree()
Returns the degree of this polynomialUnivariatePolynomialZp64
derivative()
Returns the formal derivative of this poly (new instance, so the content of this is not changed)UnivariatePolynomialZp64
divide(long val)
Divide by specified valueUnivariatePolynomialZp64
divideByLC(UnivariatePolynomialZp64 other)
Divides this polynomial by the leading coefficient ofother
or returnsnull
(causing loss of internal data) if some of the elements can't be exactly divided by theother.lc()
.void
ensureInternalCapacity(int desiredCapacity)
ensures that internal storage has enough size to storedesiredCapacity
elementsboolean
equals(Object obj)
long
evaluate(long point)
Evaluates this poly at a givenpoint
(via Horner method).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)UnivariatePolynomialZp64
getAsPoly(int i)
Returns i-th coefficient of this as a constant polynomiallong[]
getDataReferenceUnsafe()
internal API >>> direct unsafe access to internal storageUnivariatePolynomialZp64
getRange(int from, int to)
Creates polynomial formed from the coefficients of this starting fromfrom
(inclusive) toto
(exclusive)int
hashCode()
UnivariatePolynomialZp64
increment()
Adds 1 to thisboolean
isConstant()
Returnstrue
if this polynomial has only constant termboolean
isMonic()
Returnstrue
if this polynomial is monicboolean
isMonomial()
Returnstrue
if this polynomial has only one monomial termboolean
isOne()
Returnstrue
if this is oneboolean
isOverField()
Returns whether the coefficient ring of this polynomial is a fieldboolean
isOverFiniteField()
Returns whether the coefficient ring of this polynomial is a finite fieldboolean
isOverPerfectPower()
Returns whether thecoefficientRingCardinality()
is a perfect powerboolean
isOverZ()
Returns whether the coefficient ring of this polynomial is Zboolean
isUnitCC()
Returns true if constant term is equal to oneboolean
isZero()
Returnstrue
if this is zeroboolean
isZeroAt(int i)
Returns whether i-th coefficient of this is zerolong
lc()
Returns the leading coefficient of this polyUnivariatePolynomialZp64
lcAsPoly()
Returns the leading coefficient as a constant polystatic UnivariatePolynomialZp64
linear(long cc, long lc, long modulus)
Creates linear polynomial of formcc + x * lc
<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 polylong
modulus()
Returns the modulusUnivariatePolynomialZp64
monic()
Setsthis
to its monic part (that isthis
divided by its leading coefficient), or returnsnull
(causing loss of internal data) if some of the elements can't be exactly divided by thelc()
.UnivariatePolynomialZp64
monic(long factor)
Setsthis
to its monic part multiplied by thefactor
(that ismonic(modulus).multiply(factor)
).UnivariatePolynomialZp64
monicWithLC(UnivariatePolynomialZp64 other)
Setsthis
to its monic part multiplied by the leading coefficient ofother
;static UnivariatePolynomialZp64
monomial(long modulus, long coefficient, int exponent)
Creates monomialcoefficient * x^exponent
UnivariatePolynomialZp64
multiply(long factor)
Multiplies this byfactor
UnivariatePolynomialZp64
multiply(UnivariatePolynomialZp64 oth)
Multiplies this byoth
UnivariatePolynomialZp64
multiplyByBigInteger(BigInteger factor)
Multiplies this byfactor
UnivariatePolynomialZp64
multiplyByLC(UnivariatePolynomialZp64 other)
Multiply this by the leading coefficient ofother
UnivariatePolynomialZp64
negate()
Negates this and returnsdouble
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 polystatic UnivariatePolynomialZp64
one(long modulus)
Creates unit polynomialstatic UnivariatePolynomialZp64
one(IntegersZp64 ring)
Creates unit polynomialstatic UnivariatePolynomialZp64
parse(String string, long modulus)
Deprecated.static UnivariatePolynomialZp64
parse(String string, IntegersZp64 modulus)
Deprecated.static UnivariatePolynomialZp64
parse(String string, IntegersZp64 modulus, String variable)
Parse string into polynomialUnivariatePolynomialZp64
parsePoly(String string)
UnivariatePolynomialZp64
primitivePart()
Reduces poly to its primitive part (primitive part will always have positive l.c.)UnivariatePolynomialZp64
primitivePartSameSign()
Reduces poly to its primitive part, so that primitive part will have the same signum as the initial polyUnivariatePolynomialZp64
reverse()
Reverses the coefficients of thisboolean
sameCoefficientRingWith(UnivariatePolynomialZp64 oth)
Returns whetheroth
andthis
have the same coefficient ringUnivariatePolynomialZp64
set(int i, long el)
Sets i-th element of this poly with the specified valueUnivariatePolynomialZp64
set(UnivariatePolynomialZp64 oth)
Sets the content of this tooth
UnivariatePolynomialZp64
setAndDestroy(UnivariatePolynomialZp64 oth)
Sets the content of this withoth
and destroys othUnivariatePolynomialZp64
setCoefficientRingFrom(UnivariatePolynomialZp64 univariatePolynomialZp64)
Set the coefficient ring from specified polyUnivariatePolynomialZp64
setFrom(int indexInThis, UnivariatePolynomialZp64 poly, int indexInPoly)
Sets i-th element of this by j-th element of other polyUnivariatePolynomialZp64
setLC(long lc)
Sets hte leading coefficient of this poly with specified valueUnivariatePolynomialZp64
setModulus(long newModulus)
Creates new Zp[x] polynomial by coping the coefficients of this and reducing them modulo new modulus.UnivariatePolynomialZp64
setModulus(IntegersZp64 newDomain)
Creates new Zp[x] polynomial by coping the coefficients of this and reducing them modulo new modulus.UnivariatePolynomialZp64
setModulusUnsafe(long newModulus)
does not copy the data and does not reduce the data with new modulusUnivariatePolynomialZp64
setModulusUnsafe(IntegersZp64 newModulus)
does not copy the data and does not reduce the data with new modulusUnivariatePolynomialZp64
setZero(int i)
Fills i-th element with zeroUnivariatePolynomialZp64
shift(long value)
Shifts variable x -> x + value and returns the result (new instance)UnivariatePolynomialZp64
shiftLeft(int offset)
Returns the quotientthis / x^offset
, it is polynomial with coefficient list formed by shifting coefficients ofthis
to the left byoffset
.UnivariatePolynomialZp64
shiftRight(int offset)
Multipliesthis
by thex^offset
.int
signumOfLC()
Gives signum of the leading coefficientUnivariatePolynomialZp64
square()
Squaresthis
LongStream
stream()
Returns a sequentialStream
with coefficients of this as its source.Stream<UnivariatePolynomialZp64>
streamAsPolys()
Stream polynomial coefficients as constant polynomialsUnivariatePolynomialZp64
subtract(long val)
Subtract constant from this.UnivariatePolynomialZp64
subtract(UnivariatePolynomialZp64 oth)
Subtractsoth
fromthis
.UnivariatePolynomialZp64
subtract(UnivariatePolynomialZp64 oth, long factor, int exponent)
Subtractsfactor * x^exponent * oth
fromthis
UnivariatePolynomial<BigInteger>
toBigPoly()
Converts this to a polynomial over BigIntegersString
toString()
String
toString(IStringifier<UnivariatePolynomialZp64> stringifier)
convert this to string with the use of stringifierString
toStringForCopy()
UnivariatePolynomialZp64
toZero()
Sets this to zeroUnivariatePolynomialZp64
truncate(int newDegree)
Returns the remainderthis rem x^(newDegree + 1)
, it is polynomial formed by coefficients of this from zero tonewDegree
(both inclusive)static UnivariatePolynomialZp64
zero(long modulus)
Creates zero polynomialstatic UnivariatePolynomialZp64
zero(IntegersZp64 ring)
Creates zero polynomialMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface cc.redberry.rings.poly.IPolynomial
add, assertSameCoefficientRingWith, canonical, coefficientRingToString, copy, createArray, createArray, monicExact, multiply, multiply, setCoefficientRingFromOptional, subtract, toPositiveLC, toString
Methods inherited from interface cc.redberry.rings.poly.univar.IUnivariatePolynomial
composition, exponents, isLinearExactly, isLinearOrConstant, isZeroCC, mapCoefficientsAsPolys, nNonZeroTerms, size
-
Field Details
-
ring
The coefficient ring
-
-
Method Details
-
parse
Deprecated.Parse string into polynomial -
parse
Deprecated.Parse string into polynomial -
parse
Parse string into polynomial -
create
Creates poly with specified coefficients represented as signed integers reducing them modulomodulus
- Parameters:
modulus
- the modulusdata
- coefficients- Returns:
- the polynomial
-
create
Creates poly with specified coefficients represented as signed integers reducing them modulomodulus
- Parameters:
ring
- the ringdata
- coefficients- Returns:
- the polynomial
-
linear
Creates linear polynomial of formcc + x * lc
- Parameters:
cc
- the constant coefficientlc
- the leading coefficientmodulus
- the modulus- Returns:
cc + x * lc
-
createUnsafe
data is not reduced modulo modulus -
createUnsafe
data is not reduced modulo modulus -
monomial
Creates monomialcoefficient * x^exponent
- Parameters:
modulus
- the moduluscoefficient
- monomial coefficientexponent
- monomial exponent- Returns:
coefficient * x^exponent
-
constant
Creates constant polynomial with specified value- Parameters:
modulus
- the modulusvalue
- the value- Returns:
- constant polynomial
-
constant
Creates constant polynomial with specified value- Parameters:
ring
- the ringvalue
- the value- Returns:
- constant polynomial
-
zero
Creates zero polynomial- Parameters:
modulus
- the modulus- Returns:
- zero polynomial
-
zero
Creates zero polynomial- Parameters:
ring
- the ring- Returns:
- zero polynomial
-
one
Creates unit polynomial- Parameters:
modulus
- the modulus- Returns:
- unit polynomial
-
one
Creates unit polynomial- Parameters:
ring
- the ring- Returns:
- unit polynomial
-
setCoefficientRingFrom
public UnivariatePolynomialZp64 setCoefficientRingFrom(UnivariatePolynomialZp64 univariatePolynomialZp64)Description copied from interface:IPolynomial
Set the coefficient ring from specified poly- Parameters:
univariatePolynomialZp64
- the polynomial- Returns:
- a copy of this with the coefficient ring taken from
poly
-
modulus
public long modulus()Returns the modulus -
setModulusUnsafe
does not copy the data and does not reduce the data with new modulus -
setModulusUnsafe
does not copy the data and does not reduce the data with new modulus -
setModulus
Creates new Zp[x] polynomial by coping the coefficients of this and reducing them modulo new modulus.- Parameters:
newModulus
- the new modulus- Returns:
- the copy of this reduced modulo new modulus
-
setModulus
Creates new Zp[x] polynomial by coping the coefficients of this and reducing them modulo new modulus.- Parameters:
newDomain
- the new domain- Returns:
- the copy of this reduced modulo new modulus
-
asPolyZSymmetric
Returns Z[x] polynomial formed from the coefficients of this represented in symmetric modular form (-modulus/2 <= cfx <= modulus/2
).- Returns:
- Z[x] version of this with coefficients represented in symmetric modular form (
-modulus/2 <= cfx <= modulus/2
).
-
asPolyZ
Returns Z[x] polynomial formed from the coefficients of this.- Parameters:
copy
- whether to copy the internal data- Returns:
- Z[x] version of this
-
createArray
Description copied from interface:IPolynomial
overcome Java generics... -
createArray
public UnivariatePolynomialZp64[] createArray(UnivariatePolynomialZp64 a, UnivariatePolynomialZp64 b)Description copied from interface:IPolynomial
overcome Java generics... -
createArray2d
Description copied from interface:IPolynomial
overcome Java generics... -
createArray2d
Description copied from interface:IPolynomial
overcome Java generics... -
getRange
Description copied from interface:IUnivariatePolynomial
Creates polynomial formed from the coefficients of this starting fromfrom
(inclusive) toto
(exclusive)- Parameters:
from
- the initial index of the range to be copied, inclusiveto
- the final index of the range to be copied, exclusive.- Returns:
- polynomial formed from the range of coefficients of this
-
sameCoefficientRingWith
Description copied from interface:IPolynomial
Returns whetheroth
andthis
have the same coefficient ring- Parameters:
oth
- other polynomial- Returns:
- whether this and oth are over the same coefficient ring
-
createFromArray
Creates new poly with the specified coefficients (over the same ring)- Parameters:
newData
- the data- Returns:
- polynomial
-
createMonomial
Creates monomialcoefficient * x^degree
(with the same coefficient ring)- Parameters:
coefficient
- monomial coefficientnewDegree
- 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
Description copied from interface:IPolynomial
Returns cardinality of the coefficient ring of this poly- Returns:
- cardinality of the coefficient ring
-
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 thecoefficientRingCardinality()
is a perfect power- Returns:
- whether the
coefficientRingCardinality()
is a perfect power
-
coefficientRingPerfectPowerBase
Description copied from interface:IPolynomial
Returnsbase
so thatcoefficientRingCardinality() == base^exponent
or null if cardinality is not finite- Returns:
base
so thatcoefficientRingCardinality() == base^exponent
or null if cardinality is not finite
-
coefficientRingPerfectPowerExponent
Description copied from interface:IPolynomial
Returnsexponent
so thatcoefficientRingCardinality() == base^exponent
or null if cardinality is not finite- Returns:
exponent
so thatcoefficientRingCardinality() == 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
Description copied from interface:IPolynomial
Setsthis
to its monic part (that isthis
divided by its leading coefficient), or returnsnull
(causing loss of internal data) if some of the elements can't be exactly divided by thelc()
. NOTE: ifnull
is returned, the content ofthis
is destroyed.- Returns:
- monic
this
ornull
-
monic
Setsthis
to its monic part multiplied by thefactor
(that ismonic(modulus).multiply(factor)
).- Parameters:
factor
- the factor- Returns:
this
-
divideByLC
Description copied from interface:IPolynomial
Divides this polynomial by the leading coefficient ofother
or returnsnull
(causing loss of internal data) if some of the elements can't be exactly divided by theother.lc()
. NOTE: ifnull
is returned, the content ofthis
is destroyed.- Parameters:
other
- the polynomial- Returns:
this
divided by theother.lc()
ornull
if exact division is not possible
-
divide
Divide by specified value- Parameters:
val
- the value- Returns:
this / val
-
multiplyByBigInteger
Description copied from interface:IPolynomial
Multiplies this byfactor
- Parameters:
factor
- the factor- Returns:
this * factor
-
multiply
Description copied from interface:IPolynomial
Multiplies this byoth
- Parameters:
oth
- the polynomial- Returns:
this * oth
-
square
Description copied from interface:IPolynomial
Squaresthis
- Returns:
this * this
-
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
-
toBigPoly
Converts this to a polynomial over BigIntegers. The ring of the result will be exactly those returned bythis.ring.asGenericRing()
- Returns:
- polynomial over BigIntegers
-
clone
Description copied from interface:IPolynomial
Deep copy of this- Specified by:
clone
in interfaceIPolynomial<UnivariatePolynomialZp64>
- Specified by:
clone
in interfaceIUnivariatePolynomial<UnivariatePolynomialZp64>
- Returns:
- deep copy of this
-
parsePoly
-
coefficientRingToString
Description copied from interface:IPolynomial
String representation of the coefficient ring of this -
composition
Description copied from interface:IUnivariatePolynomial
Calculates the composition of this(oth)- Parameters:
value
- polynomial- Returns:
- composition
this(oth)
-
asMultivariate
Description copied from interface:IUnivariatePolynomial
Convert to multivariate polynomial -
asMultivariate
Description copied from interface:IUnivariatePolynomial
Convert to multivariate polynomial -
degree
public final int degree()Description copied from interface:IPolynomial
Returns the degree of this polynomial- Specified by:
degree
in interfaceIPolynomial<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
Sets i-th element of this poly with the specified value -
setLC
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 interfaceIUnivariatePolynomial<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
Description copied from interface:IPolynomial
Returns the leading coefficient as a constant poly- Specified by:
lcAsPoly
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
-
ccAsPoly
Description copied from interface:IPolynomial
Returns the constant coefficient as a constant poly- Specified by:
ccAsPoly
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
-
getAsPoly
Description copied from interface:IUnivariatePolynomial
Returns i-th coefficient of this as a constant polynomial- Specified by:
getAsPoly
in interfaceIUnivariatePolynomial<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 storedesiredCapacity
elements- Specified by:
ensureInternalCapacity
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
-
createMonomial
Description copied from interface:IUnivariatePolynomial
Creates new monomialx^degree
(with the same coefficient ring)- Specified by:
createMonomial
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
degree
- monomial degree- Returns:
- new monomial
coefficient * x^degree
-
createLinear
Creates linear polynomial of formcc + x * lc
(with the same coefficient ring)- Parameters:
cc
- the constant coefficientlc
- the leading coefficient- Returns:
cc + x * lc
-
createConstant
Creates constant polynomial with specified value (with the same coefficient ring)- Specified by:
createConstant
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
val
- the value- Returns:
- constant polynomial with specified value
-
createZero
Description copied from interface:IPolynomial
Returns the new instance of zero polynomial (with the same coefficient ring)- Specified by:
createZero
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- new instance of 0
-
createOne
Description copied from interface:IPolynomial
Returns the new instance of unit polynomial (with the same coefficient ring)- Specified by:
createOne
in interfaceIPolynomial<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 interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
i
- the position- Returns:
- whether i-th coefficient of this is zero
-
setZero
Description copied from interface:IUnivariatePolynomial
Fills i-th element with zero- Specified by:
setZero
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
i
- position- Returns:
- self
-
setFrom
public final UnivariatePolynomialZp64 setFrom(int indexInThis, UnivariatePolynomialZp64 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 interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
indexInThis
- index in selfpoly
- other polynomialindexInPoly
- index in other polynomial- Returns:
- self
-
isZero
public final boolean isZero()Description copied from interface:IPolynomial
Returnstrue
if this is zero- Specified by:
isZero
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- whether
this
is zero
-
isOne
public final boolean isOne()Description copied from interface:IPolynomial
Returnstrue
if this is one- Specified by:
isOne
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- whether
this
is one
-
isMonic
public final boolean isMonic()Description copied from interface:IPolynomial
Returnstrue
if this polynomial is monic- Specified by:
isMonic
in interfaceIPolynomial<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 interfaceIPolynomial<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
Returnstrue
if this polynomial has only constant term- Specified by:
isConstant
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- whether
this
is constant
-
isMonomial
public final boolean isMonomial()Description copied from interface:IPolynomial
Returnstrue
if this polynomial has only one monomial term- Specified by:
isMonomial
in interfaceIPolynomial<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 interfaceIPolynomial<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
Description copied from interface:IPolynomial
Sets this to zero- Specified by:
toZero
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- this := zero
-
set
Description copied from interface:IPolynomial
Sets the content of this tooth
- Specified by:
set
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
oth
- the polynomial- Returns:
- this := oth
-
setAndDestroy
Description copied from interface:IUnivariatePolynomial
Sets the content of this withoth
and destroys oth- Specified by:
setAndDestroy
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
oth
- the polynomial (will be destroyed)- Returns:
- this := oth
-
shiftLeft
Description copied from interface:IUnivariatePolynomial
Returns the quotientthis / x^offset
, it is polynomial with coefficient list formed by shifting coefficients ofthis
to the left byoffset
.- Specified by:
shiftLeft
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
offset
- shift amount- Returns:
- the quotient
this / x^offset
-
shiftRight
Description copied from interface:IUnivariatePolynomial
Multipliesthis
by thex^offset
.- Specified by:
shiftRight
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
offset
- monomial exponent- Returns:
this * x^offset
-
truncate
Description copied from interface:IUnivariatePolynomial
Returns the remainderthis rem x^(newDegree + 1)
, it is polynomial formed by coefficients of this from zero tonewDegree
(both inclusive)- Specified by:
truncate
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
newDegree
- new degree- Returns:
- remainder
this rem x^(newDegree + 1)
-
reverse
Description copied from interface:IUnivariatePolynomial
Reverses the coefficients of this- Specified by:
reverse
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- reversed polynomial
-
contentAsPoly
Description copied from interface:IPolynomial
Returns the content of this (gcd of coefficients) as a constant poly- Specified by:
contentAsPoly
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<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 interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- primitive part (poly will be modified)
-
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 interfaceIPolynomial<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 givenpoint
(via Horner method).- Parameters:
point
-point
- Returns:
- value at
point
-
composition
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 interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
value
- polynomial- Returns:
- composition
this(oth)
-
shift
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
Description copied from interface:IPolynomial
Setsthis
to its monic part multiplied by the leading coefficient ofother
;- Specified by:
monicWithLC
in interfaceIPolynomial<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
Add constant to this.- Parameters:
val
- some number- Returns:
- this + val
-
subtract
Subtract constant from this.- Parameters:
val
- some number- Returns:
- this + val
-
decrement
Description copied from interface:IPolynomial
Subtracts 1 from this- Specified by:
decrement
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
this - 1
-
increment
Description copied from interface:IPolynomial
Adds 1 to this- Specified by:
increment
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
this + 1
-
add
Description copied from interface:IPolynomial
Addsoth
tothis
.- Specified by:
add
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
oth
- the polynomial- Returns:
this + oth
-
addMonomial
Addscoefficient*x^exponent
tothis
- Parameters:
coefficient
- monomial coefficientexponent
- monomial exponent- Returns:
this + coefficient*x^exponent
-
addMul
Addsoth * factor
tothis
- Parameters:
oth
- the polynomialfactor
- the factor- Returns:
this + oth * factor
modulomodulus
-
subtract
Description copied from interface:IPolynomial
Subtractsoth
fromthis
.- Specified by:
subtract
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
oth
- the polynomial- Returns:
this - oth
-
subtract
public final UnivariatePolynomialZp64 subtract(UnivariatePolynomialZp64 oth, long factor, int exponent)Subtractsfactor * x^exponent * oth
fromthis
- Parameters:
oth
- the polynomialfactor
- the factorexponent
- the exponent- Returns:
this - factor * x^exponent * oth
-
negate
Description copied from interface:IPolynomial
Negates this and returns- Specified by:
negate
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Returns:
- this negated
-
multiplyByLC
Description copied from interface:IPolynomial
Multiply this by the leading coefficient ofother
- Specified by:
multiplyByLC
in interfaceIPolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
- Parameters:
other
- polynomial- Returns:
- this * lc(other)
-
multiply
Description copied from interface:IPolynomial
Multiplies this byfactor
- Specified by:
multiply
in interfaceIPolynomial<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
- Specified by:
compareTo
in interfaceComparable<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
-
toString
-
toString
Description copied from interface:Stringifiable
convert this to string with the use of stringifier- Specified by:
toString
in interfaceStringifiable<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
-
toStringForCopy
-
streamAsPolys
Description copied from interface:IUnivariatePolynomial
Stream polynomial coefficients as constant polynomials- Specified by:
streamAsPolys
in interfaceIUnivariatePolynomial<lPoly extends cc.redberry.rings.poly.univar.AUnivariatePolynomial64<lPoly>>
-
stream
Returns a sequentialStream
with coefficients of this as its source.- Returns:
- a sequential
Stream
over the coefficients in this polynomial
-
mapCoefficients
Applies transformation function to this and returns the result. This method is equivalent ofstream().mapToObj(mapper).collect(new PolynomialCollector<>(ring))
.- Type Parameters:
T
- result elements type- Parameters:
ring
- ring of the new polynomialmapper
- 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
-
hashCode
public final int hashCode()
-
parse(String, IntegersZp64, String)