# HG changeset patch
# User Simon King <simon.king@uni-jena.de>
# Date 1315242749 -7200
# Node ID 6308b3e4469a5e9d7a0c20316bfe36428e7b145e
# Parent 32c6b4a32e9bfefb47e9c66308e24206dbf50883
#11780: Do not create a non-unique auxiliary polynomial ring in singular_ring_new and in numerator()
diff --git a/sage/libs/singular/ring.pyx b/sage/libs/singular/ring.pyx
a
|
b
|
|
35 | 35 | |
36 | 36 | from sage.rings.polynomial.term_order import TermOrder |
37 | 37 | from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular, MPolynomialRing_libsingular |
| 38 | from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing |
38 | 39 | |
39 | 40 | |
40 | 41 | from sage.misc.misc_c import is_64_bit |
… |
… |
|
172 | 173 | else: |
173 | 174 | raise TypeError, "characteristic must be <= 2147483647." |
174 | 175 | # TODO: This is lazy, it should only call Singular stuff not MPolynomial stuff |
175 | | k = MPolynomialRing_libsingular(base_ring.prime_subfield(), 1, base_ring.variable_name(), 'lex') |
| 176 | try: |
| 177 | k = PolynomialRing(base_ring.prime_subfield(), 1, [base_ring.variable_name()], 'lex') |
| 178 | except TypeError: |
| 179 | raise TypeError, "The multivariate polynomial ring in a single variable %s in lex order over %s is supposed to be of type %s"%(base_ring.variable_name(), base_ring,MPolynomialRing_libsingular) |
176 | 180 | minpoly = base_ring.polynomial()(k.gen()) |
177 | 181 | is_extension = True |
178 | 182 | |
179 | 183 | elif PY_TYPE_CHECK(base_ring, NumberField) and base_ring.is_absolute(): |
180 | 184 | characteristic = 1 |
181 | | k = MPolynomialRing_libsingular(RationalField(), 1, base_ring.variable_name(), 'lex') |
| 185 | try: |
| 186 | k = PolynomialRing(RationalField(), 1, [base_ring.variable_name()], 'lex') |
| 187 | except TypeError: |
| 188 | raise TypeError, "The multivariate polynomial ring in a single variable %s in lex order over Rational Field is supposed to be of type %s"%(base_ring.variable_name(), MPolynomialRing_libsingular) |
182 | 189 | minpoly = base_ring.polynomial()(k.gen()) |
183 | 190 | is_extension = True |
184 | 191 | |
diff --git a/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/sage/rings/polynomial/multi_polynomial_libsingular.pyx
a
|
b
|
|
4781 | 4781 | sage: f.numerator().base_ring() |
4782 | 4782 | Integer Ring |
4783 | 4783 | |
4784 | | We check that the computation the numerator and denominator |
4785 | | are valid |
| 4784 | We check that the computation of numerator and denominator |
| 4785 | is valid. |
4786 | 4786 | |
4787 | 4787 | :: |
4788 | 4788 | |
… |
… |
|
4790 | 4790 | sage: f=K.random_element() |
4791 | 4791 | sage: f.numerator() / f.denominator() == f |
4792 | 4792 | True |
| 4793 | |
| 4794 | The following tests against a bug that has been fixed in trac ticket #11780:: |
| 4795 | |
| 4796 | sage: P.<foo,bar> = ZZ[] |
| 4797 | sage: Q.<foo,bar> = QQ[] |
| 4798 | sage: f = Q.random_element() |
| 4799 | sage: f.numerator().parent() is P |
| 4800 | True |
4793 | 4801 | """ |
4794 | 4802 | if self.base_ring() == RationalField(): |
4795 | 4803 | #This part is for compatibility with the univariate case, |
4796 | 4804 | #where the numerator of a polynomial over RationalField |
4797 | 4805 | #is a polynomial over IntegerRing |
4798 | | integer_polynomial_ring = MPolynomialRing_libsingular(ZZ,\ |
| 4806 | # |
| 4807 | # Trac ticket #11780: Create the polynomial ring over |
| 4808 | # the integers using the (cached) polynomial ring constructor: |
| 4809 | from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing |
| 4810 | integer_polynomial_ring = PolynomialRing(ZZ,\ |
4799 | 4811 | self.parent().ngens(), self.parent().gens(), order =\ |
4800 | 4812 | self.parent().term_order()) |
4801 | 4813 | return integer_polynomial_ring(self * self.denominator()) |