§
    º³Ùgð
  ã                  óB   — d Z ddlmZ ddlZddlmZ ddlmZ	 	 ddd„ZdS )zÐ
Implementation of the GraySynth algorithm for synthesizing CNOT-Phase
circuits with efficient CNOT cost, and the Patel-Hayes-Markov algorithm
for optimal synthesis of linear (CNOT-only) reversible circuits.
é    )ÚannotationsN)ÚQuantumCircuit)Úsynth_cnot_count_full_pmhÚstateú#list[list[bool]] | np.ndarray[bool]Úsection_sizeú
int | NoneÚreturnr   c                ó  — t          j        | ¦  «                             t          ¦  «        }|�2|j        d         |k     r!t          d|› d|j        d         › d�¦  «        ‚t          ||¦  «        }t          j        |d¬¦  «        S )uë  
    Synthesize linear reversible circuits for all-to-all architecture
    using Patel, Markov and Hayes method.

    This function is an implementation of the Patel, Markov and Hayes algorithm from [1]
    for optimal synthesis of linear reversible circuits for all-to-all architecture,
    as specified by an :math:`n \times n` matrix.

    Args:
        state: :math:`n \times n` boolean invertible matrix, describing
            the state of the input circuit.
        section_size: The size of each section in the Patelâ€“Markovâ€“Hayes algorithm [1].
            If ``None`` it is chosen to be :math:`\max(2, \alpha\log_2(n))` with
            :math:`\alpha = 0.56`, which approximately minimizes the upper bound on the number
            of row operations given in [1] Eq. (3).

    Returns:
        A CX-only circuit implementing the linear transformation.

    Raises:
        ValueError: When ``section_size`` is larger than the number of columns.

    References:
        1. Patel, Ketan N., Igor L. Markov, and John P. Hayes,
           *Optimal synthesis of linear reversible circuits*,
           Quantum Information & Computation 8.3 (2008): 282-294.
           `arXiv:quant-ph/0302002 [quant-ph] <https://arxiv.org/abs/quant-ph/0302002>`_
    Né   zThe section_size (z/) cannot be larger than the number of columns (z).T)Úadd_regs)	ÚnpÚasarrayÚastypeÚboolÚshapeÚ
ValueErrorÚfast_pmhr   Ú_from_circuit_data)r   r   Ú
normalizedÚcircuit_datas       úX/granary/edev/quantum/lib/python3.11/site-packages/qiskit/synthesis/linear/cnot_synth.pyr   r      sŸ   € õ> ”˜EÑ"Ô"×)Ò)­$Ñ/Ô/€JØÐ JÔ$4°QÔ$7¸,Ò$FÐ$FÝð( ð (ð (ØÔ  Ô#ð(ð (ð (ñ
ô 
ð 	
õ ˜J¨Ñ5Ô5€Lõ Ô,¨\ÀDÐIÑIÔIÐIó    )N)r   r   r   r	   r
   r   )
Ú__doc__Ú
__future__r   Únumpyr   Úqiskit.circuitr   Ú#qiskit._accelerate.synthesis.linearr   r   © r   r   ú<module>r       s„   ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )à UÐ UÐ UÐ UÐ UÐ Uð LPð*Jð *Jð *Jð *Jð *Jð *Jð *Jr   