
    z	i                     V    S r SSKJr  SSKJr  SSKJrJrJr   " S S\5      r	S r
S rg	)
zKReplace each sequence of CX and SWAP gates by a single LinearFunction gate.    )partialLinearFunction)CollectAndCollapsecollect_using_filter_functioncollapse_to_operationc                   <   ^  \ rS rSrSr      SU 4S jjrSrU =r$ )CollectLinearFunctions   zCollect blocks of linear gates (:class:`.CXGate` and :class:`.SwapGate` gates)
and replaces them by linear functions (:class:`.LinearFunction`).c           
      v   > [        [        [        UUUUUS9n[        [        [        S9n[
        T	U ]  UUUS9  g)a  CollectLinearFunctions initializer.

Args:
    do_commutative_analysis (bool): if True, exploits commutativity relations
        between nodes.
    split_blocks (bool): if True, splits collected blocks into sub-blocks
        over disjoint qubit subsets.
    min_block_size (int): specifies the minimum number of gates in the block
        for the block to be collected.
    split_layers (bool): if True, splits collected blocks into sub-blocks
        over disjoint qubit subsets.
    collect_from_back (bool): specifies if blocks should be collected started
        from the end of the circuit.
    max_block_width (int | None): specifies the maximum width of the block
        (that is, the number of qubits over which the block is defined)
        for the block to be collected.
)filter_functionsplit_blocksmin_block_sizesplit_layerscollect_from_backmax_block_width)collapse_function)collect_functionr   do_commutative_analysisN)r   r   _is_linear_gater   _collapse_to_linear_functionsuper__init__)
selfr   r   r   r   r   r   r   r   	__class__s
            x/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/optimization/collect_linear_functions.pyr   CollectLinearFunctions.__init__   sU    6 #)+%)%/+
 $!5Q
 	-/$; 	 	
     )FT   FFN)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r   s   @r   r
   r
      s'    I
 !&,
 ,
r   r
   c                 `    U R                   R                  S;   =(       a    [        U SS5      SL $ )z-Specifies whether a node holds a linear gate.)cxswap	conditionN)opnamegetattr)nodes    r   r   r   M   s)    77<<>)VgdK.NRV.VVr   c                     [        U 5      $ )zpSpecifies how to construct a ``LinearFunction`` from a quantum circuit (that must
consist of linear gates only).r   )circuits    r   r   r   R   s     '""r   N)r%   	functoolsr   (qiskit.circuit.library.generalized_gatesr   :qiskit.transpiler.passes.optimization.collect_and_collapser   r   r   r
   r   r   r   r   r   <module>r5      s4    R  C 0
/ 0
fW
#r   