class_docstr: Double excitation rotation.
  
  This operation performs an :math:`SO(2)` rotation in the two-dimensional subspace :math:`\{
  |1100\rangle,|0011\rangle\}`. More precisely, it performs the transformation
  
  .. math::
  
      &|0011\rangle \rightarrow \cos(\phi/2) |0011\rangle + \sin(\phi/2) |1100\rangle\\
      &|1100\rangle \rightarrow \cos(\phi/2) |1100\rangle - \sin(\phi/2) |0011\rangle,
  
  while leaving all other basis states unchanged.
  
  The name originates from the occupation-number representation of fermionic wavefunctions, where
  the transformation from :math:`|1100\rangle` to :math:`|0011\rangle` is interpreted as
  "exciting" two particles from the first pair of qubits to the second pair of qubits.
  
  **Details:**
  
  * Number of wires: 4
  * Number of parameters: 1
  * Number of dimensions per parameter: (0,)
  * Gradient recipe: The ``DoubleExcitation`` operator satisfies a four-term parameter-shift rule
    (see Appendix F, https://doi.org/10.1088/1367-2630/ac2cb3):
  
  Args:
      phi (float): rotation angle :math:`\phi`
      wires (Sequence[int]): the wires the operation acts on
      id (str or None): String representing the operation (optional)
  
  **Example**
  
  The following circuit performs the transformation :math:`|1100\rangle\rightarrow \cos(
  \phi/2)|1100\rangle - \sin(\phi/2)|0011\rangle)`:
  
  .. code-block::
  
      dev = qml.device('default.qubit', wires=4)
  
      @qml.qnode(dev)
      def circuit(phi):
          qml.PauliX(wires=0)
          qml.PauliX(wires=1)
          qml.DoubleExcitation(phi, wires=[0, 1, 2, 3])
          return qml.state()
  
      circuit(0.1)
class_docstr_tok: ["Double","excitation","rotation",".","This","operation","performs","an",":","math",":","`","SO","(","2",")","`","rotation","in","the","two-dimensional","subspace",":","math",":","`","\\","{","|1100\\rangle",",","|0011\\rangle\\","}","`",".","More","precisely",",","it","performs","the","transformation","..","math",":",":","&","|0011\\rangle","\\rightarrow","\\cos","(","\\phi\/2",")","|0011\\rangle","+","\\sin","(","\\phi\/2",")","|1100\\rangle\\\\","&","|1100\\rangle","\\rightarrow","\\cos","(","\\phi\/2",")","|1100\\rangle","-","\\sin","(","\\phi\/2",")","|0011\\rangle",",","while","leaving","all","other","basis","states","unchanged",".","The","name","originates","from","the","occupation-number","representation","of","fermionic","wavefunctions",",","where","the","transformation","from",":","math",":","`","|1100\\rangle","`","to",":","math",":","`","|0011\\rangle","`","is","interpreted","as","''","exciting","''","two","particles","from","the","first","pair","of","qubits","to","the","second","pair","of","qubits",".","*","*","Details",":","*","*","*","Number","of","wires",":","4","*","Number","of","parameters",":","1","*","Number","of","dimensions","per","parameter",":","(","0",",",")","*","Gradient","recipe",":","The","``","DoubleExcitation","``","operator","satisfies","a","four-term","parameter-shift","rule","(","see","Appendix","F",",","https",":","\/\/doi.org\/10.1088\/1367-2630\/ac2cb3",")",":","Args",":","phi","(","float",")",":","rotation","angle",":","math",":","`","\\phi","`","wires","(","Sequence","[","int","]",")",":","the","wires","the","operation","acts","on","id","(","str","or","None",")",":","String","representing","the","operation","(","optional",")","*","*","Example","*","*","The","following","circuit","performs","the","transformation",":","math",":","`","|1100\\rangle\\rightarrow","\\cos","(","\\phi\/2",")","|1100\\rangle","-","\\sin","(","\\phi\/2",")","|0011\\rangle",")","`",":","..","code-block",":",":","dev","=","qml.device","(","'default.qubit","'",",","wires=4",")","@","qml.qnode","(","dev",")","def","circuit","(","phi",")",":","qml.PauliX","(","wires=0",")","qml.PauliX","(","wires=1",")","qml.DoubleExcitation","(","phi",",","wires=","[","0",",","1",",","2",",","3","]",")","return","qml.state","(",")","circuit","(","0.1",")"]
docstr: Representation of the operator as a product of other operators (static method). :
  
  .. math:: O = O_1 O_2 \dots O_n.
  
  
  .. seealso:: :meth:`~.DoubleExcitation.decomposition`.
  
  For the source of this decomposition, see page 17 of
  `"Local, Expressive, Quantum-Number-Preserving VQE Ansatze for Fermionic Systems" <https://doi.org/10.1088/1367-2630/ac2cb3>`_ .
  
  Args:
      phi (float): rotation angle :math:`\phi`
      wires (Iterable, Wires): wires that the operator acts on
  
  Returns:
      list[Operator]: decomposition into lower level operations
  
  **Example:**
  
  >>> qml.DoubleExcitation.compute_decomposition(1.23, wires=(0,1,2,3))
  [CNOT(wires=[2, 3]),
  CNOT(wires=[0, 2]),
  Hadamard(wires=[3]),
  Hadamard(wires=[0]),
  CNOT(wires=[2, 3]),
  CNOT(wires=[0, 1]),
  RY(0.15375, wires=[1]),
  RY(-0.15375, wires=[0]),
  CNOT(wires=[0, 3]),
  Hadamard(wires=[3]),
  CNOT(wires=[3, 1]),
  RY(0.15375, wires=[1]),
  RY(-0.15375, wires=[0]),
  CNOT(wires=[2, 1]),
  CNOT(wires=[2, 0]),
  RY(-0.15375, wires=[1]),
  RY(0.15375, wires=[0]),
  CNOT(wires=[3, 1]),
  Hadamard(wires=[3]),
  CNOT(wires=[0, 3]),
  RY(-0.15375, wires=[1]),
  RY(0.15375, wires=[0]),
  CNOT(wires=[0, 1]),
  CNOT(wires=[2, 0]),
  Hadamard(wires=[0]),
  Hadamard(wires=[3]),
  CNOT(wires=[0, 2]),
  CNOT(wires=[2, 3])]
docstr_tok: ["Representation","of","the","operator","as","a","product","of","other","operators","(","static","method",")",".",":","..","math",":",":","O","=","O_1","O_2","\\dots","O_n",".","..","seealso",":",":",":","meth",":","`","~.DoubleExcitation.decomposition","`",".","For","the","source","of","this","decomposition",",","see","page","17","of","`","``","Local",",","Expressive",",","Quantum-Number-Preserving","VQE","Ansatze","for","Fermionic","Systems","''","<","https",":","\/\/doi.org\/10.1088\/1367-2630\/ac2cb3",">","`","_",".","Args",":","phi","(","float",")",":","rotation","angle",":","math",":","`","\\phi","`","wires","(","Iterable",",","Wires",")",":","wires","that","the","operator","acts","on","Returns",":","list","[","Operator","]",":","decomposition","into","lower","level","operations","*","*","Example",":","*","*",">",">",">","qml.DoubleExcitation.compute_decomposition","(","1.23",",","wires=","(","0,1,2,3",")",")","[","CNOT","(","wires=","[","2",",","3","]",")",",","CNOT","(","wires=","[","0",",","2","]",")",",","Hadamard","(","wires=","[","3","]",")",",","Hadamard","(","wires=","[","0","]",")",",","CNOT","(","wires=","[","2",",","3","]",")",",","CNOT","(","wires=","[","0",",","1","]",")",",","RY","(","0.15375",",","wires=","[","1","]",")",",","RY","(","-0.15375",",","wires=","[","0","]",")",",","CNOT","(","wires=","[","0",",","3","]",")",",","Hadamard","(","wires=","[","3","]",")",",","CNOT","(","wires=","[","3",",","1","]",")",",","RY","(","0.15375",",","wires=","[","1","]",")",",","RY","(","-0.15375",",","wires=","[","0","]",")",",","CNOT","(","wires=","[","2",",","1","]",")",",","CNOT","(","wires=","[","2",",","0","]",")",",","RY","(","-0.15375",",","wires=","[","1","]",")",",","RY","(","0.15375",",","wires=","[","0","]",")",",","CNOT","(","wires=","[","3",",","1","]",")",",","Hadamard","(","wires=","[","3","]",")",",","CNOT","(","wires=","[","0",",","3","]",")",",","RY","(","-0.15375",",","wires=","[","1","]",")",",","RY","(","0.15375",",","wires=","[","0","]",")",",","CNOT","(","wires=","[","0",",","1","]",")",",","CNOT","(","wires=","[","2",",","0","]",")",",","Hadamard","(","wires=","[","0","]",")",",","Hadamard","(","wires=","[","3","]",")",",","CNOT","(","wires=","[","0",",","2","]",")",",","CNOT","(","wires=","[","2",",","3","]",")","]"]
code: def compute_decomposition(phi, wires):
      r"""Representation of the operator as a product of other operators (static method). :
  
      .. math:: O = O_1 O_2 \dots O_n.
  
  
      .. seealso:: :meth:`~.DoubleExcitation.decomposition`.
  
      For the source of this decomposition, see page 17 of
      `"Local, Expressive, Quantum-Number-Preserving VQE Ansatze for Fermionic Systems" <https://doi.org/10.1088/1367-2630/ac2cb3>`_ .
  
      Args:
          phi (float): rotation angle :math:`\phi`
          wires (Iterable, Wires): wires that the operator acts on
  
      Returns:
          list[Operator]: decomposition into lower level operations
  
      **Example:**
  
      >>> qml.DoubleExcitation.compute_decomposition(1.23, wires=(0,1,2,3))
      [CNOT(wires=[2, 3]),
      CNOT(wires=[0, 2]),
      Hadamard(wires=[3]),
      Hadamard(wires=[0]),
      CNOT(wires=[2, 3]),
      CNOT(wires=[0, 1]),
      RY(0.15375, wires=[1]),
      RY(-0.15375, wires=[0]),
      CNOT(wires=[0, 3]),
      Hadamard(wires=[3]),
      CNOT(wires=[3, 1]),
      RY(0.15375, wires=[1]),
      RY(-0.15375, wires=[0]),
      CNOT(wires=[2, 1]),
      CNOT(wires=[2, 0]),
      RY(-0.15375, wires=[1]),
      RY(0.15375, wires=[0]),
      CNOT(wires=[3, 1]),
      Hadamard(wires=[3]),
      CNOT(wires=[0, 3]),
      RY(-0.15375, wires=[1]),
      RY(0.15375, wires=[0]),
      CNOT(wires=[0, 1]),
      CNOT(wires=[2, 0]),
      Hadamard(wires=[0]),
      Hadamard(wires=[3]),
      CNOT(wires=[0, 2]),
      CNOT(wires=[2, 3])]
  
      """
      # This decomposition is the "upside down" version of that on p17 of https://arxiv.org/abs/2104.05695
      decomp_ops = [
          qml.CNOT(wires=[wires[2], wires[3]]),
          qml.CNOT(wires=[wires[0], wires[2]]),
          qml.Hadamard(wires=wires[3]),
          qml.Hadamard(wires=wires[0]),
          qml.CNOT(wires=[wires[2], wires[3]]),
          qml.CNOT(wires=[wires[0], wires[1]]),
          qml.RY(phi / 8, wires=wires[1]),
          qml.RY(-phi / 8, wires=wires[0]),
          qml.CNOT(wires=[wires[0], wires[3]]),
          qml.Hadamard(wires=wires[3]),
          qml.CNOT(wires=[wires[3], wires[1]]),
          qml.RY(phi / 8, wires=wires[1]),
          qml.RY(-phi / 8, wires=wires[0]),
          qml.CNOT(wires=[wires[2], wires[1]]),
          qml.CNOT(wires=[wires[2], wires[0]]),
          qml.RY(-phi / 8, wires=wires[1]),
          qml.RY(phi / 8, wires=wires[0]),
          qml.CNOT(wires=[wires[3], wires[1]]),
          qml.Hadamard(wires=wires[3]),
          qml.CNOT(wires=[wires[0], wires[3]]),
          qml.RY(-phi / 8, wires=wires[1]),
          qml.RY(phi / 8, wires=wires[0]),
          qml.CNOT(wires=[wires[0], wires[1]]),
          qml.CNOT(wires=[wires[2], wires[0]]),
          qml.Hadamard(wires=wires[0]),
          qml.Hadamard(wires=wires[3]),
          qml.CNOT(wires=[wires[0], wires[2]]),
          qml.CNOT(wires=[wires[2], wires[3]]),
      ]
  
      return decomp_ops
  
imports: import functools
  import numpy
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane.operation import Operation
label_desc: Use image node_id 5 for calling the DoubleExcitation obj's underlying member method code with example usage: obj.compute_decomposition(phi, wires) and returns: decomp_ops