up previous next
RingElem    --    convert an expression into a RINGELEM


Syntax
RingElem(R: RING, E: STRING): RINGELEM
RingElem(R: RING, E: RINGELEM): RINGELEM
RingElem(R: RING, E: INT): RINGELEM
RingElem(R: RING, E: RAT): RINGELEM
RingElem(R: RING, E:[STRING, INT, .., INT]): RINGELEM

Description
This function converts the expression E into a RINGELEM in R, if possible. These functions areuseful for operating with different rings.

If E is a STRING it evaluates E in R, (with no need for use R). The expression E may contain arithmetic operations and parentheses (but no programming variables or function calls). Use RingElemList, RingElems to read many (comma-separated) ringelems into a list.

If E is a RINGELEM it is equivalent to applying the CanonicalHom from RingOf(E) to R (for other homomorphisms see RINGHOM ).

Example
/**/ P ::= ZZ/(5)[x,y];  S ::= QQ[x,y,z[1..4]];  K := NewFractionField(S);
/**/ QR := NewQuotientRing(S, "x^2-3, y^2-5");

/**/  -- STRING
/**/  RingElem(P, "7*x");  --> 7*x as an element of P
2*x
/**/  RingElem(S, "7*x");  --> 7*x as an element of S
7*x
/**/  RingElem(S, "((7/3)*z[2] - 1)^2" ); -- expr without function calls
(49/9)*z[2]^2 +(-14/3)*z[2] +1
/**/  RingElem(K, "(x^2-x*y)/(x*y-y^2)");
x/y
/**/ RingElem(QR, "(x+y)^3");
(18*x +14*y)

/**/  -- RINGELEM (via CanonicalHom)
/**/  use S;
/**/  f := 2*x-3;
-- /**/  1/f; --> !!! ERROR !!! as expected: f in P is not invertible
/**/  1/RingElem(K, f); -- f in K is invertible
1/(2*x -3)

/**/  use P;
/**/  -- INT and RAT
/**/  RingElem(P, 7);
2
/**/  RingElem(P, 3/2);
-1

/**/  -- LIST for indexed indets
/**/  i := 2;  RingElem(S, ["z",i]);
z[2]

See Also