qml.utils.expand

expand(matrix, original_wires, expanded_wires)[source]

Expand a an operator matrix to more wires.

Parameters
  • matrix (array) – \(2^n \times 2^n\) matrix where n = len(original_wires).

  • original_wires (Sequence[int]) – original wires of matrix

  • expanded_wires (Union[Sequence[int], int]) – expanded wires of matrix, can be shuffled. If a single int m is given, corresponds to list(range(m))

Returns

\(2^m \times 2^m\) matrix where m = len(expanded_wires).

Return type

array