qiskit/quantum_info/operators/channel/superop.py
def _evolve_subsystem(self, state, qargs):
        """Evolve a quantum state by the operator.

        Args:
            state (QuantumState): The input statevector or density matrix.
            qargs (list): a list of QuantumState subsystem positions to apply
                           the operator on.

        Returns:
            QuantumState: the output quantum state.

        Raises:
            QiskitError: if the operator dimension does not match the
            specified QuantumState subsystem dimensions.
        """
        mat = np.reshape(self.data, self._shape)
        # Hack to assume state is a N-qubit state until a proper class for states
        # is in place
        state_size = len(state)
        state_dims = self._automatic_dims(None, state_size)
        if self.input_dims() != len(qargs) * (2, ):
            raise QiskitError(
                "Channel input dimensions are not compatible with state subsystem dimensions."
            )
        # Return evolved density matrix
        tensor = np.reshape(state, 2 * state_dims)
        num_inidices = len(state_dims)
        indices = [num_inidices - 1 - qubit for qubit in qargs
                   ] + [2 * num_inidices - 1 - qubit for qubit in qargs]
        tensor = self._einsum_matmul(tensor, mat, indices)
        return np.reshape(tensor, [state_size, state_size])
def _evolve_subsystem(self, state, qargs):
        """Evolve a quantum state by the operator.

        Args:
            state (QuantumState): The input statevector or density matrix.
            qargs (list): a list of QuantumState subsystem positions to apply
                           the operator on.

        Returns:
            QuantumState: the output quantum state.

        Raises:
            QiskitError: if the operator dimension does not match the
            specified QuantumState subsystem dimensions.
        """
        mat = np.reshape(self.data, self._shape)
        # Hack to assume state is a N-qubit state until a proper class for states
        # is in place
        state_size = len(state)
        state_dims = self._automatic_dims(None, state_size)
        if self.input_dims() != len(qargs) * (2, ):
            raise QiskitError(
                "Channel input dimensions are not compatible with state subsystem dimensions."
            )
        # Return evolved density matrix
        tensor = np.reshape(state, 2 * state_dims)
        num_inidices = len(state_dims)
        indices = [num_inidices - 1 - qubit for qubit in qargs
                   ] + [2 * num_inidices - 1 - qubit for qubit in qargs]
        tensor = self._einsum_matmul(tensor, mat, indices)
        return np.reshape(tensor, [state_size, state_size])
Evolve a quantum state by the operator.

        Args:
            state (QuantumState): The input statevector or density matrix.
            qargs (list): a list of QuantumState subsystem positions to apply
                           the operator on.

        Returns:
            QuantumState: the output quantum state.

        Raises:
            QiskitError: if the operator dimension does not match the
            specified QuantumState subsystem dimensions.