class_docstr: Properties
  ==========
  
  [1] `0 \in \Omega` and `\tau(1) = \epsilon`
  [2] `\alpha^x = \beta \Leftrightarrow \beta^{x^{-1}} = \alpha`
  [3] If `\alpha^x = \beta`, then `H \tau(\alpha)x = H \tau(\beta)`
  [4] `\forall \alpha \in \Omega, 1^{\tau(\alpha)} = \alpha`
  
  References
  ==========
  
  .. [1] Holt, D., Eick, B., O'Brien, E.
         "Handbook of Computational Group Theory"
  
  .. [2] John J. Cannon; Lucien A. Dimino; George Havas; Jane M. Watson
         Mathematics of Computation, Vol. 27, No. 123. (Jul., 1973), pp. 463-490.
         "Implementation and Analysis of the Todd-Coxeter Algorithm"
class_docstr_tok: ["Properties","==========","[","1","]","`","0","\\in","\\Omega","`","and","`","\\tau","(","1",")","=","\\epsilon","`","[","2","]","`","\\alpha^x","=","\\beta","\\Leftrightarrow","\\beta^","{","x^","{","-1","}","}","=","\\alpha","`","[","3","]","If","`","\\alpha^x","=","\\beta","`",",","then","`","H","\\tau","(","\\alpha",")","x","=","H","\\tau","(","\\beta",")","`","[","4","]","`","\\forall","\\alpha","\\in","\\Omega",",","1^","{","\\tau","(","\\alpha",")","}","=","\\alpha","`","References","==========","..","[","1","]","Holt",",","D.",",","Eick",",","B.",",","O'Brien",",","E.","``","Handbook","of","Computational","Group","Theory","''","..","[","2","]","John","J.","Cannon",";","Lucien","A.","Dimino",";","George","Havas",";","Jane","M.","Watson","Mathematics","of","Computation",",","Vol",".","27",",","No",".","123",".","(","Jul.",",","1973",")",",","pp",".","463-490",".","``","Implementation","and","Analysis","of","the","Todd-Coxeter","Algorithm","''"]
docstr: Parameters
  ==========
  
  `k \in [0 \ldots n-1]`, as for ``self`` only array ``p`` is used
  
  Returns
  =======
  
  Representative of the class containing ``k``.
  
  Returns the representative of `\sim` class containing ``k``, it also
  makes some modification to array ``p`` of ``self`` to ease further
  computations, described on Pg. 157 [1].
  
  The information on classes under `\sim` is stored in array `p` of
  ``self`` argument, which will always satisfy the property:
  
  `p[\alpha] \sim \alpha` and `p[\alpha]=\alpha \iff \alpha=rep(\alpha)`
  `\forall \in [0 \ldots n-1]`.
  
  So, for `\alpha \in [0 \ldots n-1]`, we find `rep(self, \alpha)` by
  continually replacing `\alpha` by `p[\alpha]` until it becomes
  constant (i.e satisfies `p[\alpha] = \alpha`):w
  
  To increase the efficiency of later ``rep`` calculations, whenever we
  find `rep(self, \alpha)=\beta`, we set
  `p[\gamma] = \beta \forall \gamma \in p-chain` from `\alpha` to `\beta`
  
  Notes
  =====
  
  ``rep`` routine is also described on Pg. 85-87 [1] in Atkinson's
  algorithm, this results from the fact that ``coincidence`` routine
  introduces functionality similar to that introduced by the
  ``minimal_block`` routine on Pg. 85-87 [1].
  
  See Also
  ========
  
  coincidence, merge
