§
    º³ÙgT6  ã                  ó¤   — d Z ddlmZ ddlmZ ddlZddlZddlm	Z	m
Z
mZ ddlmZ  G d„ d¦  «        Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS )z1Algebra utilities and the ``GateSequence`` class.é    )Úannotations)ÚSequenceN)ÚGateÚQuantumCircuitÚQubit)ÚUnitaryGatec                  ó�   — e Zd ZdZd"d#d„Zd$d
„Zd%d„Zd„ Zd„ Zd&d„Z	d'd„Z
d'd„Zd(d„Zd)d„Zd*d„Zd*d„Zed+d„¦   «         Zd,d „Zd!S )-ÚGateSequencez‚A class implementing a sequence of gates.

    This class stores the sequence of gates along with the unitary they implement.
    © ÚgatesúSequence[Gate]ÚreturnÚNonec                ó�  — t          |¦  «        | _        d„ |D ¦   «         | _        d„ |D ¦   «         | _        t	          j        d¦  «        }| j        D ]}|                     |¦  «        }Œt          |¦  «        \  }}t          |¦  «        }d| _	        d 
                    | j        ¦  «        | _        || _        || _        || _        dS )zxCreate a new sequence of gates.

        Args:
            gates: The gates in the sequence. The default is [].
        c                óN   — g | ]"}t          j        |t           j        ¬ ¦  «        ‘Œ#S )©Údtype)ÚnpÚasarrayÚ
complex128©Ú.0Úgates     úc/granary/edev/quantum/lib/python3.11/site-packages/qiskit/synthesis/discrete_basis/gate_sequence.pyú
<listcomp>z)GateSequence.__init__.<locals>.<listcomp>&   s)   € ÐQÐQÐQÀ4�œ Dµ´Ð>Ñ>Ô>ÐQÐQÐQó    c                ó   — g | ]	}|j         ‘Œ
S r   ©Únamer   s     r   r   z)GateSequence.__init__.<locals>.<listcomp>'   s   € Ð3Ð3Ð3 T�t”yÐ3Ð3Ð3r   é   Nú )Úlistr   ÚmatricesÚlabelsr   ÚidentityÚdotÚ_convert_u2_to_su2Ú_convert_su2_to_so3Ú_eulersÚjoinr   Úglobal_phaseÚproductÚproduct_su2)Úselfr   Ú	u2_matrixÚmatrixÚ
su2_matrixr+   Ú
so3_matrixs          r   Ú__init__zGateSequence.__init__   sÌ   € õ ˜%‘[”[ˆŒ
ØQÐQÈ5ÐQÑQÔQˆŒØ3Ð3¨UÐ3Ñ3Ô3ˆŒõ ”K ‘N”Nˆ	Ø”mð 	.ð 	.ˆFàŸ
š
 9Ñ-Ô-ˆIˆIõ $6°iÑ#@Ô#@Ñ ˆ
�Lõ )¨Ñ4Ô4ˆ
ð ˆŒØ—H’H˜Tœ[Ñ)Ô)ˆŒ	Ø(ˆÔØ!ˆŒØ%ˆÔÐÐr   ÚindicesúSequence[int]c                óâ   — t          |ddd…         ¦  «        D ]6}| j                             |¦  «         | j                             |¦  «         Œ7d                     | j        ¦  «        | _        dS )zQRemove a pair of indices that cancel each other and *do not* change the matrices.Néÿÿÿÿr!   )r"   r   Úpopr$   r*   r   )r.   r4   Úindexs      r   Úremove_cancelling_pairz#GateSequence.remove_cancelling_pair<   si   € å˜' $ $ B $œ-Ñ(Ô(ð 	#ð 	#ˆEØŒJ�NŠN˜5Ñ!Ô!Ð!ØŒK�OŠO˜EÑ"Ô"Ð"Ð"ð —H’H˜Tœ[Ñ)Ô)ˆŒ	ˆ	ˆ	r   Úotherú'GateSequence'Úboolc                óÔ   — t          | j        ¦  «        t          |j        ¦  «        k    sdS t          | j        |j        ¦  «        D ]\  }}||k    r dS Œ| j        |j        k    rdS dS )zýCheck if this GateSequence is the same as the other GateSequence.

        Args:
            other: The GateSequence that will be compared to ``self``.

        Returns:
            True if ``other`` is equivalent to ``self``, false otherwise.

        FT)Úlenr   Úzipr+   )r.   r;   Úgate1Úgate2s       r   Ú__eq__zGateSequence.__eq__E   sy   € õ �4”:‰Œ¥# e¤kÑ"2Ô"2Ò2Ð2Ø�5å ¤
