class_docstr: Creates a sequence of controlled gates raised to decreasing powers of 2. Can be used as
  a sub-block in building a `quantum phase estimation <https://en.wikipedia.org/wiki/Quantum_phase_estimation_algorithm>`__
  circuit.
  
  Given an :class:`~.Operator` and a list of control wires, this template creates a sequence of
  controlled gates, one for each control wire, with the base :class:`~.Operator` raised to
  decreasing powers of 2:
  
  .. figure:: ../../_static/templates/subroutines/big_ctrl.png
      :align: center
      :width: 40%
      :target: javascript:void(0);
  
  Args:
      base (Operator): the phase estimation unitary, specified as an :class:`~.Operator`
      control (Union[Wires, Sequence[int], or int]): the wires to be used for control
  
  Raises:
      ValueError: if the wires in ``control`` and wires on the ``base`` operator share a common
          element
  
  .. seealso:: :class:`~.QuantumPhaseEstimation`
  
  **Example**
  
  .. code-block:: python
  
      dev = qml.device("default.qubit", wires = 4)
  
      @qml.qnode(dev)
      def circuit():
  
          for i in range(3):
              qml.Hadamard(wires = i)
  
          qml.ControlledSequence(qml.RX(0.25, wires = 3), control = [0, 1, 2])
  
          qml.adjoint(qml.QFT)(wires = range(3))
  
          return qml.probs(wires = range(3))
  
  >>> print(circuit())
  [0.92059345 0.02637178 0.00729619 0.00423258 0.00360545 0.00423258 0.00729619 0.02637178]
class_docstr_tok: ["Creates","a","sequence","of","controlled","gates","raised","to","decreasing","powers","of","2",".","Can","be","used","as","a","sub-block","in","building","a","`","quantum","phase","estimation","<","https",":","\/\/en.wikipedia.org\/wiki\/Quantum_phase_estimation_algorithm",">","`","__","circuit",".","Given","an",":","class",":","`","~.Operator","`","and","a","list","of","control","wires",",","this","template","creates","a","sequence","of","controlled","gates",",","one","for","each","control","wire",",","with","the","base",":","class",":","`","~.Operator","`","raised","to","decreasing","powers","of","2",":","..","figure",":",":","..","\/","..","\/_static\/templates\/subroutines\/big_ctrl.png",":","align",":","center",":","width",":","40","%",":","target",":","javascript",":","void","(","0",")",";","Args",":","base","(","Operator",")",":","the","phase","estimation","unitary",",","specified","as","an",":","class",":","`","~.Operator","`","control","(","Union","[","Wires",",","Sequence","[","int","]",",","or","int","]",")",":","the","wires","to","be","used","for","control","Raises",":","ValueError",":","if","the","wires","in","``","control","``","and","wires","on","the","``","base","``","operator","share","a","common","element","..","seealso",":",":",":","class",":","`","~.QuantumPhaseEstimation","`","*","*","Example","*","*","..","code-block",":",":","python","dev","=","qml.device","(","``","default.qubit","''",",","wires","=","4",")","@","qml.qnode","(","dev",")","def","circuit","(",")",":","for","i","in","range","(","3",")",":","qml.Hadamard","(","wires","=","i",")","qml.ControlledSequence","(","qml.RX","(","0.25",",","wires","=","3",")",",","control","=","[","0",",","1",",","2","]",")","qml.adjoint","(","qml.QFT",")","(","wires","=","range","(","3",")",")","return","qml.probs","(","wires","=","range","(","3",")",")",">",">",">","print","(","circuit","(",")",")","[","0.92059345","0.02637178","0.00729619","0.00423258","0.00360545","0.00423258","0.00729619","0.02637178","]"]
docstr: Representation of the operator as a product of other operators.
  
  .. math:: O = O_1 O_2 \dots O_n.
  
  .. seealso:: :meth:`~.CtrlSequence.decomposition`.
  
  Args:
      base (Operator): the operator that acts as the base for the sequence
      control_wires (Any or Iterable[Any]): the control wires for the sequence
  
  Returns:
      list[.Operator]: decomposition of the operator
  
  **Example**
  
  .. code-block:: python
  
      dev = qml.device("default.qubit")
      op = qml.ControlledSequence(qml.RX(0.25, wires = 3), control = [0, 1, 2])
  
      @qml.qnode(dev)
      def circuit():
          op.decomposition()
          return qml.state()
  
  >>> print(qml.draw(circuit, wire_order=[0,1,2,3])())
  0: ─╭●─────────────────────────────────────┤  State
  1: ─│────────────╭●────────────────────────┤  State
  2: ─│────────────│────────────╭●───────────┤  State
  3: ─╰(RX(1.00))──╰(RX(0.50))──╰(RX(0.25))──┤  State
  
  To display the operators as powers of the base operator without further simplifcation,
  the `compute_decompostion` method can be used with `lazy=True`.
  
  .. code-block:: python
  
      dev = qml.device("default.qubit")
      op = qml.ControlledSequence(qml.RX(0.25, wires = 3), control = [0, 1, 2])
  
      @qml.qnode(dev)
      def circuit():
          op.compute_decomposition(base=op.base, control_wires=op.control, lazy=True)
          return qml.state()
  
  >>> print(qml.draw(circuit, wire_order=[0,1,2,3])())
  0: ─╭●─────────────────────────────────────┤  State
  1: ─│────────────╭●────────────────────────┤  State
  2: ─│────────────│────────────╭●───────────┤  State
  3: ─╰(RX(0.25))⁴─╰(RX(0.25))²─╰(RX(0.25))¹─┤  State
docstr_tok: ["Representation","of","the","operator","as","a","product","of","other","operators",".","..","math",":",":","O","=","O_1","O_2","\\dots","O_n",".","..","seealso",":",":",":","meth",":","`","~.CtrlSequence.decomposition","`",".","Args",":","base","(","Operator",")",":","the","operator","that","acts","as","the","base","for","the","sequence","control_wires","(","Any","or","Iterable","[","Any","]",")",":","the","control","wires","for","the","sequence","Returns",":","list","[",".Operator","]",":","decomposition","of","the","operator","*","*","Example","*","*","..","code-block",":",":","python","dev","=","qml.device","(","``","default.qubit","''",")","op","=","qml.ControlledSequence","(","qml.RX","(","0.25",",","wires","=","3",")",",","control","=","[","0",",","1",",","2","]",")","@","qml.qnode","(","dev",")","def","circuit","(",")",":","op.decomposition","(",")","return","qml.state","(",")",">",">",">","print","(","qml.draw","(","circuit",",","wire_order=","[","0,1,2,3","]",")","(",")",")","0",":","\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State","1",":","\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State","2",":","\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State","3",":","\u2500\u2570","(","RX","(","1.00",")",")","\u2500\u2500\u2570","(","RX","(","0.50",")",")","\u2500\u2500\u2570","(","RX","(","0.25",")",")","\u2500\u2500\u2524","State","To","display","the","operators","as","powers","of","the","base","operator","without","further","simplifcation",",","the","`","compute_decompostion","`","method","can","be","used","with","`","lazy=True","`",".","..","code-block",":",":","python","dev","=","qml.device","(","``","default.qubit","''",")","op","=","qml.ControlledSequence","(","qml.RX","(","0.25",",","wires","=","3",")",",","control","=","[","0",",","1",",","2","]",")","@","qml.qnode","(","dev",")","def","circuit","(",")",":","op.compute_decomposition","(","base=op.base",",","control_wires=op.control",",","lazy=True",")","return","qml.state","(",")",">",">",">","print","(","qml.draw","(","circuit",",","wire_order=","[","0,1,2,3","]",")","(",")",")","0",":","\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State","1",":","\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State","2",":","\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State","3",":","\u2500\u2570","(","RX","(","0.25",")",")","\u2074\u2500\u2570","(","RX","(","0.25",")",")","\u00b2\u2500\u2570","(","RX","(","0.25",")",")","\u00b9\u2500\u2524","State"]
code: def compute_decomposition(
      *_, base=None, control_wires=None, lazy=False, **__
  ):
      r"""Representation of the operator as a product of other operators.
  
      .. math:: O = O_1 O_2 \dots O_n.
  
      .. seealso:: :meth:`~.CtrlSequence.decomposition`.
  
      Args:
          base (Operator): the operator that acts as the base for the sequence
          control_wires (Any or Iterable[Any]): the control wires for the sequence
  
      Returns:
          list[.Operator]: decomposition of the operator
  
      **Example**
  
      .. code-block:: python
  
          dev = qml.device("default.qubit")
          op = qml.ControlledSequence(qml.RX(0.25, wires = 3), control = [0, 1, 2])
  
          @qml.qnode(dev)
          def circuit():
              op.decomposition()
              return qml.state()
  
      >>> print(qml.draw(circuit, wire_order=[0,1,2,3])())
      0: ─╭●─────────────────────────────────────┤  State
      1: ─│────────────╭●────────────────────────┤  State
      2: ─│────────────│────────────╭●───────────┤  State
      3: ─╰(RX(1.00))──╰(RX(0.50))──╰(RX(0.25))──┤  State
  
      To display the operators as powers of the base operator without further simplifcation,
      the `compute_decompostion` method can be used with `lazy=True`.
  
      .. code-block:: python
  
          dev = qml.device("default.qubit")
          op = qml.ControlledSequence(qml.RX(0.25, wires = 3), control = [0, 1, 2])
  
          @qml.qnode(dev)
          def circuit():
              op.compute_decomposition(base=op.base, control_wires=op.control, lazy=True)
              return qml.state()
  
      >>> print(qml.draw(circuit, wire_order=[0,1,2,3])())
      0: ─╭●─────────────────────────────────────┤  State
      1: ─│────────────╭●────────────────────────┤  State
      2: ─│────────────│────────────╭●───────────┤  State
      3: ─╰(RX(0.25))⁴─╰(RX(0.25))²─╰(RX(0.25))¹─┤  State
  
      """
  
      powers_of_two = [2**i for i in range(len(control_wires))]
      ops = []
  
      for z, ctrl_wire in zip(powers_of_two[::-1], control_wires):
          ops.append(
              qml.pow(qml.ctrl(base, control=ctrl_wire), z=z, lazy=lazy)
          )
  
      return ops
  
file_path: pennylane/pennylane/templates/subroutines/controlled_sequence.py
imports: from copy import copy
  import pennylane
  from pennylane.operation import Operation
  from pennylane.wires import Wires
  from pennylane.ops.op_math.symbolicop import SymbolicOp
label_desc: Use image node_id 11 for calling the ControlledSequence obj's underlying member method code with example usage: obj.compute_decomposition() and returns: ops