Changeset 7449:2fcb657f9f75
- Timestamp:
- 12/01/07 09:44:42 (5 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
sage/rings/polynomial/polynomial_element.pyx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sage/rings/polynomial/polynomial_element.pyx
r7423 r7449 525 525 526 526 def _integer_(self): 527 r""" 528 EXAMPLES: 529 sage: k = GF(47) 530 sage: R.<x> = PolynomialRing(k) 531 sage: ZZ(R(45)) 532 45 533 sage: ZZ(3*x + 45) 534 Traceback (most recent call last): 535 ... 536 TypeError: cannot coerce nonconstant polynomial 537 """ 527 538 if self.degree() > 0: 528 539 raise TypeError, "cannot coerce nonconstant polynomial" 529 540 return sage.rings.integer.Integer(self[0]) 541 542 def _rational_(self): 543 r""" 544 EXAMPLES: 545 sage: R.<x> = PolynomialRing(QQ) 546 sage: QQ(R(45/4)) 547 45/4 548 sage: QQ(3*x + 45) 549 Traceback (most recent call last): 550 ... 551 TypeError: cannot coerce nonconstant polynomial 552 """ 553 if self.degree() > 0: 554 raise TypeError, "cannot coerce nonconstant polynomial" 555 return sage.rings.rational.Rational(self[0]) 530 556 531 557 def __invert__(self):
Note: See TracChangeset
for help on using the changeset viewer.
