class_docstr: Tests specific to the ControlledQubitUnitary operation
class_docstr_tok: ["Tests","specific","to","the","ControlledQubitUnitary","operation"]
docstr: Test that the matrix representation is defined correctly
docstr_tok: ["Test","that","the","matrix","representation","is","defined","correctly"]
code: def test_matrix_representation_broadcasted(self, tol):
      """Test that the matrix representation is defined correctly"""
      U = np.array(
          [
              [[0.94877869, 0.31594146], [-0.31594146, 0.94877869]],
              [[0.4125124, -0.91095199], [0.91095199, 0.4125124]],
              [[0.31594146, 0.94877869j], [0.94877869j, 0.31594146]],
          ]
      )
  
      res_dynamic = qml.ControlledQubitUnitary(
          U, control_wires=[1], wires=0
      ).matrix()
      expected = np.array(
          [
              [
                  [1.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j],
                  [0.0 + 0.0j, 1.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j],
                  [
                      0.0 + 0.0j,
                      0.0 + 0.0j,
                      0.94877869 + 0.0j,
                      0.31594146 + 0.0j,
                  ],
                  [
                      0.0 + 0.0j,
                      0.0 + 0.0j,
                      -0.31594146 + 0.0j,
                      0.94877869 + 0.0j,
                  ],
              ],
              [
                  [1.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j],
                  [0.0 + 0.0j, 1.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j],
                  [
                      0.0 + 0.0j,
                      0.0 + 0.0j,
                      0.4125124 + 0.0j,
                      -0.91095199 + 0.0j,
                  ],
                  [
                      0.0 + 0.0j,
                      0.0 + 0.0j,
                      0.91095199 + 0.0j,
                      0.4125124 + 0.0j,
                  ],
              ],
              [
                  [1.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j],
                  [0.0 + 0.0j, 1.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j],
                  [
                      0.0 + 0.0j,
                      0.0 + 0.0j,
                      0.31594146 + 0.0j,
                      0.0 + 0.94877869j,
                  ],
                  [
                      0.0 + 0.0j,
                      0.0 + 0.0j,
                      0.0 + 0.94877869j,
                      0.31594146 + 0.0j,
                  ],
              ],
          ]
      )
      assert np.allclose(res_dynamic, expected, atol=tol)
  
imports: import copy
  import numpy
  import pytest
  from scipy.linalg import fractional_matrix_power
  from scipy.sparse import csr_matrix
  from scipy.stats import unitary_group
  from gate_data import CY, CZ
  import pennylane
  from pennylane.wires import Wires
  from pennylane.operation import AnyWires
  from pennylane.ops.qubit.matrix_ops import QubitUnitary
label_desc: Use image node_id 13 for calling the TestControlledQubitUnitary obj's underlying member method code with example usage: obj.test_matrix_representation_broadcasted(tol) without return types