qiskit/quantum_info/operators/channel/superop.py
def compose(self, other, qargs=None, front=False):
        """Return the composition channel self∘other.

        Args:
            other (QuantumChannel): a quantum channel.
            qargs (list): a list of subsystem positions to compose other on.
            front (bool): If False compose in standard order other(self(input))
                          otherwise compose in reverse order self(other(input))
                          [default: False]

        Returns:
            SuperOp: The composition channel as a SuperOp object.

        Raises:
            QiskitError: if other is not a QuantumChannel subclass, or
            has incompatible dimensions.
        """
        # Convert other to SuperOp
        if not isinstance(other, SuperOp):
            other = SuperOp(other)
        # Check dimensions are compatible
        if front and self.input_dims(qargs=qargs) != other.output_dims():
            raise QiskitError(
                'output_dims of other must match subsystem input_dims')
        if not front and self.output_dims(qargs=qargs) != other.input_dims():
            raise QiskitError(
                'input_dims of other must match subsystem output_dims')

        # Full composition of superoperators
        if qargs is None:
            if front:
                # Composition A(B(input))
                return SuperOp(
                    np.dot(self._data, other.data),
                    input_dims=other.input_dims(),
                    output_dims=self.output_dims())
            # Composition B(A(input))
            return SuperOp(
                np.dot(other.data, self._data),
                input_dims=self.input_dims(),
                output_dims=other.output_dims())
        # Composition on subsystem
        return self._compose_subsystem(other, qargs, front)
def compose(self, other, qargs=None, front=False):
        """Return the composition channel self∘other.

        Args:
            other (QuantumChannel): a quantum channel.
            qargs (list): a list of subsystem positions to compose other on.
            front (bool): If False compose in standard order other(self(input))
                          otherwise compose in reverse order self(other(input))
                          [default: False]

        Returns:
            SuperOp: The composition channel as a SuperOp object.

        Raises:
            QiskitError: if other is not a QuantumChannel subclass, or
            has incompatible dimensions.
        """
        # Convert other to SuperOp
        if not isinstance(other, SuperOp):
            other = SuperOp(other)
        # Check dimensions are compatible
        if front and self.input_dims(qargs=qargs) != other.output_dims():
            raise QiskitError(
                'output_dims of other must match subsystem input_dims')
        if not front and self.output_dims(qargs=qargs) != other.input_dims():
            raise QiskitError(
                'input_dims of other must match subsystem output_dims')

        # Full composition of superoperators
        if qargs is None:
            if front:
                # Composition A(B(input))
                return SuperOp(
                    np.dot(self._data, other.data),
                    input_dims=other.input_dims(),
                    output_dims=self.output_dims())
            # Composition B(A(input))
            return SuperOp(
                np.dot(other.data, self._data),
                input_dims=self.input_dims(),
                output_dims=other.output_dims())
        # Composition on subsystem
        return self._compose_subsystem(other, qargs, front)
def compose ( self , other , qargs = None , front = False ) : # Convert other to SuperOp if not isinstance ( other , SuperOp ) : other = SuperOp ( other ) # Check dimensions are compatible if front and self . input_dims ( qargs = qargs ) != other . output_dims ( ) : raise QiskitError ( 'output_dims of other must match subsystem input_dims' ) if not front and self . output_dims ( qargs = qargs ) != other . input_dims ( ) : raise QiskitError ( 'input_dims of other must match subsystem output_dims' ) # Full composition of superoperators if qargs is None : if front : # Composition A(B(input)) return SuperOp ( np . dot ( self . _data , other . data ) , input_dims = other . input_dims ( ) , output_dims = self . output_dims ( ) ) # Composition B(A(input)) return SuperOp ( np . dot ( other . data , self . _data ) , input_dims = self . input_dims ( ) , output_dims = other . output_dims ( ) ) # Composition on subsystem return self . _compose_subsystem ( other , qargs , front )
Return the composition channel self∘other.

        Args:
            other (QuantumChannel): a quantum channel.
            qargs (list): a list of subsystem positions to compose other on.
            front (bool): If False compose in standard order other(self(input))
                          otherwise compose in reverse order self(other(input))
                          [default: False]

        Returns:
            SuperOp: The composition channel as a SuperOp object.

        Raises:
            QiskitError: if other is not a QuantumChannel subclass, or
            has incompatible dimensions.
Return the composition channel self∘other .