本文整理汇总了Python中sage.all.PolynomialRing.ngens方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing.ngens方法的具体用法?Python PolynomialRing.ngens怎么用?Python PolynomialRing.ngens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.all.PolynomialRing
的用法示例。
在下文中一共展示了PolynomialRing.ngens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_key
# 需要导入模块: from sage.all import PolynomialRing [as 别名]
# 或者: from sage.all.PolynomialRing import ngens [as 别名]
def create_key(self,base_ring, arg1=None, arg2=None,
sparse=False, order='degrevlex',
names=None, name=None,
implementation=None, degrees=None):
"""
Create the key under which a free algebra is stored.
TESTS::
sage: FreeAlgebra.create_key(GF(5),['x','y','z'])
(Finite Field of size 5, ('x', 'y', 'z'))
sage: FreeAlgebra.create_key(GF(5),['x','y','z'],3)
(Finite Field of size 5, ('x', 'y', 'z'))
sage: FreeAlgebra.create_key(GF(5),3,'xyz')
(Finite Field of size 5, ('x', 'y', 'z'))
sage: FreeAlgebra.create_key(GF(5),['x','y','z'], implementation='letterplace')
(Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,)
sage: FreeAlgebra.create_key(GF(5),['x','y','z'],3, implementation='letterplace')
(Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,)
sage: FreeAlgebra.create_key(GF(5),3,'xyz', implementation='letterplace')
(Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,)
sage: FreeAlgebra.create_key(GF(5),3,'xyz', implementation='letterplace', degrees=[1,2,3])
((1, 2, 3), Multivariate Polynomial Ring in x, y, z, x_ over Finite Field of size 5)
"""
if arg1 is None and arg2 is None and names is None:
# this is used for pickling
if degrees is None:
return (base_ring,)
return tuple(degrees),base_ring
PolRing = None
# test if we can use libSingular/letterplace
if implementation is not None and implementation != 'generic':
try:
PolRing = PolynomialRing(base_ring, arg1, arg2,
sparse=sparse, order=order,
names=names, name=name,
implementation=implementation if implementation!='letterplace' else None)
if not isinstance(PolRing,MPolynomialRing_libsingular):
if PolRing.ngens() == 1:
PolRing = PolynomialRing(base_ring,1,PolRing.variable_names())
if not isinstance(PolRing,MPolynomialRing_libsingular):
raise TypeError
else:
raise TypeError
except (TypeError, NotImplementedError),msg:
raise NotImplementedError, "The letterplace implementation is not available for the free algebra you requested"
示例2: create_key
# 需要导入模块: from sage.all import PolynomialRing [as 别名]
# 或者: from sage.all.PolynomialRing import ngens [as 别名]
def create_key(self,base_ring, arg1=None, arg2=None,
sparse=False, order='degrevlex',
names=None, name=None,
implementation=None, degrees=None):
"""
Create the key under which a free algebra is stored.
TESTS::
sage: FreeAlgebra.create_key(GF(5),['x','y','z'])
(Finite Field of size 5, ('x', 'y', 'z'))
sage: FreeAlgebra.create_key(GF(5),['x','y','z'],3)
(Finite Field of size 5, ('x', 'y', 'z'))
sage: FreeAlgebra.create_key(GF(5),3,'xyz')
(Finite Field of size 5, ('x', 'y', 'z'))
sage: FreeAlgebra.create_key(GF(5),['x','y','z'], implementation='letterplace')
(Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,)
sage: FreeAlgebra.create_key(GF(5),['x','y','z'],3, implementation='letterplace')
(Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,)
sage: FreeAlgebra.create_key(GF(5),3,'xyz', implementation='letterplace')
(Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,)
sage: FreeAlgebra.create_key(GF(5),3,'xyz', implementation='letterplace', degrees=[1,2,3])
((1, 2, 3), Multivariate Polynomial Ring in x, y, z, x_ over Finite Field of size 5)
"""
if arg1 is None and arg2 is None and names is None:
# this is used for pickling
if degrees is None:
return (base_ring,)
return tuple(degrees),base_ring
PolRing = None
# test if we can use libSingular/letterplace
if implementation is not None and implementation != 'generic':
try:
PolRing = PolynomialRing(base_ring, arg1, arg2,
sparse=sparse, order=order,
names=names, name=name,
implementation=implementation if implementation != 'letterplace' else None)
if not isinstance(PolRing, MPolynomialRing_libsingular):
if PolRing.ngens() == 1:
PolRing = PolynomialRing(base_ring, 1, PolRing.variable_names())
if not isinstance(PolRing, MPolynomialRing_libsingular):
raise TypeError
else:
raise TypeError
except (TypeError, NotImplementedError) as msg:
raise NotImplementedError("The letterplace implementation is not available for the free algebra you requested")
if PolRing is not None:
if degrees is None:
return (PolRing,)
from sage.all import TermOrder
T = PolRing.term_order() + TermOrder('lex',1)
varnames = list(PolRing.variable_names())
newname = 'x'
while newname in varnames:
newname += '_'
varnames.append(newname)
return tuple(degrees),PolynomialRing(PolRing.base(), varnames,
sparse=sparse, order=T,
implementation=implementation if implementation != 'letterplace' else None)
# normalise the generator names
from sage.all import Integer
if isinstance(arg1, (int, long, Integer)):
arg1, arg2 = arg2, arg1
if not names is None:
arg1 = names
elif not name is None:
arg1 = name
if arg2 is None:
arg2 = len(arg1)
names = sage.structure.parent_gens.normalize_names(arg2, arg1)
return base_ring, names