當前位置: 首頁>>代碼示例>>Python>>正文


Python VectorSpace.gens方法代碼示例

本文整理匯總了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)
開發者ID:gavento,項目名稱:homsearch,代碼行數:32,代碼來源:cayley.py

示例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
開發者ID:fchapoton,項目名稱:sage-flatsurf,代碼行數:71,代碼來源:similarity.py


注:本文中的sage.modules.free_module.VectorSpace.gens方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。