direct_sum#

direct_sum(reps, name=None, change_of_basis=None)[source]#

Return the direct sum \(\rho=\bigoplus_i \rho_i\) of representations.

If name is not provided, the function builds one by run-length encoding consecutive repeated names:

  • [rep_1, rep_1, rep_2, rep_1] -> "(rep_1 x 2)⊕rep_2⊕rep_1"

This preserves order and makes repeated contiguous blocks explicit.

Parameters:
  • reps (list[Representation]) – Summands in the direct sum.

  • name (str, optional) – Name of the resulting representation. Auto-generated when None.

  • change_of_basis (ndarray, optional) – Optional change of basis for the resulting representation.

Returns:

Direct-sum representation with attributes["direct_sum_reps"] set.

Return type:

Representation