  
  [1X6 [33X[0;0YCentralizer (commutant) rings[133X[101X
  
  
  [1X6.1 [33X[0;0YFinding a basis for the centralizer[133X[101X
  
  [1X6.1-1 CentralizerBlocksOfRepresentation[101X
  
  [33X[1;0Y[29X[2XCentralizerBlocksOfRepresentation[102X( [3Xrho[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YList  of  vector  space  generators  for  the  centralizer ring of
            [23X\rho(G)[123X,      written      in      the      basis     given     by
            [2XBlockDiagonalBasisOfRepresentation[102X ([14X5.1-1[114X). The matrices are given
            as a list of blocks.[133X
  
  [33X[0;0YLet  [23XG[123X  have irreducible representations [23X\rho_i[123X with multiplicities [23Xm_i[123X. The
  centralizer  has  dimension  [23X\sum_i m_i^2[123X as a [23X\mathbb{C}[123X-vector space. This
  function gives the minimal number of generators required.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XG := DihedralGroup(8);;[127X[104X
    [4X[25Xgap>[125X [27Xirreps := IrreducibleRepresentations(G);;[127X[104X
    [4X[25Xgap>[125X [27X# rho is the sum of two isomorphic degree 1 irreps, and a degree[127X[104X
    [4X[25X>[125X [27X# 2 irrep.[127X[104X
    [4X[25X>[125X [27Xrho := DirectSumOfRepresentations([irreps[4], irreps[4], irreps[5]]);;[127X[104X
    [4X[25Xgap>[125X [27X# Compute a basis for the centralizer (in blocks)[127X[104X
    [4X[25X>[125X [27Xcent_basis_blocks := CentralizerBlocksOfRepresentation(rho);;[127X[104X
    [4X[25Xgap>[125X [27X# Verify that the dimension is the sum of the multiplicities squared,[127X[104X
    [4X[25X>[125X [27X# in this case 2^2 + 1 = 5.[127X[104X
    [4X[25X>[125X [27XLength(cent_basis_blocks) = 5;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X6.1-2 CentralizerOfRepresentation[101X
  
  [33X[1;0Y[29X[2XCentralizerOfRepresentation[102X( [3Xarg[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YList  of  vector  space  generators  for  the  centralizer ring of
            [23X\rho(G)[123X.[133X
  
  [33X[0;0YThis gives the same result as [2XCentralizerBlocksOfRepresentation[102X ([14X6.1-1[114X), but
  with  the  matrices  given in their entirety: not as lists of blocks, but as
  full matrices.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27X# This is the actual basis for the centralizer.[127X[104X
    [4X[25X>[125X [27Xcent_basis := CentralizerOfRepresentation(rho);;[127X[104X
    [4X[25Xgap>[125X [27X# All matrices in the span should commute with the image of rho.[127X[104X
    [4X[25X>[125X [27XForAll(G, g -> ForAll(cent_basis, M -> Image(rho, g)*M = M*Image(rho,g)));[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  
  [1X6.2 [33X[0;0YUsing the centralizer for computations[133X[101X
  
  [1X6.2-1 ClassSumCentralizer[101X
  
  [33X[1;0Y[29X[2XClassSumCentralizer[102X( [3Xrho[103X, [3Xclass[103X, [3Xcent_basis[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[23X\sum_{s  \in  t^G}  \rho(s)[123X,  where  [23Xt[123X  is a representative of the
            conjugacy class [3Xclass[103X of [23XG[123X.[133X
  
  [33X[0;0YWe  require  that  [3Xrho[103X  is  unitary.  Uses the given orthonormal basis (with
  respect  to the inner product [23X\langle A, B \rangle = \mbox{Trace}(AB^*)[123X) for
  the  centralizer  ring  of  [3Xrho[103X  to calculate the sum of the conjugacy class
  [3Xclass[103X quickly, i.e. without summing over the class.[133X
  
  [33X[0;0YNOTE:  Orthonormality  of  [3Xcent_basis[103X  and unitarity of [3Xrho[103X are checked. See
  [2XClassSumCentralizerNC[102X ([14X6.2-2[114X) for a version of this function without checks.
  The checks are not very expensive, so it is recommended you use the function
  with checks.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27X# Now we have a basis for the centralizer, we can sum a conjugacy class[127X[104X
    [4X[25X>[125X [27X# of G.[127X[104X
    [4X[25X>[125X [27Xclass := List(ConjugacyClasses(G)[3]);;[127X[104X
    [4X[25Xgap>[125X [27X# We can do the computation naively, with no centralizer basis given:[127X[104X
    [4X[25X>[125X [27Xsum1 := ClassSumCentralizer(rho, class, fail);;[127X[104X
    [4X[25Xgap>[125X [27X# Before summing with th centralizer basis given, we need to[127X[104X
    [4X[25X>[125X [27X# orthonormalize it. It's already orthogonal, but not normal:[127X[104X
    [4X[25X>[125X [27Xorth_basis := OrthonormalBasis@RepnDecomp(cent_basis);;[127X[104X
    [4X[25Xgap>[125X [27XIsOrthonormalSet(orth_basis, InnerProduct@RepnDecomp);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27X# And with the centralizer given, should be more efficient in certain[127X[104X
    [4X[25X>[125X [27X# cases (small degree, low multiplicities, but very large group)[127X[104X
    [4X[25X>[125X [27Xsum2 := ClassSumCentralizer(rho, class, orth_basis);;[127X[104X
    [4X[25Xgap>[125X [27X# Should be the same:[127X[104X
    [4X[25X>[125X [27Xsum1 = sum2;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X6.2-2 ClassSumCentralizerNC[101X
  
  [33X[1;0Y[29X[2XClassSumCentralizerNC[102X( [3Xrho[103X, [3Xclass[103X, [3Xcent_basis[103X ) [32X function[133X
  
  [33X[0;0YThe  same  as  [2XClassSumCentralizer[102X ([14X6.2-1[114X), but does not check the basis for
  orthonormality or the representation for unitarity.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27X# The very same as the above, but with no checks on orthonormality.[127X[104X
    [4X[25X>[125X [27Xsum3 := ClassSumCentralizerNC(rho, class, orth_basis);;[127X[104X
    [4X[25Xgap>[125X [27Xsum1 = sum3;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
