class_docstr: Tests for the qft operations
docstr: Test that the matrix representation is correct.
docstr_tok: ["Test","that","the","matrix","representation","is","correct","."]
code: def test_matrix(self, tol):
      """Test that the matrix representation is correct."""
  
      res_static = qml.QFT.compute_matrix(2)
      res_dynamic = qml.QFT(wires=[0, 1]).matrix()
      res_reordered = qml.QFT(wires=[0, 1]).matrix([1, 0])
  
      expected = np.array(
          [
              [0.5 + 0.0j, 0.5 + 0.0j, 0.5 + 0.0j, 0.5 + 0.0j],
              [0.5 + 0.0j, 0.0 + 0.5j, -0.5 + 0.0j, -0.0 - 0.5j],
              [0.5 + 0.0j, -0.5 + 0.0j, 0.5 - 0.0j, -0.5 + 0.0j],
              [0.5 + 0.0j, -0.0 - 0.5j, -0.5 + 0.0j, 0.0 + 0.5j],
          ]
      )
  
      assert np.allclose(res_static, expected, atol=tol, rtol=0)
      assert np.allclose(res_dynamic, expected, atol=tol, rtol=0)
  
      expected_permuted = [
          [0.5 + 0.0j, 0.5 + 0.0j, 0.5 + 0.0j, 0.5 + 0.0j],
          [0.5 + 0.0j, 0.5 - 0.0j, -0.5 + 0.0j, -0.5 + 0.0j],
          [0.5 + 0.0j, -0.5 + 0.0j, 0.0 + 0.5j, -0.0 - 0.5j],
          [0.5 + 0.0j, -0.5 + 0.0j, -0.0 - 0.5j, 0.0 + 0.5j],
      ]
      assert np.allclose(
          res_reordered, expected_permuted, atol=tol, rtol=0
      )
  
file_path: pennylane/tests/templates/test_subroutines/test_qft.py
imports: import pytest
  import numpy
  from gate_data import QFT
  import pennylane
label_desc: Use image node_id 4 for calling the TestQFT obj's underlying member method code with example usage: obj.test_matrix(tol) without return types