qiskit/providers/basicaer/qasm_simulator.py
def _add_unitary_two(self, gate, qubit0, qubit1):
        """Apply a two-qubit unitary matrix.

        Args:
            gate (matrix_like): a the two-qubit gate matrix
            qubit0 (int): gate qubit-0
            qubit1 (int): gate qubit-1
        """
        # Compute einsum index string for 1-qubit matrix multiplication
        indexes = einsum_vecmul_index([qubit0, qubit1], self._number_of_qubits)
        # Convert to complex rank-4 tensor
        gate_tensor = np.reshape(np.array(gate, dtype=complex), 4 * [2])
        # Apply matrix multiplication
        self._statevector = np.einsum(indexes, gate_tensor,
                                      self._statevector,
                                      dtype=complex,
                                      casting='no')
def _add_unitary_two(self, gate, qubit0, qubit1):
        """Apply a two-qubit unitary matrix.

        Args:
            gate (matrix_like): a the two-qubit gate matrix
            qubit0 (int): gate qubit-0
            qubit1 (int): gate qubit-1
        """
        # Compute einsum index string for 1-qubit matrix multiplication
        indexes = einsum_vecmul_index([qubit0, qubit1], self._number_of_qubits)
        # Convert to complex rank-4 tensor
        gate_tensor = np.reshape(np.array(gate, dtype=complex), 4 * [2])
        # Apply matrix multiplication
        self._statevector = np.einsum(indexes, gate_tensor,
                                      self._statevector,
                                      dtype=complex,
                                      casting='no')
def _add_unitary_two ( self , gate , qubit0 , qubit1 ) : # Compute einsum index string for 1-qubit matrix multiplication indexes = einsum_vecmul_index ( [ qubit0 , qubit1 ] , self . _number_of_qubits ) # Convert to complex rank-4 tensor gate_tensor = np . reshape ( np . array ( gate , dtype = complex ) , 4 * [ 2 ] ) # Apply matrix multiplication self . _statevector = np . einsum ( indexes , gate_tensor , self . _statevector , dtype = complex , casting = 'no' )
Apply a two-qubit unitary matrix.

        Args:
            gate (matrix_like): a the two-qubit gate matrix
            qubit0 (int): gate qubit-0
            qubit1 (int): gate qubit-1
Apply a two - qubit unitary matrix .