¨E¬KÑ8Ô8ð 	ð 	‰LˆE�5Ø˜Š~ˆ~Ø�u�uð ð Ô Ô 2Ò2Ð2Ø�5àˆtr   c                ó‚  — t          | j        ¦  «        dk    rot          j        | j        t          j        d¦  «        ¦  «        sCt          d| j        ¬¦  «        }t          | j        ¦  «        }| 	                    |dg¦  «         |S t          d| j        ¬¦  «        }| j        D ]}| 
                    |dg¦  «         Œ|S )z¨Convert to a circuit.

        If no gates set but the product is not the identity, returns a circuit with a
        unitary operation to implement the matrix.
        r   é   é   )r+   )r?   r   r   Úallcloser,   r%   r   r+   Ú_convert_so3_to_su2ÚunitaryÚappend)r.   ÚcircuitÚsu2r   s       r   Ú
to_circuitzGateSequence.to_circuit[   sµ   € õ ˆtŒz‰?Œ?˜aÒÐ­¬°D´LÅ"Ä+ÈaÁ.Ä.Ñ(QÔ(QÐÝ$ Q°TÔ5FÐGÑGÔGˆGÝ% d¤lÑ3Ô3ˆCØ�OŠO˜C ! Ñ%Ô%Ð%ØˆNå  °Ô1BÐCÑCÔCˆØ”Jð 	&ð 	&ˆDØ�NŠN˜4 ! Ñ%Ô%Ð%Ð%àˆr   c                óÈ  — ddl m} t          ¦   «         f} |¦   «         }|                     |¦  «         t	          | j        ¦  «        dk    rgt          j        | j        t          j	        d¦  «        ¦  «        s;t          | j        ¦  «        }|                     t          |¦  «        |d¬¦  «         |S | j        |_        | j        D ]}|                     ||d¬¦  «         Œ|S )zµConvert to a :class:`.DAGCircuit`.

        If no gates set but the product is not the identity, returns a circuit with a
        unitary operation to implement the matrix.
        r   )Ú
DAGCircuitrE   F)Úcheck)Úqiskit.dagcircuitrO   r   Ú
add_qubitsr?   r   r   rG   r,   r%   rH   Úapply_operation_backr   r+   )r.   rO   ÚqregÚdagrL   r   s         r   Úto_dagzGateSequence.to_dagm   sâ   € ð 	1Ð0Ð0Ð0Ð0Ð0å‘”ˆzˆØˆj‰lŒlˆØ�Š�tÑÔÐåˆtŒz‰?Œ?˜aÒÐ­¬°D´LÅ"Ä+ÈaÁ.Ä.Ñ(QÔ(QÐÝ% d¤lÑ3Ô3ˆCØ×$Ò$¥[°Ñ%5Ô%5°tÀ5Ð$ÑIÔIÐIØˆJàÔ,ˆÔØ”Jð 	>ð 	>ˆDØ×$Ò$ T¨4°uÐ$Ñ=Ô=Ð=Ð=àˆ
r   r   r   c                óP  — d| _         t          j        |t          j        ¬¦  «        }t	          |¦  «        \  }}t          |¦  «        }|                     | j        ¦  «        | _        |                     | j        ¦  «        | _        | j	        |z   | _	        | j
                             |¦  «         t          | j        ¦  «        dk    r| xj        d|j        › �z  c_        n|j        | _        | j                             |j        ¦  «         | j                             |¦  «         | S )z«Append gate to the sequence of gates.

        Args:
            gate: The gate to be appended.

        Returns:
            GateSequence with ``gate`` appended.
        Nr   r   r!   )r)   r   Úarrayr   r'   r(   r&   r,   r-   r+   r   rJ   r?   r$   r   r#   )r.   r   r0   rL   ÚphaseÚso3s         r   rJ   zGateSequence.append„   sþ   € ð ˆŒõ
 ”˜$¥b¤mÐ4Ñ4Ô4ˆÝ'¨Ñ/Ô/‰
