本文整理汇总了Python中sage.modules.free_module.VectorSpace.gens方法的典型用法代码示例。如果您正苦于以下问题:Python VectorSpace.gens方法的具体用法?Python VectorSpace.gens怎么用?Python VectorSpace.gens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.modules.free_module.VectorSpace
的用法示例。
在下文中一共展示了VectorSpace.gens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: nonisomorphic_cubes_Z2
# 需要导入模块: from sage.modules.free_module import VectorSpace [as 别名]
# 或者: from sage.modules.free_module.VectorSpace import gens [as 别名]
def nonisomorphic_cubes_Z2(n, avoid_complete=False):
"""
Returns a generator for all n-dimensional Cube-like graphs
(Cayley graphs over Z_2^n) with their generators.
With avoid_complete=True avoids the complete graph.
Iterates over tuples (generatorSet, G).
"""
vs = VectorSpace(GF(2), n)
basegens = vs.gens()
optgens = [v for v in vs if sum(map(int,v)) >= 2]
total = 2**len(optgens)
seen_graphs = set()
c = 0
for g in powerset(optgens):
c += 1
gens = tuple(list(basegens) + g)
if c % (total / 100 + 1) == 0:
log.debug("Generating (%d of %d)" % (c, total))
if avoid_complete:
if len(g) >= len(optgens):
continue
G = CayleyGraph(vs, gens)
canon = tuple(Graph(G).canonical_label().edges())
if canon in seen_graphs:
continue
log.debug("Unique graph (%d of %d) gens=%s" % (c, total, gens))
seen_graphs.add(canon)
yield (gens, G)
示例2: SimilarityGroup
# 需要导入模块: from sage.modules.free_module import VectorSpace [as 别名]
# 或者: from sage.modules.free_module.VectorSpace import gens [as 别名]
class SimilarityGroup(UniqueRepresentation,Group):
r'''Group representing all similarities in the plane.
This is the group generated by rotations, translations and dilations.
'''
Element = Similarity
def _element_constructor_(self, *args, **kwds):
if len(args)!=1:
return self.element_class(self, *args, **kwds)
x = args[0]
p=parent(x)
if self._f.has_coerce_map_from(p):
return self.element_class( self,self._f(x), self._f.zero(), self._f.zero(), self._f.zero())
if isinstance(p, SimilarityGroup):
return self.element_class(self, x.a(), x.b(), x.s(), x.t())
if isinstance(p, TranslationGroup):
return self.element_class( self,self._f.one(), self._f.zero(), x.s(), x.t() )
return self.element_class(self, x, **kwds)
def _coerce_map_from_(self, S):
if self._f.has_coerce_map_from(S):
return True
if isinstance(S, SimilarityGroup):
return self._f.has_coerce_map_from(S._f)
if isinstance(S, TranslationGroup):
return self._f.has_coerce_map_from(S.base_field())
def __init__(self, base_field):
self._f=base_field
# The vector space of vectors
self._vs = VectorSpace(self._f,2)
Group.__init__(self, category=Groups().Infinite())
def _repr_(self):
return "SimilarityGroup over field "+str(self._f)
def one(self):
return self.element_class(self,self._f.one(),self._f.zero(),self._f.zero(),self._f.zero())
def an_element(self):
return self.element_class(self,self._f(ZZ_3),self._f(ZZ_4),self._f(ZZ_2),self._f(-ZZ_1))
def is_abelian(self):
return False
def gens(self):
pairs=[
(self._f.one(),self._f.zero()),
(self._f(ZZ_2),self._f.zero()),
(self._f.zero(),self._f(ZZ_2)),
(self._f(ZZ_3),self._f(ZZ_4))]
l=[]
for p in pairs:
for v in self._vs.gens():
l.append(self.element_class(self,p[0],p[1],v[0],v[1]))
return l
# For pickling:
#def __reduce__(self):
# return self.__class__, (self._f,)
#def _cmp_(self, other):
# return self._f == other._f
#__cmp__=_cmp_
def base_field(self):
return self._f