Package maths
Class PolyBasic
- java.lang.Object
-
- maths.PolyBasic
-
- Direct Known Subclasses:
GeoPoly
public class PolyBasic extends java.lang.ObjectThis class provides basic polynomial operations.
-
-
Constructor Summary
Constructors Constructor Description PolyBasic()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TMonob_reduce(TMono m1, java.util.Vector vlist)Reduces the polynomial by dividing it by the leading term of another polynomial.java.util.Vectorbb_reduce(java.util.Vector vlist, long t)Reduces the polynomial by dividing it by the leading term of another polynomial.java.util.Vectorbb_reduce(java.util.Vector vlist, long t, boolean s)Reduces the polynomial by dividing it by the leading term of another polynomial.double[]calculate_oncr(TMono mm, Param[] p, int dx, int dy)Calculates the values of the polynomial `mm` given the parameters `p` for two variables.double[]calculate_online(TMono mm, Param[] p, int dx, int dy)Calculates the values of the polynomial `mm` given the parameters `p` for two variables.double[]calculv(TMono mm, Param[] p)Calculates the values of the polynomial `mm` given the parameters `p`.double[]calculv_2v(TMono mm, Param[] p)Calculates the values of the polynomial `mm` given the parameters `p` for two variables.double[]calculv2poly(TMono mm1, TMono mm2, Param[] p)Calculates the values of two polynomials `mm1` and `mm2` given the parameters `p`.booleancheck_zero(TMono m)Checks if the given polynomial is zero.booleanck_eq(TMono m1, TMono m2)Checks if two monomials are equal.java.math.BigIntegercoefgcd(TMono p)Returns the greatest common divisor of the coefficients of the polynomial.TMonocp_times(long c, TMono p1)Multiplies a polynomial by a constant.booleanctLessdx(TMono m, int dx)Checks if the polynomial is less than a given value.booleanctLessdx1(TMono m, int dx)Checks if the polynomial is less than a given value.intdeg(TMono p)Returns the degree of the given polynomial.intdeg(TMono p, int x)Returns the degree of the given polynomial `p` with respect to the variable `x`.voiddiv_factor1(TMono m, int x, int n)Divides the degree of the polynomial `m` by `n` for the variable `x`.voideraseCommonDono(java.util.Vector v)Erases common Dono objects from the given vector of polynomials.TMonofactor_remove(TMono p1, TMono p2)Removes the common factors of the polynomial `p1` using the polynomial `p2`.voidfactor1(TMono m1)Factors the polynomial `m1` by dividing it by its common factors.java.util.Vectorg_basis(java.util.Vector v)Computes the Groebner basis for the given vector of polynomials.booleangb_finished(java.util.Vector v)Checks if the polynomial is finished.TMonoget_factor1(TMono m)Gets the common factors of the polynomial `m`.java.lang.StringgetAllPrinted(TMono p)Returns a string representation of all printed monomials in the polynomial.java.lang.StringgetAllPrinted(TMono p, boolean b)Returns a string representation of all printed monomials in the polynomial.java.util.Vectorgetcnds(java.util.Vector v, int dx)Gets the conditions for the given vector of polynomials.TDonogetDo(java.util.Vector v, int n)Gets the Dono object from the given vector of polynomials.java.lang.StringgetExpandedPrint(TMono p)Returns a string representation of the polynomial with expanded format.static PolyBasicgetInstance()Returns the singleton instance of the PolyBasic class.intgetMaxX(java.util.Vector v)Gets the maximum value of x in a vector of polynomials.TMonogetxm1(int x, int d, TMono m)Gets the leading coefficient of a polynomial.TMonoll_delta(int x, TMono m1, TMono m2)Computes the delta of two polynomials.intlv(TMono p)Returns the leading variable of the given polynomial.voidndg_reduce(java.util.Vector v)Reduces the polynomial by removing terms with degree 0.TMonop_copy(TMono p)Creates a copy of the polynomial `p`.TMonopadd(TMono p1, TMono p2)Adds two polynomials.java.util.VectorparseCommonDono(java.util.Vector v, int dx)Parses common Dono objects from the given vector of polynomials.TMonopcopy(TMono p)Creates a copy of the given polynomial.TMonopctimes(TMono p, long c)Multiplies a polynomial by a constant.TMonopdif(TMono p1, TMono p2)Subtracts the second polynomial from the first polynomial.intplength(TMono m)Returns the length of the given polynomial.voidppush(TMono m, java.util.Vector v)Pushes a polynomial into a sorted vector.TPolyppush(TMono t, TPoly pp)Pushes a polynomial into a sorted linked list.TMonoprem(TMono p1, TMono p2)Computes the pseudo-remainder of two polynomials.voidprint(TMono p)Prints the given polynomial.java.lang.StringprintHead(TMono m)Returns the head of the polynomial as a string.java.lang.StringprintMaxstrPoly(TMono m)Returns a string representation of the polynomial with a maximum length.java.lang.StringprintNPoly(TMono m)Returns a string representation of the polynomial with a maximum length.java.lang.StringprintNPoly(TMono m1, TMono m2)Returns a string representation of two polynomials with a maximum length.voidprintpoly(TMono m)Prints the given polynomial.java.lang.StringprintSPoly(TMono m)Returns a simplified string representation of the polynomial.java.lang.StringprintSPoly(TMono m, int n)Returns a simplified string representation of the polynomial with a specified maximum length.voidprintVpoly(java.util.Vector v)Prints the given vector of polynomials.TMonopRtimes(TMono p1, TMono p2)Multiplies two polynomials.TMonopth(int x, int c, int d)Creates a new monomial with the specified variable, coefficient, and degree.TMonopth(int x, java.math.BigInteger c, int d)Creates a new monomial with the specified variable, BigInteger coefficient, and degree.TMonoptimes(TMono p1, TMono p2)Multiplies two polynomials.TMonopzero()Returns a zero polynomial.booleanpzerop(TMono m)Checks if the given polynomial is zero.TMonoreduce(TMono m, Param[] p)Reduces the given polynomial `m` using the provided parameters `p`.TMonoreduceMDono(TMono mm, java.util.Vector v, int dx)Reduces the polynomial by dividing it by the leading term of another polynomial.java.util.Vectors_polys(java.util.Vector vlist)Computes the S-polynomials for the given vector of polynomials.static voidsetbbStop(boolean t)Sets the BB\_STOP flag.static voidsetRMCOEF(boolean s)Sets the RM\_SCOEF flag.TMonosimplify(TMono m, Param[] p)Simplifies a polynomial to a lower degree without removing coefficients.TDonosplitDono(TMono m, int dx)Splits the given monomial into a Dono object.voidsprint(TMono p)Prints the polynomial in a simplified format.java.lang.StringString_p_print(TMono p, boolean ce, boolean first, boolean nn)Returns a string representation of the polynomial.voidupValueDM(java.util.Vector v, int dx)Updates the value of a polynomial by adding a given value to its coefficients.voidupValueTM(java.util.Vector v, int dx)Updates the value of a polynomial by adding a given value to its coefficients.voidupValueTM(TMono m, int dx)Updates the value of a polynomial by adding a given value to its coefficients.
-
-
-
Method Detail
-
getInstance
public static PolyBasic getInstance()
Returns the singleton instance of the PolyBasic class.- Returns:
- the singleton instance of PolyBasic
-
setbbStop
public static void setbbStop(boolean t)
Sets the BB\_STOP flag.- Parameters:
t- the new value for the BB\_STOP flag
-
setRMCOEF
public static void setRMCOEF(boolean s)
Sets the RM\_SCOEF flag.- Parameters:
s- the new value for the RM\_SCOEF flag
-
cp_times
public TMono cp_times(long c, TMono p1)
Multiplies a polynomial by a constant.- Parameters:
c- the constant to multiply byp1- the polynomial to be multiplied- Returns:
- the resulting polynomial after multiplication
-
check_zero
public boolean check_zero(TMono m)
Checks if the given polynomial is zero.- Parameters:
m- the polynomial to check- Returns:
- true if the polynomial is zero, false otherwise
-
deg
public int deg(TMono p, int x)
Returns the degree of the given polynomial `p` with respect to the variable `x`.- Parameters:
p- the polynomial to checkx- the variable to check the degree against- Returns:
- the degree of the polynomial with respect to `x`
-
reduce
public TMono reduce(TMono m, Param[] p)
Reduces the given polynomial `m` using the provided parameters `p`.- Parameters:
m- the polynomial to be reducedp- the array of parameters used for reduction- Returns:
- the reduced polynomial
-
simplify
public TMono simplify(TMono m, Param[] p)
Simplifies a polynomial to a lower degree without removing coefficients.- Parameters:
m- the polynomial to simplifyp- the array of parameters used for simplification- Returns:
- the simplified polynomial
-
prem
public TMono prem(TMono p1, TMono p2)
Computes the pseudo-remainder of two polynomials.- Parameters:
p1- the first polynomialp2- the second polynomial- Returns:
- the pseudo-remainder of the two polynomials
-
div_factor1
public void div_factor1(TMono m, int x, int n)
Divides the degree of the polynomial `m` by `n` for the variable `x`.- Parameters:
m- the polynomial to be modifiedx- the variable whose degree is to be dividedn- the divisor for the degree
-
factor1
public void factor1(TMono m1)
Factors the polynomial `m1` by dividing it by its common factors.- Parameters:
m1- the polynomial to be factored
-
get_factor1
public TMono get_factor1(TMono m)
Gets the common factors of the polynomial `m`.- Parameters:
m- the polynomial to get factors from- Returns:
- the common factors of the polynomial
-
factor_remove
public TMono factor_remove(TMono p1, TMono p2)
Removes the common factors of the polynomial `p1` using the polynomial `p2`.- Parameters:
p1- the polynomial to be factoredp2- the polynomial used for factoring- Returns:
- the factored polynomial
-
p_copy
public TMono p_copy(TMono p)
Creates a copy of the polynomial `p`.- Parameters:
p- the polynomial to copy- Returns:
- the copied polynomial
-
ppush
public void ppush(TMono m, java.util.Vector v)
Pushes a polynomial into a sorted vector.- Parameters:
m- the polynomial to pushv- the vector to push into
-
print
public void print(TMono p)
Prints the given polynomial.- Parameters:
p- the polynomial to print
-
sprint
public void sprint(TMono p)
Prints the polynomial in a simplified format.- Parameters:
p- the polynomial to print
-
pth
public TMono pth(int x, int c, int d)
Creates a new monomial with the specified variable, coefficient, and degree.- Parameters:
x- the variable of the monomialc- the coefficient of the monomiald- the degree of the monomial- Returns:
- the created monomial
-
pth
public TMono pth(int x, java.math.BigInteger c, int d)
Creates a new monomial with the specified variable, BigInteger coefficient, and degree.- Parameters:
x- the variable of the monomialc- the BigInteger coefficient of the monomiald- the degree of the monomial- Returns:
- the created monomial
-
deg
public int deg(TMono p)
Returns the degree of the given polynomial.- Parameters:
p- the polynomial- Returns:
- the degree of the polynomial
-
lv
public int lv(TMono p)
Returns the leading variable of the given polynomial.- Parameters:
p- the polynomial- Returns:
- the leading variable of the polynomial
-
pzero
public TMono pzero()
Returns a zero polynomial.- Returns:
- a zero polynomial
-
plength
public int plength(TMono m)
Returns the length of the given polynomial.- Parameters:
m- the polynomial- Returns:
- the length of the polynomial
-
pzerop
public boolean pzerop(TMono m)
Checks if the given polynomial is zero.- Parameters:
m- the polynomial to check- Returns:
- true if the polynomial is zero, false otherwise
-
ppush
public TPoly ppush(TMono t, TPoly pp)
Pushes a polynomial into a sorted linked list.- Parameters:
t- the polynomial to pushpp- the linked list to push into- Returns:
- the updated linked list with the polynomial added
-
calculv
public double[] calculv(TMono mm, Param[] p)
Calculates the values of the polynomial `mm` given the parameters `p`.- Parameters:
mm- the polynomial to calculatep- the array of parameters used in the calculation- Returns:
- an array of calculated values of the polynomial
-
calculv_2v
public double[] calculv_2v(TMono mm, Param[] p)
Calculates the values of the polynomial `mm` given the parameters `p` for two variables.- Parameters:
mm- the polynomial to calculatep- the array of parameters used in the calculation- Returns:
- an array of calculated values of the polynomial
-
calculate_online
public double[] calculate_online(TMono mm, Param[] p, int dx, int dy)
Calculates the values of the polynomial `mm` given the parameters `p` for two variables.- Parameters:
mm- the polynomial to calculatep- the array of parameters used in the calculationdx- the first variable indexdy- the second variable index- Returns:
- an array of calculated values of the polynomial
-
calculate_oncr
public double[] calculate_oncr(TMono mm, Param[] p, int dx, int dy)
Calculates the values of the polynomial `mm` given the parameters `p` for two variables.- Parameters:
mm- the polynomial to calculatep- the array of parameters used in the calculationdx- the first variable indexdy- the second variable index- Returns:
- an array of calculated values of the polynomial
-
calculv2poly
public double[] calculv2poly(TMono mm1, TMono mm2, Param[] p)
Calculates the values of two polynomials `mm1` and `mm2` given the parameters `p`.- Parameters:
mm1- the first polynomial to calculatemm2- the second polynomial to calculatep- the array of parameters used in the calculation- Returns:
- an array of calculated values of the polynomials
-
pRtimes
public TMono pRtimes(TMono p1, TMono p2)
Multiplies two polynomials.- Parameters:
p1- the first polynomialp2- the second polynomial- Returns:
- the product of the two polynomials
-
padd
public TMono padd(TMono p1, TMono p2)
Adds two polynomials.- Parameters:
p1- the first polynomialp2- the second polynomial- Returns:
- the sum of the two polynomials
-
pdif
public TMono pdif(TMono p1, TMono p2)
Subtracts the second polynomial from the first polynomial.- Parameters:
p1- the first polynomialp2- the second polynomial- Returns:
- the difference of the two polynomials
-
pcopy
public TMono pcopy(TMono p)
Creates a copy of the given polynomial.- Parameters:
p- the polynomial to copy- Returns:
- the copied polynomial
-
ptimes
public TMono ptimes(TMono p1, TMono p2)
Multiplies two polynomials.- Parameters:
p1- the first polynomialp2- the second polynomial- Returns:
- the product of the two polynomials
-
pctimes
public TMono pctimes(TMono p, long c)
Multiplies a polynomial by a constant.- Parameters:
p- the polynomialc- the constant- Returns:
- the product of the polynomial and the constant
-
printpoly
public void printpoly(TMono m)
Prints the given polynomial.- Parameters:
m- the polynomial to print
-
printHead
public java.lang.String printHead(TMono m)
Returns the head of the polynomial as a string.- Parameters:
m- the polynomial- Returns:
- the head of the polynomial as a string
-
printSPoly
public java.lang.String printSPoly(TMono m)
Returns a simplified string representation of the polynomial.- Parameters:
m- the polynomial- Returns:
- the simplified string representation of the polynomial
-
printNPoly
public java.lang.String printNPoly(TMono m)
Returns a string representation of the polynomial with a maximum length.- Parameters:
m- the polynomial- Returns:
- the string representation of the polynomial with a maximum length
-
printNPoly
public java.lang.String printNPoly(TMono m1, TMono m2)
Returns a string representation of two polynomials with a maximum length.- Parameters:
m1- the first polynomialm2- the second polynomial- Returns:
- the string representation of the two polynomials with a maximum length
-
printSPoly
public java.lang.String printSPoly(TMono m, int n)
Returns a simplified string representation of the polynomial with a specified maximum length.- Parameters:
m- the polynomialn- the maximum length of the string representation- Returns:
- the simplified string representation of the polynomial with a specified maximum length
-
printMaxstrPoly
public java.lang.String printMaxstrPoly(TMono m)
Returns a string representation of the polynomial with a maximum length.- Parameters:
m- the polynomial- Returns:
- the string representation of the polynomial with a maximum length
-
String_p_print
public java.lang.String String_p_print(TMono p, boolean ce, boolean first, boolean nn)
Returns a string representation of the polynomial.- Parameters:
p- the polynomialce- a flag indicating whether to enclose the polynomial in parenthesesfirst- a flag indicating whether this is the first polynomial in a sequencenn- a flag indicating whether to include the leading coefficient- Returns:
- the string representation of the polynomial
-
getExpandedPrint
public java.lang.String getExpandedPrint(TMono p)
Returns a string representation of the polynomial with expanded format.- Parameters:
p- the polynomial- Returns:
- the string representation of the polynomial with expanded format
-
getAllPrinted
public java.lang.String getAllPrinted(TMono p, boolean b)
Returns a string representation of all printed monomials in the polynomial.- Parameters:
p- the polynomialb- a flag indicating whether to include the leading coefficient- Returns:
- the string representation of all printed monomials in the polynomial
-
getAllPrinted
public java.lang.String getAllPrinted(TMono p)
Returns a string representation of all printed monomials in the polynomial.- Parameters:
p- the polynomial- Returns:
- the string representation of all printed monomials in the polynomial
-
coefgcd
public java.math.BigInteger coefgcd(TMono p)
Returns the greatest common divisor of the coefficients of the polynomial.- Parameters:
p- the polynomial- Returns:
- the greatest common divisor of the coefficients of the polynomial
-
bb_reduce
public java.util.Vector bb_reduce(java.util.Vector vlist, long t)Reduces the polynomial by dividing it by the leading term of another polynomial.- Parameters:
vlist- the list of polynomials to reducet- the time limit for reduction- Returns:
- the reduced polynomial
-
bb_reduce
public java.util.Vector bb_reduce(java.util.Vector vlist, long t, boolean s)Reduces the polynomial by dividing it by the leading term of another polynomial.- Parameters:
vlist- the list of polynomials to reducet- the time limit for reductions- a flag indicating whether to use a special reduction method- Returns:
- the reduced polynomial
-
b_reduce
public TMono b_reduce(TMono m1, java.util.Vector vlist)
Reduces the polynomial by dividing it by the leading term of another polynomial.- Parameters:
m1- the first polynomialvlist- the list of polynomials to reduce- Returns:
- the reduced polynomial
-
printVpoly
public void printVpoly(java.util.Vector v)
Prints the given vector of polynomials.- Parameters:
v- the vector of polynomials to print
-
g_basis
public java.util.Vector g_basis(java.util.Vector v)
Computes the Groebner basis for the given vector of polynomials.- Parameters:
v- the vector of polynomials- Returns:
- the Groebner basis as a vector of polynomials
-
s_polys
public java.util.Vector s_polys(java.util.Vector vlist)
Computes the S-polynomials for the given vector of polynomials.- Parameters:
vlist- the vector of polynomials- Returns:
- the S-polynomials as a vector of polynomials
-
ll_delta
public TMono ll_delta(int x, TMono m1, TMono m2)
Computes the delta of two polynomials.- Parameters:
x- the variablem1- the first polynomialm2- the second polynomial- Returns:
- the delta of the two polynomials
-
getxm1
public TMono getxm1(int x, int d, TMono m)
Gets the leading coefficient of a polynomial.- Parameters:
x- the variabled- the degreem- the polynomial- Returns:
- the leading coefficient
-
upValueTM
public void upValueTM(java.util.Vector v, int dx)Updates the value of a polynomial by adding a given value to its coefficients.- Parameters:
v- the polynomialdx- the value to add
-
upValueDM
public void upValueDM(java.util.Vector v, int dx)Updates the value of a polynomial by adding a given value to its coefficients.- Parameters:
v- the polynomialdx- the value to add
-
getMaxX
public int getMaxX(java.util.Vector v)
Gets the maximum value of x in a vector of polynomials.- Parameters:
v- the vector of polynomials- Returns:
- the maximum value of x
-
upValueTM
public void upValueTM(TMono m, int dx)
Updates the value of a polynomial by adding a given value to its coefficients.- Parameters:
m- the polynomialdx- the value to add
-
gb_finished
public boolean gb_finished(java.util.Vector v)
Checks if the polynomial is finished.- Parameters:
v- the vector of polynomials- Returns:
- true if the polynomial is finished, false otherwise
-
ndg_reduce
public void ndg_reduce(java.util.Vector v)
Reduces the polynomial by removing terms with degree 0.- Parameters:
v- the vector of polynomials
-
getcnds
public java.util.Vector getcnds(java.util.Vector v, int dx)Gets the conditions for the given vector of polynomials.- Parameters:
v- the vector of polynomialsdx- the value to add- Returns:
- the conditions as a vector of polynomials
-
parseCommonDono
public java.util.Vector parseCommonDono(java.util.Vector v, int dx)Parses common Dono objects from the given vector of polynomials.- Parameters:
v- the vector of polynomialsdx- the value to add- Returns:
- a vector of parsed Dono objects
-
eraseCommonDono
public void eraseCommonDono(java.util.Vector v)
Erases common Dono objects from the given vector of polynomials.- Parameters:
v- the vector of polynomials
-
ck_eq
public boolean ck_eq(TMono m1, TMono m2)
Checks if two monomials are equal.- Parameters:
m1- the first monomialm2- the second monomial- Returns:
- true if the monomials are equal, false otherwise
-
ctLessdx1
public boolean ctLessdx1(TMono m, int dx)
Checks if the polynomial is less than a given value. This method only traverses the `coef` chain of the polynomial.- Parameters:
m- the polynomialdx- the value to compare with- Returns:
- true if the polynomial is less than the given value, false otherwise
-
ctLessdx
public boolean ctLessdx(TMono m, int dx)
Checks if the polynomial is less than a given value. This method traverses both the `coef` and `next` chains of the polynomial and uses recursion.- Parameters:
m- the polynomialdx- the value to compare with- Returns:
- true if the polynomial is less than the given value, false otherwise
-
reduceMDono
public TMono reduceMDono(TMono mm, java.util.Vector v, int dx)
Reduces the polynomial by dividing it by the leading term of another polynomial.- Parameters:
mm- the polynomial to reducev- the vector of polynomialsdx- the value to add- Returns:
- the reduced polynomial
-
getDo
public TDono getDo(java.util.Vector v, int n)
Gets the Dono object from the given vector of polynomials.- Parameters:
v- the vector of polynomialsn- the value to compare with- Returns:
- the Dono object, or null if not found
-
-