ˆˆUÝ! #Ñ&Ô&ˆà—w’w˜tœ|Ñ,Ô,ˆŒØŸ7š7 4Ô#3Ñ4Ô4ˆÔØ Ô-°Ñ5ˆÔàŒ
×Ò˜$ÑÔÐÝˆtŒ{ÑÔ˜aÒÐØˆIŒI˜˜TœY˜˜Ñ(ˆIŒIˆIàœ	ˆDŒIØŒ×Ò˜4œ9Ñ%Ô%Ð%àŒ×Ò˜VÑ$Ô$Ð$àˆr   c                óx  — t          ¦   «         }d„ t          | j        ¦  «        D ¦   «         |_        d„ |j        D ¦   «         |_        d                     |j        ¦  «        |_        t          j        | j        ¦  «        j	        |_        t          j        | j
        ¦  «        j	        |_
        | j         |_        |S )zGet the complex conjugate.c                ó6   — g | ]}|                      ¦   «         ‘ŒS r   )Úinverser   s     r   r   z(GateSequence.adjoint.<locals>.<listcomp>«   s    € ÐIÐIÐI¨D˜Ÿš™œÐIÐIÐIr   c                ó   — g | ]	}|j         ‘Œ
S r   r   )r   Úinvs     r   r   z(GateSequence.adjoint.<locals>.<listcomp>¬   s   € Ð<Ð<Ð< s˜#œ(Ð<Ð<Ð<r   r!   )r
   Úreversedr   r$   r*   r   r   Úconjr,   ÚTr-   r+   )r.   Úadjoints     r   rc   zGateSequence.adjoint¦   s™   € õ ‘.”.ˆØIÐIµH¸T¼ZÑ4HÔ4HÐIÑIÔIˆŒØ<Ð<¨g¬mÐ<Ñ<Ô<ˆŒØ—x’x ¤Ñ/Ô/ˆŒÝœ' $¤,Ñ/Ô/Ô1ˆŒÝ œg dÔ&6Ñ7Ô7Ô9ˆÔØ $Ô 1Ð1ˆÔàˆr   c                óØ  — t          | ¦  «                             t          | ¦  «        ¦  «        }| j                             ¦   «         |_        | j                             ¦   «         |_        | j                             ¦   «         |_        | j        |_        | j                             ¦   «         |_        | j                             ¦   «         |_        | j	        |_	        | j
        |_
        |S )z†Create copy of the sequence of gates.

        Returns:
            A new ``GateSequence`` containing copy of list of gates.

        )ÚtypeÚ__new__r$   Úcopyr   r#   r+   r,   r-   r   r)   )r.   Úouts     r   rg   zGateSequence.copy´   s­   € õ �4‰jŒj× Ò ¥ d¡¤Ñ,Ô,ˆØ”[×%Ò%Ñ'Ô'ˆŒ
Ø”J—O’OÑ%Ô%ˆŒ	Ø”}×)Ò)Ñ+Ô+ˆŒØÔ,ˆÔØ”l×'Ò'Ñ)Ô)ˆŒØÔ*×/Ò/Ñ1Ô1ˆŒØ”9ˆŒØ”lˆŒØˆ
r   Úintc                ó*   — t          | j        ¦  «        S )zkReturn length of sequence of gates.

        Returns:
            Length of list containing gates.
        )r?   r   )r.   s    r   Ú__len__zGateSequence.__len__Æ   s   € õ �4”:‰ŒÐr   r9   c                ó   — | j         |         S )zÖReturns the gate at ``index`` from the list of gates.

        Args
            index: Index of gate in list that will be returned.

        Returns:
            The gate at ``index`` in the list of gates.
        )r   )r.   r9   s     r   Ú__getitem__zGateSequence.__getitem__Î   s   € ð Œz˜%Ô Ð r   Ústrc                ó~   — d}| j         D ]}||j        z  }|dz  }Œ|dz  }|dz  }|t          | j        ¦  «        z  }|S )ú}Return string representation of this object.

        Returns:
            Representation of this sequence of gates.
        ú[ú, ú]z, product: ©r   r   rn   r,   ©r.   rh   r   s      r   Ú__repr__zGateSequence.__repr__Ù   s]   € ð ˆØ”Jð 	ð 	ˆDØ�4”9ÑˆCØ�4‰KˆCˆCØˆs‰
