class_docstr: Observable corresponding to the state projector :math:`P=\ket{\phi}\bra{\phi}`, where
  :math:`\phi` denotes a state.
class_docstr_tok: ["Observable","corresponding","to","the","state","projector",":","math",":","`","P=\\ket","{","\\phi","}","\\bra","{","\\phi","}","`",",","where",":","math",":","`","\\phi","`","denotes","a","state","."]
docstr: Sequence of gates that diagonalize the operator in the computational basis (static method).
  
  Given the eigendecomposition :math:`O = U \Sigma U^{\dagger}` where
  :math:`\Sigma` is a diagonal matrix containing the eigenvalues,
  the sequence of diagonalizing gates implements the unitary :math:`U^{\dagger}`.
  
  The diagonalizing gates rotate the state into the eigenbasis
  of the operator.
  
  .. seealso:: :meth:`~.StateVectorProjector.diagonalizing_gates`.
  
  Args:
      state_vector (Iterable): state vector that the operator projects on.
      wires (Iterable[Any], Wires): wires that the operator acts on.
  Returns:
      list[.Operator]: list of diagonalizing gates.
  
  **Example**
  
  >>> state_vector = np.array([1., 1j])/np.sqrt(2)
  >>> StateVectorProjector.compute_diagonalizing_gates(state_vector, wires=[0])
  [QubitUnitary(array([[ 0.70710678+0.j        ,  0.        -0.70710678j],
                       [ 0.        +0.70710678j, -0.70710678+0.j        ]]), wires=[0])]
docstr_tok: ["Sequence","of","gates","that","diagonalize","the","operator","in","the","computational","basis","(","static","method",")",".","Given","the","eigendecomposition",":","math",":","`","O","=","U","\\Sigma","U^","{","\\dagger","}","`","where",":","math",":","`","\\Sigma","`","is","a","diagonal","matrix","containing","the","eigenvalues",",","the","sequence","of","diagonalizing","gates","implements","the","unitary",":","math",":","`","U^","{","\\dagger","}","`",".","The","diagonalizing","gates","rotate","the","state","into","the","eigenbasis","of","the","operator",".","..","seealso",":",":",":","meth",":","`","~.StateVectorProjector.diagonalizing_gates","`",".","Args",":","state_vector","(","Iterable",")",":","state","vector","that","the","operator","projects","on",".","wires","(","Iterable","[","Any","]",",","Wires",")",":","wires","that","the","operator","acts","on",".","Returns",":","list","[",".Operator","]",":","list","of","diagonalizing","gates",".","*","*","Example","*","*",">",">",">","state_vector","=","np.array","(","[","1.",",","1j","]",")","\/np.sqrt","(","2",")",">",">",">","StateVectorProjector.compute_diagonalizing_gates","(","state_vector",",","wires=","[","0","]",")","[","QubitUnitary","(","array","(","[","[","0.70710678+0.j",",","0",".","-0.70710678j","]",",","[","0",".","+0.70710678j",",","-0.70710678+0.j","]","]",")",",","wires=","[","0","]",")","]"]
code: def compute_diagonalizing_gates(
      state_vector, wires
  ):  # pylint: disable=arguments-differ,unused-argument,arguments-renamed
      r"""Sequence of gates that diagonalize the operator in the computational basis (static method).
  
      Given the eigendecomposition :math:`O = U \Sigma U^{\dagger}` where
      :math:`\Sigma` is a diagonal matrix containing the eigenvalues,
      the sequence of diagonalizing gates implements the unitary :math:`U^{\dagger}`.
  
      The diagonalizing gates rotate the state into the eigenbasis
      of the operator.
  
      .. seealso:: :meth:`~.StateVectorProjector.diagonalizing_gates`.
  
      Args:
          state_vector (Iterable): state vector that the operator projects on.
          wires (Iterable[Any], Wires): wires that the operator acts on.
      Returns:
          list[.Operator]: list of diagonalizing gates.
  
      **Example**
  
      >>> state_vector = np.array([1., 1j])/np.sqrt(2)
      >>> StateVectorProjector.compute_diagonalizing_gates(state_vector, wires=[0])
      [QubitUnitary(array([[ 0.70710678+0.j        ,  0.        -0.70710678j],
                           [ 0.        +0.70710678j, -0.70710678+0.j        ]]), wires=[0])]
      """
      # Adapting the approach discussed in the link below to work with arbitrary complex-valued state vectors.
      # Alternatively, we could take the adjoint of the Mottonen decomposition for the state vector.
      # https://quantumcomputing.stackexchange.com/questions/10239/how-can-i-fill-a-unitary-knowing-only-its-first-column
      phase = qml.math.exp(-1j * qml.math.angle(state_vector[0]))
      psi = phase * state_vector
      denominator = qml.math.sqrt(2 + 2 * psi[0])
      psi = qml.math.set_index(
          psi, 0, psi[0] + 1
      )  # psi[0] += 1, but JAX-JIT compatible
      psi /= denominator
      u = 2 * qml.math.outer(psi, qml.math.conj(psi)) - qml.math.eye(
          len(psi)
      )
      return [QubitUnitary(u, wires=wires)]
  
imports: from copy import copy
  from collections.abc import Sequence
  import numpy
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane.operation import AnyWires, Observable, Operation
  from pennylane.wires import Wires
  from .matrix_ops import QubitUnitary
label_desc: Use image node_id 6 for calling the StateVectorProjector obj's underlying member method code with example usage: obj.compute_diagonalizing_gates(state_vector, wires) and returns: list