def _coerce_map_from_(self, R): r""" Return a coerce map from ``R`` to this field. EXAMPLES:: sage: R.<t> = GF(5)[] sage: K = R.fraction_field() sage: L = K.function_field() sage: f = K.coerce_map_from(L); f # indirect doctest Isomorphism: From: Rational function field in t over Finite Field of size 5 To: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5 sage: f(~L.gen()) 1/t """ from sage.rings.function_field.function_field import is_RationalFunctionField if is_RationalFunctionField(R) and self.variable_name( ) == R.variable_name() and self.base_ring() is R.constant_base_field(): from sage.categories.all import Hom parent = Hom(R, self) from sage.rings.function_field.maps import FunctionFieldToFractionField return parent.__make_element_class__(FunctionFieldToFractionField)( parent) return super(FractionField_1poly_field, self)._coerce_map_from_(R)
def _coerce_map_from_(self, R): r""" Return a coerce map from ``R`` to this field. EXAMPLES:: sage: R.<t> = GF(5)[] sage: K = R.fraction_field() sage: L = K.function_field() sage: f = K.coerce_map_from(L); f # indirect doctest Isomorphism: From: Rational function field in t over Finite Field of size 5 To: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5 sage: f(~L.gen()) 1/t """ from sage.rings.function_field.function_field import is_RationalFunctionField if is_RationalFunctionField(R) and self.variable_name() == R.variable_name() and self.base_ring() is R.constant_base_field(): from sage.categories.all import Hom parent = Hom(R, self) from sage.rings.function_field.maps import FunctionFieldToFractionField return parent.__make_element_class__(FunctionFieldToFractionField)(parent) return super(FractionField_1poly_field, self)._coerce_map_from_(R)
def can_convert_to_singular(R): """ Returns True if this ring's base field or ring can be represented in Singular, and the polynomial ring has at least one generator. If this is True then this polynomial ring can be represented in Singular. The following base rings are supported: finite fields, rationals, number fields, and real and complex fields. EXAMPLES:: sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular sage: can_convert_to_singular(PolynomialRing(QQ, names=['x'])) True sage: can_convert_to_singular(PolynomialRing(ZZ, names=['x'])) True sage: can_convert_to_singular(PolynomialRing(QQ, names=[])) False TESTS: Avoid non absolute number fields (see :trac:`23535`):: sage: K.<a,b> = NumberField([x^2-2,x^2-5]) sage: can_convert_to_singular(K['s,t']) False """ if R.ngens() == 0: return False base_ring = R.base_ring() if (base_ring is ZZ or sage.rings.finite_rings.finite_field_constructor.is_FiniteField( base_ring) or is_RationalField(base_ring) or is_IntegerModRing(base_ring) or is_RealField(base_ring) or is_ComplexField(base_ring) or is_RealDoubleField(base_ring) or is_ComplexDoubleField(base_ring)): return True elif base_ring.is_prime_field(): return base_ring.characteristic() <= 2147483647 elif number_field.number_field_base.is_NumberField(base_ring): return base_ring.is_absolute() elif sage.rings.fraction_field.is_FractionField(base_ring): B = base_ring.base_ring() return B.is_prime_field() or B is ZZ or is_FiniteField(B) elif is_RationalFunctionField(base_ring): return base_ring.constant_field().is_prime_field() else: return False
def can_convert_to_singular(R): """ Returns True if this ring's base field or ring can be represented in Singular, and the polynomial ring has at least one generator. If this is True then this polynomial ring can be represented in Singular. The following base rings are supported: finite fields, rationals, number fields, and real and complex fields. EXAMPLES:: sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular sage: can_convert_to_singular(PolynomialRing(QQ, names=['x'])) True sage: can_convert_to_singular(PolynomialRing(QQ, names=[])) False TESTS: Avoid non absolute number fields (see :trac:`23535`):: sage: K.<a,b> = NumberField([x^2-2,x^2-5]) sage: can_convert_to_singular(K['s,t']) False """ if R.ngens() == 0: return False; base_ring = R.base_ring() if (base_ring is ZZ or sage.rings.finite_rings.finite_field_constructor.is_FiniteField(base_ring) or is_RationalField(base_ring) or is_IntegerModRing(base_ring) or is_RealField(base_ring) or is_ComplexField(base_ring) or is_RealDoubleField(base_ring) or is_ComplexDoubleField(base_ring)): return True elif base_ring.is_prime_field(): return base_ring.characteristic() <= 2147483647 elif number_field.number_field_base.is_NumberField(base_ring): return base_ring.is_absolute() elif sage.rings.fraction_field.is_FractionField(base_ring): B = base_ring.base_ring() return B.is_prime_field() or B is ZZ or is_FiniteField(B) elif is_RationalFunctionField(base_ring): return base_ring.constant_field().is_prime_field() else: return False
def can_convert_to_singular(R): """ Returns True if this ring's base field or ring can be represented in Singular, and the polynomial ring has at least one generator. If this is True then this polynomial ring can be represented in Singular. The following base rings are supported: finite fields, rationals, number fields, and real and complex fields. EXAMPLES:: sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular sage: can_convert_to_singular(PolynomialRing(QQ, names=['x'])) True sage: can_convert_to_singular(PolynomialRing(QQ, names=[])) False """ if R.ngens() == 0: return False base_ring = R.base_ring() return ( sage.rings.finite_rings.constructor.is_FiniteField(base_ring) or is_RationalField(base_ring) or (base_ring.is_prime_field() and base_ring.characteristic() <= 2147483647) or is_RealField(base_ring) or is_ComplexField(base_ring) or is_RealDoubleField(base_ring) or is_ComplexDoubleField(base_ring) or number_field.number_field_base.is_NumberField(base_ring) or (sage.rings.fraction_field.is_FractionField(base_ring) and (base_ring.base_ring().is_prime_field() or base_ring.base_ring() is ZZ or is_FiniteField(base_ring.base_ring()))) or base_ring is ZZ or is_IntegerModRing(base_ring) or (is_RationalFunctionField(base_ring) and base_ring.constant_field().is_prime_field()))
def can_convert_to_singular(R): """ Returns True if this ring's base field or ring can be represented in Singular, and the polynomial ring has at least one generator. If this is True then this polynomial ring can be represented in Singular. The following base rings are supported: finite fields, rationals, number fields, and real and complex fields. EXAMPLES:: sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular sage: can_convert_to_singular(PolynomialRing(QQ, names=['x'])) True sage: can_convert_to_singular(PolynomialRing(QQ, names=[])) False """ if R.ngens() == 0: return False; base_ring = R.base_ring() return ( sage.rings.finite_rings.constructor.is_FiniteField(base_ring) or is_RationalField(base_ring) or (base_ring.is_prime_field() and base_ring.characteristic() <= 2147483647) or is_RealField(base_ring) or is_ComplexField(base_ring) or is_RealDoubleField(base_ring) or is_ComplexDoubleField(base_ring) or number_field.number_field_base.is_NumberField(base_ring) or ( sage.rings.fraction_field.is_FractionField(base_ring) and ( base_ring.base_ring().is_prime_field() or base_ring.base_ring() is ZZ or is_FiniteField(base_ring.base_ring()) ) ) or base_ring is ZZ or is_IntegerModRing(base_ring) or (is_RationalFunctionField(base_ring) and base_ring.constant_field().is_prime_field()) )