ˆØˆ}ÑˆØ�s�4”<Ñ Ô Ñ ˆØˆ
r   c                ó~   — d}| j         D ]}||j        z  }|dz  }Œ|dz  }|dz  }|t          | j        ¦  «        z  }|S )rp   rq   rr   rs   z, product: 
rt   ru   s      r   Ú__str__zGateSequence.__str__è   s]   € ð ˆØ”Jð 	ð 	ˆDØ�4”9ÑˆCØ�4‰KˆCˆCØˆs‰
ˆØˆÑˆØ�s�4”<Ñ Ô Ñ ˆØˆ
r   r0   ú
np.ndarrayc                ó¾   —  | ¦   «         }|j         dk    rt          |¦  «        |_        n+|j         dk    r||_        nt          d|j         › d�¦  «        ‚g |_        |S )a4  Initialize the gate sequence from a matrix, without a gate sequence.

        Args:
            matrix: The matrix, can be SU(2) or SO(3).

        Returns:
            A ``GateSequence`` initialized from the input matrix.

        Raises:
            ValueError: If the matrix has an invalid shape.
        ©r    r    ©rE   rE   z0Matrix must have shape (3, 3) or (2, 2) but has ú.)Úshaper(   r,   Ú
ValueErrorr   )Úclsr0   Úinstances      r   Úfrom_matrixzGateSequence.from_matrix÷   sq   € ð �3‘5”5ˆØŒ<˜6Ò!Ð!Ý2°6Ñ:Ô:ˆHÔÐØŒ\˜VÒ#Ð#Ø%ˆHÔÐåÐ_ÐPVÔP\Ð_Ð_Ð_Ñ`Ô`Ð`àˆŒØˆr   c                ó   — t          ¦   «         }|j        | j        z   |_        |j        | j        z   |_        d                     |j        ¦  «        |_        t          j        | j        |j        ¦  «        |_        | j        |j        z   |_        |S )z·Compute the dot-product with another gate sequence.

        Args:
            other: The other gate sequence.

        Returns:
            The dot-product as gate sequence.
        r!   )	r
   r   r$   r*   r   r   r&   r,   r+   )r.   r;   Úcomposeds      r   r&   zGateSequence.dot  sr   € õ  ‘>”>ˆØœ t¤zÑ1ˆŒØœ,¨¬Ñ4ˆŒØŸš ¤Ñ1Ô1ˆŒÝœ6 $¤,°´Ñ>Ô>ˆÔØ $Ô 1°EÔ4FÑ FˆÔàˆr   N)r   )r   r   r   r   )r4   r5   r   r   )r;   r<   r   r=   )r   r   r   r<   )r   r<   )r   ri   )r9   ri   r   r   )r   rn   )r0   ry   r   r<   )r;   r<   r   r<   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r3   r:   rC   rM   rV   rJ   rc   rg   rk   rm   rv   rx   Úclassmethodr‚   r&   r   r   r   r
   r
      s>  € € € € € ðð ð
