|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.perisic.ring.Ring com.perisic.ring.UniversalRing com.perisic.ring.UniversalPolynomialRing
public class UniversalPolynomialRing
The field of polynomials over all allowed variable names as variables. That is, say in this ring you can add a polynomial a^2 + b of Z[a][b] with b - c of Z[b][c] and get as result a polynomial of the ring Z[a][b][c] (the order of the variables is undefined and may vary).
public static void main(String [] args) { // Define a polynomial ring over R UniversalPolynomialRing U = new UniversalPolynomialRing(Ring.R); RingElt poly1 = U.map("0.5 * ((x1 - x2)^2 - a * (x1 + x2)^2)"); System.out.println("poly1="+poly1+" of "+poly1.getRing()); // 1st Example to substitute variables: String [] variables = { "x1", "x2" }; RingElt [] values = { Ring.R.map(2.3), Ring.R.map(1.7) }; RingElt poly2 = U.evaluatePolynomial(poly1, variables, values); System.out.println("Example1: poly2="+poly2+" of "+poly2.getRing()); // 2nd Example to substitute variables: RingElt poly3 = U.evaluatePolynomial(poly1, "a", Ring.R.map(-1)); System.out.println("Example2: poly3="+poly3+" of "+poly3.getRing()); // 3rd Example to substitute variables: RingElt poly4 = U.evaluatePolynomial(poly3, variables, values); System.out.println("Example3: poly4="+poly4+" of "+poly4.getRing()); }Produces the following output:
poly1=(0.5 + -0.5*a)*x2^2 + ((-1.0 + -1.0*a)*x2)*x1 + (0.5 + -0.5*a)*x1^2 of R[a][x2][x1] Example1: poly2=0.18000000000000016 + -7.999999999999999*a of R[a] Example2: poly3=1.0*x2^2 + 1.0*x1^2 of R[x2][x1] Example3: poly4=8.18 of R
Field Summary |
---|
Fields inherited from class com.perisic.ring.Ring |
---|
C, F2, Q, R, Z |
Constructor Summary | |
---|---|
UniversalPolynomialRing(Ring coefficientRing)
Construct the universal polynomial field by the ring of coefficients. |
Method Summary | |
---|---|
RingElt |
evaluatePolynomial(RingElt p,
java.lang.String[] var,
RingElt[] b)
Evaluates the polynomial p at the variables var[i] with the values b[i]. |
RingElt |
evaluatePolynomial(RingElt p,
java.lang.String var,
RingElt b)
Evaluates the Polynomial p (which may be defined over more than one variable) at b for the variable var. |
Ring |
findRing()
A suitable ring able to map 0 (and 1). |
Ring |
findRing(RingElt a)
The ring over the coefficient ring with the variables of a.getRing(). |
Ring |
findRing(RingElt a,
RingElt b)
The result is the coefficient ring over the variables of a.getRing() and the variables of b.getRing(). |
boolean |
isUFD()
true if the coefficient ring and therefore also the polynomial ring is an uniqe factorization domain. |
static void |
main(java.lang.String[] args)
Simple test method. |
RingElt |
map(java.lang.String str)
All Java identifiers are allowed as variables. |
RingElt |
reduceVariables(RingElt p)
Reduces the polynomial into a polynomial of the polynomial ring with the fewest variables. |
java.lang.String |
toString()
|
Methods inherited from class com.perisic.ring.UniversalRing |
---|
add, ediv, equalZero, gcd, inv, map, mod, mult, neg, one, tdiv, zero |
Methods inherited from class com.perisic.ring.Ring |
---|
div, eltToString, equal, evaluatePolynomial, isEuclidian, isField, map, map, map, pow, pow, sub |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UniversalPolynomialRing(Ring coefficientRing)
Method Detail |
---|
public java.lang.String toString()
toString
in class UniversalRing
public boolean isUFD()
isUFD
in class Ring
public RingElt map(java.lang.String str)
map
in class UniversalRing
public Ring findRing()
UniversalRing
findRing
in class UniversalRing
public Ring findRing(RingElt a)
findRing
in class UniversalRing
public Ring findRing(RingElt a, RingElt b)
findRing
in class UniversalRing
public RingElt reduceVariables(RingElt p)
public RingElt evaluatePolynomial(RingElt p, java.lang.String[] var, RingElt[] b)
public RingElt evaluatePolynomial(RingElt p, java.lang.String var, RingElt b)
public static void main(java.lang.String[] args)
args
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |