
    z	i                    n    S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKrSS	KJr   " S
 S\5      rg)z The Lie-Trotter product formula.    )annotations)Callable)Any)QuantumCircuit)SparsePauliOpN   )SuzukiTrotterc                  z   ^  \ rS rSrSr      SSS.               S	U 4S jjjjr\S
S j5       rSrU =r	$ )
LieTrotter   a+  The Lie-Trotter product formula.

The Lie-Trotter formula approximates the exponential of two non-commuting operators
with products of their exponentials up to a second order error:

.. math::

    e^{A + B} \approx e^{A}e^{B}.

In this implementation, the operators are provided as sum terms of a Pauli operator.
For example, we approximate

.. math::

    e^{-it(XI + ZZ)} = e^{-it XI}e^{-it ZZ} + \mathcal{O}(t^2).

References:

    [1]: D. Berry, G. Ahokas, R. Cleve and B. Sanders,
    "Efficient quantum algorithms for simulating sparse Hamiltonians" (2006).
    `arXiv:quant-ph/0508139 <https://arxiv.org/abs/quant-ph/0508139>`_
    [2]: N. Hatano and M. Suzuki,
    "Finding Exponential Product Formulas of Higher Orders" (2005).
    `arXiv:math-ph/0506007 <https://arxiv.org/pdf/math-ph/0506007.pdf>`_
F)"atomic_evolution_sparse_observablec               .   > [         TU ]  SUUUUUUUS9  g)aJ  
Args:
    reps: The number of time steps.
    insert_barriers: Whether to insert barriers between the atomic evolutions.
    cx_structure: How to arrange the CX gates for the Pauli evolutions, can be
        ``"chain"``, where next neighbor connections are used, or ``"fountain"``,
        where all qubits are connected to one. This only takes effect when
        ``atomic_evolution is None``.
    atomic_evolution: A function to apply the evolution of a single
        :class:`~.quantum_info.Pauli`, or :class:`.SparsePauliOp` of only commuting terms,
        to a circuit. The function takes in three arguments: the circuit to append the
        evolution to, the Pauli operator to evolve, and the evolution time. By default, a
        single Pauli evolution is decomposed into a chain of ``CX`` gates and a single
        ``RZ`` gate.
    wrap: Whether to wrap the atomic evolutions into custom gate objects. This only takes
        effect when ``atomic_evolution is None``.
    preserve_order: If ``False``, allows reordering the terms of the operator to
        potentially yield a shallower evolution circuit. Not relevant
        when synthesizing operator with a single term.
    atomic_evolution_sparse_observable: If a custom ``atomic_evolution`` is passed,
        which does not yet support :class:`.SparseObservable`\ s as input, set this
        argument to ``False`` to automatically apply a conversion to :class:`.SparsePauliOp`.
        This argument is supported until Qiskit 2.2, at which point all atomic evolutions
        are required to support :class:`.SparseObservable`\ s as input.
r   )preserve_orderr   N)super__init__)	selfrepsinsert_barrierscx_structureatomic_evolutionwrapr   r   	__class__s	           `/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/synthesis/evolution/lie_trotter.pyr   LieTrotter.__init__5   s0    N 	)/Q 	 		
    c                    U R                   b  [        S5      eU R                  U R                  U R                  U R
                  S.$ )a  Return the settings in a dictionary, which can be used to reconstruct the object.

Returns:
    A dictionary containing the settings of this product formula.

Raises:
    NotImplementedError: If a custom atomic evolution is set, which cannot be serialized.
zBCannot serialize a product formula with a custom atomic evolution.)r   r   r   r   )_atomic_evolutionNotImplementedErrorr   r   _cx_structure_wrap)r   s    r   settingsLieTrotter.settingsg   sL     !!-%T 
 II#33 ..JJ	
 	
r    )r   FchainNFT)r   intr   boolr   strr   zYCallable[[QuantumCircuit, qiskit.quantum_info.Pauli | SparsePauliOp, float], None] | Noner   r&   r   r&   r   r&   returnNone)r(   zdict[str, Any])
__name__
__module____qualname____firstlineno____doc__r   propertyr!   __static_attributes____classcell__)r   s   @r   r   r      s    8  %# #0
 490
0
 0
 	0
0
 0
 0
 -10
 
0
 0
d 
 
r   r   )r.   
__future__r   collections.abcr   typingr   qiskit.circuit.quantumcircuitr   qiskit.quantum_info.operatorsr   qiskit.quantum_infoqiskitsuzuki_trotterr	   r   r#   r   r   <module>r:      s-    ' " $  8 7  )a
 a
r   