&ð &ð &ð &ð &ð:*ð *ð *ð *ðð ð ð ð,ð ð ð$ð ð ð. ð  ð  ð  ðDð ð ð ðð ð ð ð$ð ð ð ð	!ð 	!ð 	!ð 	!ðð ð ð ðð ð ð ð ðð ð ñ „[ðð.ð ð ð ð ð r   r
   r/   ry   r   útuple[np.ndarray, float]c                óî   — dt          j        t           j                             | ¦  «        ¦  «        z  }|| z  }t          j        t          j        |¦  «        t          j        |¦  «        ¦  «        }||fS )z8Convert a U(2) matrix to SU(2) by adding a global phase.rF   )r   ÚsqrtÚlinalgÚdetÚarctan2ÚimagÚreal)r/   Úzr1   rY   s       r   r'   r'   $  sY   € à	�BŒG•B”I—M’M )Ñ,Ô,Ñ-Ô-Ñ-€AØ�Y‘€JÝŒJ•r”w˜q‘z”z¥2¤7¨1¡:¤:Ñ.Ô.€Eà�uÐÐr   r0   útuple[float, float, float]c                óV  — t          j        | d¬¦  «        } | d         d         dk    ræ| d         d         dk    rÔt          j        | d         d         ¦  «         }t          j        | d         d         t          j        |¦  «        z  | d         d         t          j        |¦  «        z  ¦  «        }t          j        | d         d         t          j        |¦  «        z  | d         d         t          j        |¦  «        z  ¦  «        }|||fS d}| d         d         dk    r@t          j        dz  }|t          j        | d         d         | d         d         ¦  «        z   }nCt          j         dz  }| t          j        | d         d          | d         d          ¦  «        z   }|||fS )aŸ  Computes the Euler angles from the SO(3)-matrix u.

    Uses the algorithm from Gregory Slabaugh,
    see `here <https://www.gregslabaugh.net/publications/euler.pdf>`_.

    Args:
        matrix: The SO(3)-matrix for which the Euler angles need to be computed.

    Returns:
        Tuple (phi, theta, psi), where phi is rotation about z-axis, theta rotation about y-axis
        and psi rotation about x-axis.
    é
   )Údecimalsr    r   rF   r7   )r   ÚroundÚmathÚasinÚatan2ÚcosÚpi)r0   ÚthetaÚpsiÚphis       r   Ú_compute_euler_angles_from_so3r    -  sk  € õ ŒX�f rÐ*Ñ*Ô*€FØˆa„y�„|�qÒÐ˜V AœY qœ\¨RÒ/Ð/Ý”˜6 !œ9 Qœ<Ñ(Ô(Ð(ˆÝŒj˜ œ 1œ­¬°©¬Ñ7¸À¼À1¼ÍÌÐQVÉÌÑ9WÑXÔXˆÝŒj˜ œ 1œ­¬°©¬Ñ7¸À¼À1¼ÍÌÐQVÉÌÑ9WÑXÔXˆØ�E˜3ˆÐàˆØ�!Œ9�QŒ<˜1ÒÐÝ”G˜a‘KˆEØ�œ
 6¨!¤9¨Q¤<°¸´¸1´Ñ>Ô>Ñ>ˆCˆCå”W�H˜q‘LˆEØ�$�œ V¨A¤Y¨q¤\ M°F¸1´I¸a´L°=ÑAÔAÑAˆCØ�E˜3ˆÐr   Úanglesc                óÖ  — | \  }}}t          j        t          j        d|z  ¦  «        dgdt          j        d|z  ¦  «        ggt          ¬¦  «        }t          j        t	          j        |dz  ¦  «        t	          j        |dz  ¦  «        gt	          j        |dz  ¦  «         t	          j        |dz  ¦  «        ggt          ¬¦  «        }t          j        t	          j        |dz  ¦  «        t	          j        |dz  ¦  «        dz  gt	          j        |dz  ¦  «        dz  t	          j        |dz  ¦  «        ggt          ¬¦  «        }t          j        |t          j        ||¦  «        ¦  «        S )a  Computes SU(2)-matrix from Euler angles.

    Args:
        angles: The tuple containing the Euler angles for which the corresponding SU(2)-matrix
            needs to be computed.

    Returns:
        The SU(2)-matrix corresponding to the Euler angles in angles.
    y       €      à¿r   y              à?r   r    y              ð?)r   rX   ÚexpÚcomplexr˜   r›   Úsinr&   )r¡   rŸ   r�   rž   Úuz_phiÚuy_thetaÚux_psis          r   Ú_compute_su2_from_euler_anglesr©   K  sJ  € ð �O€Cˆ�ÝŒX�œ˜u s™{Ñ+Ô+¨QÐ/°!µR´V¸DÀ3¹JÑ5GÔ5GÐ1HÐIÕQXÐYÑYÔY€FÝŒxÝ
Œ(�5˜1‘9Ñ
Ô
�tœx¨°©	Ñ2Ô2Ð	3µt´xÀÈÁ	Ñ7JÔ7JÐ6JÍDÌHÐUZÐ]^ÑU^ÑL_ÔL_Ð5`ÐaÝðñ ô €Hõ ŒXÝ
Œ(�3˜‘7Ñ
Ô
�TœX c¨A¡gÑ.Ô.°Ñ3Ð	4µt´xÀÀaÁÑ7HÔ7HÈ2Ñ7MÍtÌxÐX[Ð^_ÑX_ÑO`ÔO`Ð6aÐbÝðñ ô €Fõ Œ6�&�"œ& ¨6Ñ2Ô2Ñ3Ô3Ð3r   c           	     óÜ  — t          | ¦  «         |                      t          ¦  «        } t          j        | d         d         ¦  «        }t          j        | d         d         ¦  «        }t          j        | d         d         ¦  «         }t          j        | d         d         ¦  «         }t          j        |dz  |dz  z
  |dz  z
  |dz  z   d|z  |z  d|z  |z  z   d|z  |z  d|z  |z  z   gd|z  |z  d|z  |z  z   |dz  |dz  z
  |dz  z   |dz  z
  d|z  |z  d|z  |z  z   gd|z  |z  d|z  |z  z   d|z  |z  d|z  |z  z
  |dz  |dz  z   |dz  z
  |dz  z
  ggt          ¬¦  «        }|S )a'  Computes SO(3)-matrix from input SU(2)-matrix.

    Args:
        matrix: The SU(2)-matrix for which a corresponding SO(3)-matrix needs to be computed.

    Returns:
        The SO(3)-matrix corresponding to ``matrix``.

    Raises:
        ValueError: if ``matrix`` is not an SU(2)-matrix.
    r   rF   r    éþÿÿÿr   )Ú_check_is_su2Úastyper¤   r   r‘   r�   rX   Úfloat)r0   ÚaÚbÚcÚdÚrotations         r   r(   r(   b  s©  € õ �&ÑÔÐà�]Š]�7Ñ#Ô#€FÝ
Œ��q”	˜!”ÑÔ€AÝ
Œ��q”	˜!”ÑÔ€AÝ	Œ�˜”˜1”Ñ	Ô	Ð€AÝ	Œ�˜”˜1”Ñ	Ô	Ð€AÝŒxà�‰T�A�q‘D‰[˜1˜a™4Ñ ! Q¡$Ñ&¨¨A©°©	°A¸±E¸A±IÑ(=¸rÀA¹vÈ¹zÈAÐPQÉEÐTUÉIÑ?UÐVØ�!‰V�a‰Z˜!˜a™% !™)Ñ# Q¨¡T¨A¨q©D¡[°1°a±4Ñ%7¸!¸Q¹$Ñ%>ÀÀAÁÈÁ	ÈAÐPQÉEÐTUÉIÑ@UÐVØ�‰U�Q‰Y˜˜Q™ ™Ñ" A¨¡E¨A¡I°°A±¸±	Ñ$9¸1¸a¹4À!ÀQÁ$¹;ÈÈAÉÑ;MÐPQÐSTÑPTÑ;TÐUð	
õ
 ðñ ô €Hð €Or   c                óX   — t          | ¦  «         t          t          | ¦  «        ¦  «        S )a  Converts an SO(3)-matrix to a corresponding SU(2)-matrix.

    Args:
        matrix: SO(3)-matrix to convert.

    Returns:
        SU(2)-matrix corresponding to SO(3)-matrix ``matrix``.

    Raises:
        ValueError: if ``matrix`` is not an SO(3)-matrix.
    )Ú_check_is_so3r©   r    ©r0   s    r   rH   rH   €  s)   € õ �&ÑÔÐÝ)Õ*HÈÑ*PÔ*PÑQÔQÐQr   r   c                ó  — | j         dk    rt          d| j         › d�¦  «        ‚t          t          j                             | ¦  «        dz
  ¦  «        dk    r0t          dt          j                             | ¦  «        › d�¦  «        ‚dS )z<Check whether ``matrix`` is SU(2), otherwise raise an error.r{   z&Matrix must have shape (2, 2) but has r}   rF   ç-Cëâ6?ú(Determinant of matrix must be 1, but is N©r~   r   Úabsr   r�   rŽ   r¶   s    r   r¬   r¬   �  ó‚   € à„|�vÒÐÝÐQÀ&Ä,ÐQÐQÐQÑRÔRÐRå
�2Œ9�=Š=˜Ñ Ô  1Ñ$Ñ%Ô%¨Ò,Ð,ÝÐ\ÅBÄIÇMÂMÐRXÑDYÔDYÐ\Ð\Ð\Ñ]Ô]Ð]ð -Ð,r   c                ó  — | j         dk    rt          d| j         › d�¦  «        ‚t          t          j                             | ¦  «        dz
  ¦  «        dk    r0t          dt          j                             | ¦  «        › d�¦  «        ‚dS )z<Check whether ``matrix`` is SO(3), otherwise raise an error.r|   z&Matrix must have shape (3, 3) but has r}   rF   r¸   r¹   Nrº   r¶   s    r   rµ   rµ   ™  r¼   r   )r/   ry   r   rŠ   )r0   ry   r   r“   )r¡   r“   r   ry   )r0   ry   r   ry   )r0   ry   r   r   )rˆ   Ú
__future__r   Úcollections.abcr   r˜   Únumpyr   Úqiskit.circuitr   r   r   Ú0qiskit.circuit.library.generalized_gates.unitaryr   r
   r'   r    r©   r(   rH   r¬   rµ   r   r   r   ú<module>rÃ      sK  ðð 8Ð 7à "Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ø €€€Ø Ð Ð Ð à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø HÐ HÐ HÐ HÐ HÐ HðHð Hð Hð Hð Hñ Hô Hð HðVð ð ð ðð ð ð ð<4ð 4ð 4ð 4ð.ð ð ð ð<Rð Rð Rð Rð ^ð ^ð ^ð ^ð^ð ^ð ^ð ^ð ^ð ^r   