docstr_tok: ["Parameters","==========","`","k","\\in","[","0","\\ldots","n-1","]","`",",","as","for","``","self","``","only","array","``","p","``","is","used","Returns","=======","Representative","of","the","class","containing","``","k","``",".","Returns","the","representative","of","`","\\sim","`","class","containing","``","k","``",",","it","also","makes","some","modification","to","array","``","p","``","of","``","self","``","to","ease","further","computations",",","described","on","Pg",".","157","[","1","]",".","The","information","on","classes","under","`","\\sim","`","is","stored","in","array","`","p","`","of","``","self","``","argument",",","which","will","always","satisfy","the","property",":","`","p","[","\\alpha","]","\\sim","\\alpha","`","and","`","p","[","\\alpha","]","=\\alpha","\\iff","\\alpha=rep","(","\\alpha",")","`","`","\\forall","\\in","[","0","\\ldots","n-1","]","`",".","So",",","for","`","\\alpha","\\in","[","0","\\ldots","n-1","]","`",",","we","find","`","rep","(","self",",","\\alpha",")","`","by","continually","replacing","`","\\alpha","`","by","`","p","[","\\alpha","]","`","until","it","becomes","constant","(","i.e","satisfies","`","p","[","\\alpha","]","=","\\alpha","`",")",":","w","To","increase","the","efficiency","of","later","``","rep","``","calculations",",","whenever","we","find","`","rep","(","self",",","\\alpha",")","=\\beta","`",",","we","set","`","p","[","\\gamma","]","=","\\beta","\\forall","\\gamma","\\in","p-chain","`","from","`","\\alpha","`","to","`","\\beta","`","Notes","=====","``","rep","``","routine","is","also","described","on","Pg",".","85-87","[","1","]","in","Atkinson's","algorithm",",","this","results","from","the","fact","that","``","coincidence","``","routine","introduces","functionality","similar","to","that","introduced","by","the","``","minimal_block","``","routine","on","Pg",".","85-87","[","1","]",".","See","Also","========","coincidence",",","merge"]
code: def rep(self, k, modified=False):
      r"""
      Parameters
      ==========
  
      `k \in [0 \ldots n-1]`, as for ``self`` only array ``p`` is used
  
      Returns
      =======
  
      Representative of the class containing ``k``.
  
      Returns the representative of `\sim` class containing ``k``, it also
      makes some modification to array ``p`` of ``self`` to ease further
      computations, described on Pg. 157 [1].
  
      The information on classes under `\sim` is stored in array `p` of
      ``self`` argument, which will always satisfy the property:
  
      `p[\alpha] \sim \alpha` and `p[\alpha]=\alpha \iff \alpha=rep(\alpha)`
      `\forall \in [0 \ldots n-1]`.
  
      So, for `\alpha \in [0 \ldots n-1]`, we find `rep(self, \alpha)` by
      continually replacing `\alpha` by `p[\alpha]` until it becomes
      constant (i.e satisfies `p[\alpha] = \alpha`):w
  
      To increase the efficiency of later ``rep`` calculations, whenever we
      find `rep(self, \alpha)=\beta`, we set
      `p[\gamma] = \beta \forall \gamma \in p-chain` from `\alpha` to `\beta`
  
      Notes
      =====
  
      ``rep`` routine is also described on Pg. 85-87 [1] in Atkinson's
      algorithm, this results from the fact that ``coincidence`` routine
      introduces functionality similar to that introduced by the
      ``minimal_block`` routine on Pg. 85-87 [1].
  
      See Also
      ========
  
      coincidence, merge
  
      """
      p = self.p
      lamda = k
      rho = p[lamda]
      if modified:
          s = p[:]
      while rho != lamda:
          if modified:
              s[rho] = lamda
          lamda = rho
          rho = p[lamda]
      if modified:
          rho = s[lamda]
          while rho != k:
              mu = rho
              rho = s[mu]
              p[rho] = lamda
              self.p_p[rho] = self.p_p[rho] * self.p_p[mu]
      else:
          mu = k
          rho = p[mu]
          while rho != lamda:
              p[mu] = lamda
              mu = rho
              rho = p[mu]
      return lamda
  
imports: from sympy.combinatorics.free_groups import free_group
  from sympy.printing.defaults import DefaultPrinting
  from itertools import chain, product
  from bisect import bisect_left
label_desc: Use image node_id 14 for calling the CosetTable obj's underlying member method code with example usage: obj.rep(k, modified) and returns: lamda