class_docstr: A global phase operation that multiplies all components of the state by :math:`e^{-i \phi}`.
  
  **Details:**
  
  * Number of wires: All (the operation acts on all wires)
  * Number of parameters: 1
  * Gradient recipe: None
  
  Args:
      phi (TensorLike): the global phase
      wires (Iterable[Any] or Any): unused argument - the operator is applied to all wires
      id (str): custom label given to an operator instance,
          can be useful for some applications where the instance has to be identified.
  
  **Example**
  
  .. code-block:: python3
  
      dev = qml.device("default.qubit", wires=2)
  
      @qml.qnode(dev)
      def circuit(phi=None, return_state=False):
          qml.PauliX(0)
          if phi:
              qml.GlobalPhase(phi)
          if return_state:
              return qml.state()
          return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))
  
  The circuit yields the same expectation values with and without the global phase:
  
  >>> circuit()
  (tensor(-1., requires_grad=True), tensor(1., requires_grad=True))
  >>> circuit(phi=0.123)
  (tensor(-1., requires_grad=True), tensor(1., requires_grad=True))
  
  However, the states of the two systems differ by a global phase factor:
  
  >>> circuit(return_state=True)
  tensor([0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j], requires_grad=True)
  >>> circuit(return_state=True, phi=0.123)
  tensor([0.        +0.j        , 0.        +0.j        ,
          0.99244503-0.12269009j, 0.        +0.j        ], requires_grad=True)
  
  The operator can be applied with a control to create a relative phase between terms:
  
  .. code-block:: python3
  
      @qml.qnode(dev)
      def circuit():
          qml.Hadamard(0)
          qml.ctrl(qml.GlobalPhase(0.123), 0)
          return qml.state()
  
      >>> circuit()
      tensor([0.70710678+0.j        , 0.        +0.j        ,
              0.70176461-0.08675499j, 0.        +0.j        ], requires_grad=True)
class_docstr_tok: ["A","global","phase","operation","that","multiplies","all","components","of","the","state","by",":","math",":","`","e^","{","-i","\\phi","}","`",".","*","*","Details",":","*","*","*","Number","of","wires",":","All","(","the","operation","acts","on","all","wires",")","*","Number","of","parameters",":","1","*","Gradient","recipe",":","None","Args",":","phi","(","TensorLike",")",":","the","global","phase","wires","(","Iterable","[","Any","]","or","Any",")",":","unused","argument","-","the","operator","is","applied","to","all","wires","id","(","str",")",":","custom","label","given","to","an","operator","instance",",","can","be","useful","for","some","applications","where","the","instance","has","to","be","identified",".","*","*","Example","*","*","..","code-block",":",":","python3","dev","=","qml.device","(","``","default.qubit","''",",","wires=2",")","@","qml.qnode","(","dev",")","def","circuit","(","phi=None",",","return_state=False",")",":","qml.PauliX","(","0",")","if","phi",":","qml.GlobalPhase","(","phi",")","if","return_state",":","return","qml.state","(",")","return","qml.expval","(","qml.PauliZ","(","0",")",")",",","qml.expval","(","qml.PauliZ","(","1",")",")","The","circuit","yields","the","same","expectation","values","with","and","without","the","global","phase",":",">",">",">","circuit","(",")","(","tensor","(","-1.",",","requires_grad=True",")",",","tensor","(","1.",",","requires_grad=True",")",")",">",">",">","circuit","(","phi=0.123",")","(","tensor","(","-1.",",","requires_grad=True",")",",","tensor","(","1.",",","requires_grad=True",")",")","However",",","the","states","of","the","two","systems","differ","by","a","global","phase","factor",":",">",">",">","circuit","(","return_state=True",")","tensor","(","[","0.+0.j",",","0.+0.j",",","1.+0.j",",","0.+0.j","]",",","requires_grad=True",")",">",">",">","circuit","(","return_state=True",",","phi=0.123",")","tensor","(","[","0",".","+0.j",",","0",".","+0.j",",","0.99244503-0.12269009j",",","0",".","+0.j","]",",","requires_grad=True",")","The","operator","can","be","applied","with","a","control","to","create","a","relative","phase","between","terms",":","..","code-block",":",":","python3","@","qml.qnode","(","dev",")","def","circuit","(",")",":","qml.Hadamard","(","0",")","qml.ctrl","(","qml.GlobalPhase","(","0.123",")",",","0",")","return","qml.state","(",")",">",">",">","circuit","(",")","tensor","(","[","0.70710678+0.j",",","0",".","+0.j",",","0.70176461-0.08675499j",",","0",".","+0.j","]",",","requires_grad=True",")"]
docstr: Representation of the operator as a canonical matrix in the computational basis (static method).
  The canonical matrix is the textbook matrix representation that does not consider wires.
  Implicitly, this assumes that the wires of the operator correspond to the global wire order.
  
  .. seealso:: :meth:`~.GlobalPhase.matrix`
  
  Returns:
      ndarray: matrix
  
  **Example**
  
  >>> qml.GlobalPhase.compute_matrix(np.pi/4, n_wires=1)
  array([[0.70710678-0.70710678j, 0.        +0.j        ],
         [0.        +0.j        , 0.70710678-0.70710678j]])
docstr_tok: ["Representation","of","the","operator","as","a","canonical","matrix","in","the","computational","basis","(","static","method",")",".","The","canonical","matrix","is","the","textbook","matrix","representation","that","does","not","consider","wires",".","Implicitly",",","this","assumes","that","the","wires","of","the","operator","correspond","to","the","global","wire","order",".","..","seealso",":",":",":","meth",":","`","~.GlobalPhase.matrix","`","Returns",":","ndarray",":","matrix","*","*","Example","*","*",">",">",">","qml.GlobalPhase.compute_matrix","(","np.pi\/4",",","n_wires=1",")","array","(","[","[","0.70710678-0.70710678j",",","0",".","+0.j","]",",","[","0",".","+0.j",",","0.70710678-0.70710678j","]","]",")"]
code: def compute_matrix(
      phi, n_wires=1
  ):  # pylint: disable=arguments-differ
      r"""Representation of the operator as a canonical matrix in the computational basis (static method).
      The canonical matrix is the textbook matrix representation that does not consider wires.
      Implicitly, this assumes that the wires of the operator correspond to the global wire order.
  
      .. seealso:: :meth:`~.GlobalPhase.matrix`
  
      Returns:
          ndarray: matrix
  
      **Example**
  
      >>> qml.GlobalPhase.compute_matrix(np.pi/4, n_wires=1)
      array([[0.70710678-0.70710678j, 0.        +0.j        ],
             [0.        +0.j        , 0.70710678-0.70710678j]])
      """
      interface = qml.math.get_interface(phi)
      if interface == "tensorflow":
          return qml.math.exp(
              -1j * qml.math.cast(phi, complex)
          ) * qml.math.eye(int(2**n_wires))
      return qml.math.exp(
          -1j * qml.math.cast(phi, complex)
      ) * qml.math.eye(int(2**n_wires), like=interface)
  
imports: from functools import lru_cache
  from scipy import sparse
  import pennylane
  from pennylane.operation import AnyWires, AllWires, CVObservable, Operation
label_desc: Use image node_id 3 for calling the GlobalPhase obj's underlying member method code with example usage: obj.compute_matrix(phi, n_wires) and returns: unknown, unknown