#NEWLINE# def _naive_list_centralizer( self , other , af = False ) : #NEWLINE# #INDENT# from sympy.combinatorics.perm_groups import PermutationGroup #NEWLINE# '\n    Return a list of elements for the centralizer of a subgroup/set/element.\n\n    This is a brute force implementation that goes over all elements of the\n    group and checks for membership in the centralizer. It is used to\n    test ``.centralizer()`` from ``sympy.combinatorics.perm_groups``.\n\n    Examples\n    ========\n\n    >>> from sympy.combinatorics.testutil import _naive_list_centralizer\n    >>> from sympy.combinatorics.named_groups import DihedralGroup\n    >>> D = DihedralGroup(4)\n    >>> _naive_list_centralizer(D, D)\n    [Permutation([0, 1, 2, 3]), Permutation([2, 3, 0, 1])]\n\n    See Also\n    ========\n\n    sympy.combinatorics.perm_groups.centralizer\n\n    ' #NEWLINE# from sympy.combinatorics.permutations import _af_commutes_with #NEWLINE# if hasattr ( other , 'generators' ) : #NEWLINE# #INDENT# elements = list ( self . generate_dimino ( af = True ) ) #NEWLINE# gens = [ x . _array_form for x in other . generators ] #NEWLINE# commutes_with_gens = ( lambda x : all ( ( _af_commutes_with ( x , gen ) for gen in gens ) ) ) #NEWLINE# centralizer_list = [ ] #NEWLINE# if ( not af ) : #NEWLINE# #INDENT# for element in elements : #NEWLINE# #INDENT# if commutes_with_gens ( element ) : #NEWLINE# #INDENT# centralizer_list . append ( Permutation . _af_new ( element ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for element in elements : #NEWLINE# #INDENT# if commutes_with_gens ( element ) : #NEWLINE# #INDENT# centralizer_list . append ( element ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return centralizer_list #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( other , 'getitem' ) : #NEWLINE# #INDENT# return _naive_list_centralizer ( self , PermutationGroup ( elements ) , af ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( other , 'array_form' ) : #NEWLINE# #INDENT# return _naive_list_centralizer ( self , PermutationGroup ( [ other ] ) , af )