本文整理汇总了Python中sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing.has_coerce_map_from方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing.has_coerce_map_from方法的具体用法?Python PolynomialRing.has_coerce_map_from怎么用?Python PolynomialRing.has_coerce_map_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing
的用法示例。
在下文中一共展示了PolynomialRing.has_coerce_map_from方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DifferentialWeylAlgebra
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import has_coerce_map_from [as 别名]
#.........这里部分代码省略.........
if isinstance(x, DifferentialWeylAlgebraElement):
R = self.base_ring()
if x.parent().base_ring() is R:
return self.element_class(self, dict(x))
zero = R.zero()
return self.element_class(self, {i: R(c) for i,c in x if R(c) != zero})
x = self._poly_ring(x)
return self.element_class(self, {(tuple(m), t): c
for m,c in six.iteritems(x.dict())})
def _coerce_map_from_(self, R):
"""
Return data which determines if there is a coercion map
from ``R`` to ``self``.
If such a map exists, the output could be a map, callable,
or ``True``, which constructs a generic map. Otherwise the output
must be ``False`` or ``None``.
EXAMPLES::
sage: R.<x,y,z> = QQ[]
sage: W = DifferentialWeylAlgebra(R)
sage: W._coerce_map_from_(R)
True
sage: W._coerce_map_from_(QQ)
True
sage: W._coerce_map_from_(ZZ['x'])
True
Order of the names matter::
sage: Wp = DifferentialWeylAlgebra(QQ['x,z,y'])
sage: W.has_coerce_map_from(Wp)
False
sage: Wp.has_coerce_map_from(W)
False
Zero coordinates are handled appropriately::
sage: R.<x,y,z> = ZZ[]
sage: W3 = DifferentialWeylAlgebra(GF(3)['x,y,z'])
sage: W3.has_coerce_map_from(R)
True
sage: W.<x,y,z> = DifferentialWeylAlgebra(ZZ)
sage: W3.has_coerce_map_from(W)
True
sage: W3(3*x + y)
y
"""
if self._poly_ring.has_coerce_map_from(R):
return True
if isinstance(R, DifferentialWeylAlgebra):
return ( R.variable_names() == self.variable_names()
and self.base_ring().has_coerce_map_from(R.base_ring()) )
return super(DifferentialWeylAlgebra, self)._coerce_map_from_(R)
def degree_on_basis(self, i):
"""
Return the degree of the basis element indexed by ``i``.
EXAMPLES::
sage: W.<a,b> = DifferentialWeylAlgebra(QQ)
sage: W.degree_on_basis( ((1, 3, 2), (0, 1, 3)) )
示例2: dual
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import has_coerce_map_from [as 别名]
def dual(self):
r"""
Return the projective dual of the given subscheme of projective space.
INPUT:
- ``X`` -- A subscheme of projective space. At present, ``X`` is
required to be an irreducible and reduced hypersurface defined
over `\QQ` or a finite field.
OUTPUT:
- The dual of ``X`` as a subscheme of the dual projective space.
EXAMPLES:
The dual of a smooth conic in the plane is also a smooth conic::
sage: R.<x, y, z> = QQ[]
sage: P.<x, y, z> = ProjectiveSpace(2, QQ)
sage: I = R.ideal(x^2 + y^2 + z^2)
sage: X = P.subscheme(I)
sage: X.dual()
Closed subscheme of Projective Space of dimension 2 over Rational Field defined by:
y0^2 + y1^2 + y2^2
The dual of the twisted cubic curve in projective 3-space is a singular
quartic surface. In the following example, we compute the dual of this
surface, which by double duality is equal to the twisted cubic itself.
The output is the twisted cubic as an intersection of three quadrics::
sage: R.<x, y, z, w> = QQ[]
sage: P.<x, y, z, w> = ProjectiveSpace(3, QQ)
sage: I = R.ideal(y^2*z^2 - 4*x*z^3 - 4*y^3*w + 18*x*y*z*w - 27*x^2*w^2)
sage: X = P.subscheme(I)
sage: X.dual()
Closed subscheme of Projective Space of dimension 3 over
Rational Field defined by:
y2^2 - y1*y3,
y1*y2 - y0*y3,
y1^2 - y0*y2
The singular locus of the quartic surface in the last example
is itself supported on a twisted cubic::
sage: X.Jacobian().radical()
Ideal (z^2 - 3*y*w, y*z - 9*x*w, y^2 - 3*x*z) of Multivariate
Polynomial Ring in x, y, z, w over Rational Field
An example over a finite field::
sage: R = PolynomialRing(GF(61), 'a,b,c')
sage: P.<a, b, c> = ProjectiveSpace(2, R.base_ring())
sage: X = P.subscheme(R.ideal(a*a+2*b*b+3*c*c))
sage: X.dual()
Closed subscheme of Projective Space of dimension 2 over
Finite Field of size 61 defined by:
y0^2 - 30*y1^2 - 20*y2^2
TESTS::
sage: R = PolynomialRing(Qp(3), 'a,b,c')
sage: P.<a, b, c> = ProjectiveSpace(2, R.base_ring())
sage: X = P.subscheme(R.ideal(a*a+2*b*b+3*c*c))
sage: X.dual()
Traceback (most recent call last):
...
NotImplementedError: base ring must be QQ or a finite field
"""
from sage.libs.singular.function_factory import ff
K = self.base_ring()
if not(is_RationalField(K) or is_FiniteField(K)):
raise NotImplementedError("base ring must be QQ or a finite field")
I = self.defining_ideal()
m = I.ngens()
n = I.ring().ngens() - 1
if (m != 1 or (n < 1) or I.is_zero()
or I.is_trivial() or not I.is_prime()):
raise NotImplementedError("At the present, the method is only"
" implemented for irreducible and"
" reduced hypersurfaces and the given"
" list of generators for the ideal must"
" have exactly one element.")
R = PolynomialRing(K, 'x', n + 1)
from sage.schemes.projective.projective_space import ProjectiveSpace
Pd = ProjectiveSpace(n, K, 'y')
Rd = Pd.coordinate_ring()
x = R.variable_names()
y = Rd.variable_names()
S = PolynomialRing(K, x + y + ('t',))
if S.has_coerce_map_from(I.ring()):
T = PolynomialRing(K, 'w', n + 1)
I_S = (I.change_ring(T)).change_ring(S)
else:
I_S = I.change_ring(S)
f_S = I_S.gens()[0]
z = S.gens()
J = I_S
for i in range(n + 1):
#.........这里部分代码省略.........