# -*- coding: utf-8 -*-

# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=invalid-name

"""Tests for Operator matrix linear operator class."""

import unittest
import logging
import copy
import numpy as np
from numpy.testing import assert_allclose
import scipy.linalg as la

from qiskit import QiskitError
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.extensions.standard import HGate, CHGate, CXGate
from qiskit.test import QiskitTestCase
from qiskit.quantum_info.operators.operator import Operator
from qiskit.quantum_info.operators.predicates import matrix_equal

logger = logging.getLogger(__name__)


class OperatorTestCase(QiskitTestCase):
    """Test utils for Operator"""

    # Pauli-matrix unitaries
    UI = np.eye(2)
    UX = np.array([[0, 1], [1, 0]])
    UY = np.array([[0, -1j], [1j, 0]])
    UZ = np.diag([1, -1])
    UH = np.array([[1, 1], [1, -1]]) / np.sqrt(2)

    @classmethod
    def rand_rho(cls, n):
        """Return random density matrix"""
        seed = np.random.randint(0, np.iinfo(np.int32).max)
        logger.debug("rand_rho RandomState seeded with seed=%s", seed)
        rng = np.random.RandomState(seed)

        psi = rng.rand(n) + 1j * rng.rand(n)
        rho = np.outer(psi, psi.conj())
        rho /= np.trace(rho)
        return rho

    @classmethod
    def rand_matrix(cls, rows, cols=None, real=False):
        """Return a random matrix."""
        seed = np.random.randint(0, np.iinfo(np.int32).max)
        logger.debug("rand_matrix RandomState seeded with seed=%s", seed)
        rng = np.random.RandomState(seed)

        if cols is None:
            cols = rows
        if real:
            return rng.rand(rows, cols)
        return rng.rand(rows, cols) + 1j * rng.rand(rows, cols)

    def simple_circuit_no_measure(self):
        """Return a unitary circuit and the corresponding unitary array."""
        qr = QuantumRegister(3)
        circ = QuantumCircuit(qr)
        circ.h(qr[0])
        circ.x(qr[1])
        circ.ry(np.pi / 2, qr[2])
        y90 = (1 / np.sqrt(2)) * np.array([[1, -1], [1, 1]])
        target = Operator(np.kron(y90, np.kron(self.UX, self.UH)))
        return circ, target

    def simple_circuit_with_measure(self):
        """Return a unitary circuit with measurement."""
        qr = QuantumRegister(2)
        cr = ClassicalRegister(2)
        circ = QuantumCircuit(qr, cr)
        circ.h(qr[0])
        circ.x(qr[1])
        circ.measure(qr, cr)
        return circ


class TestOperator(OperatorTestCase):
    """Tests for Operator linear operator class."""

    def test_init_array_qubit(self):
        """Test subsystem initialization from N-qubit array."""
        # Test automatic inference of qubit subsystems
        mat = self.rand_matrix(8, 8)
        op = Operator(mat)
        assert_allclose(op.data, mat)
        self.assertEqual(op.dim, (8, 8))
        self.assertEqual(op.input_dims(), (2, 2, 2))
        self.assertEqual(op.output_dims(), (2, 2, 2))

        op = Operator(mat, input_dims=8, output_dims=8)
        assert_allclose(op.data, mat)
        self.assertEqual(op.dim, (8, 8))
        self.assertEqual(op.input_dims(), (2, 2, 2))
        self.assertEqual(op.output_dims(), (2, 2, 2))

    def test_init_array(self):
        """Test initialization from array."""
        mat = np.eye(3)
        op = Operator(mat)
        assert_allclose(op.data, mat)
        self.assertEqual(op.dim, (3, 3))
        self.assertEqual(op.input_dims(), (3,))
        self.assertEqual(op.output_dims(), (3,))

        mat = self.rand_matrix(2 * 3 * 4, 4 * 5)
        op = Operator(mat, input_dims=[4, 5], output_dims=[2, 3, 4])
        assert_allclose(op.data, mat)
        self.assertEqual(op.dim, (4 * 5, 2 * 3 * 4))
        self.assertEqual(op.input_dims(), (4, 5))
        self.assertEqual(op.output_dims(), (2, 3, 4))

    def test_init_array_except(self):
        """Test initialization exception from array."""
        mat = self.rand_matrix(4, 4)
        self.assertRaises(QiskitError, Operator, mat, input_dims=[4, 2])
        self.assertRaises(QiskitError, Operator, mat, input_dims=[2, 4])
        self.assertRaises(QiskitError, Operator, mat, input_dims=5)

    def test_init_operator(self):
        """Test initialization from Operator."""
        op1 = Operator(self.rand_matrix(4, 4))
        op2 = Operator(op1)
        self.assertEqual(op1, op2)

    def test_circuit_init(self):
        """Test initialization from a circuit."""
        # Test tensor product of 1-qubit gates
        circuit = QuantumCircuit(3)
        circuit.h(0)
        circuit.x(1)
        circuit.ry(np.pi / 2, 2)
        op = Operator(circuit)
        y90 = (1 / np.sqrt(2)) * np.array([[1, -1], [1, 1]])
        target = np.kron(y90, np.kron(self.UX, self.UH))
        global_phase_equivalent = matrix_equal(
            op.data, target, ignore_phase=True)
        self.assertTrue(global_phase_equivalent)

        # Test decomposition of Controlled-u1 gate
        lam = np.pi / 4
        circuit = QuantumCircuit(2)
        circuit.cu1(lam, 0, 1)
        op = Operator(circuit)
        target = np.diag([1, 1, 1, np.exp(1j * lam)])
        global_phase_equivalent = matrix_equal(
            op.data, target, ignore_phase=True)
        self.assertTrue(global_phase_equivalent)

        # Test decomposition of controlled-H gate
        circuit = QuantumCircuit(2)
        circuit.ch(0, 1)
        op = Operator(circuit)
        target = np.kron(self.UI, np.diag([1, 0])) + np.kron(
            self.UH, np.diag([0, 1]))
        global_phase_equivalent = matrix_equal(
            op.data, target, ignore_phase=True)
        self.assertTrue(global_phase_equivalent)

    def test_instruction_init(self):
        """Test initialization from a circuit."""
        gate = CXGate()
        op = Operator(gate).data
        target = gate.to_matrix()
        global_phase_equivalent = matrix_equal(op, target, ignore_phase=True)
        self.assertTrue(global_phase_equivalent)

        gate = CHGate()
        op = Operator(gate).data
        had = HGate().to_matrix()
        target = np.kron(had, np.diag([0, 1])) + np.kron(
            np.eye(2), np.diag([1, 0]))
        global_phase_equivalent = matrix_equal(op, target, ignore_phase=True)
        self.assertTrue(global_phase_equivalent)

    def test_circuit_init_except(self):
        """Test initialization from circuit with measure raises exception."""
        circuit = self.simple_circuit_with_measure()
        self.assertRaises(QiskitError, Operator, circuit)

    def test_equal(self):
        """Test __eq__ method"""
        mat = self.rand_matrix(2, 2, real=True)
        self.assertEqual(Operator(np.array(mat, dtype=complex)),
                         Operator(mat))
        mat = self.rand_matrix(4, 4)
        self.assertEqual(Operator(mat.tolist()),
                         Operator(mat))

    def test_data(self):
        """Test Operator representation string property."""
        mat = self.rand_matrix(2, 2)
        op = Operator(mat)
        assert_allclose(mat, op.data)

    def test_dim(self):
        """Test Operator dim property."""
        mat = self.rand_matrix(4, 4)
        self.assertEqual(Operator(mat).dim, (4, 4))
        self.assertEqual(Operator(mat, input_dims=[4], output_dims=[4]).dim, (4, 4))
        self.assertEqual(Operator(mat, input_dims=[2, 2], output_dims=[2, 2]).dim, (4, 4))

    def test_input_dims(self):
        """Test Operator input_dims method."""
        op = Operator(self.rand_matrix(2 * 3 * 4, 4 * 5),
                      input_dims=[4, 5], output_dims=[2, 3, 4])
        self.assertEqual(op.input_dims(), (4, 5))
        self.assertEqual(op.input_dims(qargs=[0, 1]), (4, 5))
        self.assertEqual(op.input_dims(qargs=[1, 0]), (5, 4))
        self.assertEqual(op.input_dims(qargs=[0]), (4,))
        self.assertEqual(op.input_dims(qargs=[1]), (5,))

    def test_output_dims(self):
        """Test Operator output_dims method."""
        op = Operator(self.rand_matrix(2 * 3 * 4, 4 * 5),
                      input_dims=[4, 5], output_dims=[2, 3, 4])
        self.assertEqual(op.output_dims(), (2, 3, 4))
        self.assertEqual(op.output_dims(qargs=[0, 1, 2]), (2, 3, 4))
        self.assertEqual(op.output_dims(qargs=[2, 1, 0]), (4, 3, 2))
        self.assertEqual(op.output_dims(qargs=[2, 0, 1]), (4, 2, 3))
        self.assertEqual(op.output_dims(qargs=[0]), (2,))
        self.assertEqual(op.output_dims(qargs=[1]), (3,))
        self.assertEqual(op.output_dims(qargs=[2]), (4,))
        self.assertEqual(op.output_dims(qargs=[0, 2]), (2, 4))
        self.assertEqual(op.output_dims(qargs=[2, 0]), (4, 2))

    def test_reshape(self):
        """Test Operator reshape method."""
        op = Operator(self.rand_matrix(8, 8))
        reshaped1 = op.reshape(input_dims=[8], output_dims=[8])
        reshaped2 = op.reshape(input_dims=[4, 2], output_dims=[2, 4])
        self.assertEqual(op.output_dims(), (2, 2, 2))
        self.assertEqual(op.input_dims(), (2, 2, 2))
        self.assertEqual(reshaped1.output_dims(), (8,))
        self.assertEqual(reshaped1.input_dims(), (8,))
        self.assertEqual(reshaped2.output_dims(), (2, 4))
        self.assertEqual(reshaped2.input_dims(), (4, 2))

    def test_copy(self):
        """Test Operator copy method"""
        mat = np.eye(2)
        with self.subTest("Deep copy"):
            orig = Operator(mat)
            cpy = orig.copy()
            cpy._data[0, 0] = 0.0
            self.assertFalse(cpy == orig)
        with self.subTest("Shallow copy"):
            orig = Operator(mat)
            clone = copy.copy(orig)
            clone._data[0, 0] = 0.0
            self.assertTrue(clone == orig)

    def test_is_unitary(self):
        """Test is_unitary method."""
        # X-90 rotation
        X90 = la.expm(-1j * 0.5 * np.pi * np.array([[0, 1], [1, 0]]) / 2)
        self.assertTrue(Operator(X90).is_unitary())
        # Non-unitary should return false
        self.assertFalse(Operator([[1, 0], [0, 0]]).is_unitary())

    def test_to_operator(self):
        """Test to_operator method."""
        op1 = Operator(self.rand_matrix(4, 4))
        op2 = op1.to_operator()
        self.assertEqual(op1, op2)

    def test_conjugate(self):
        """Test conjugate method."""
        matr = self.rand_matrix(2, 4, real=True)
        mati = self.rand_matrix(2, 4, real=True)
        op = Operator(matr + 1j * mati)
        uni_conj = op.conjugate()
        self.assertEqual(uni_conj, Operator(matr - 1j * mati))

    def test_transpose(self):
        """Test transpose method."""
        matr = self.rand_matrix(2, 4, real=True)
        mati = self.rand_matrix(2, 4, real=True)
        op = Operator(matr + 1j * mati)
        uni_t = op.transpose()
        self.assertEqual(uni_t, Operator(matr.T + 1j * mati.T))

    def test_adjoint(self):
        """Test adjoint method."""
        matr = self.rand_matrix(2, 4, real=True)
        mati = self.rand_matrix(2, 4, real=True)
        op = Operator(matr + 1j * mati)
        uni_adj = op.adjoint()
        self.assertEqual(uni_adj, Operator(matr.T - 1j * mati.T))

    def test_compose_except(self):
        """Test compose different dimension exception"""
        self.assertRaises(QiskitError,
                          Operator(np.eye(2)).compose,
                          Operator(np.eye(3)))
        self.assertRaises(QiskitError, Operator(np.eye(2)).compose, 2)

    def test_compose(self):
        """Test compose method."""

        op1 = Operator(self.UX)
        op2 = Operator(self.UY)

        targ = Operator(np.dot(self.UY, self.UX))
        self.assertEqual(op1.compose(op2), targ)
        self.assertEqual(op1 @ op2, targ)

        targ = Operator(np.dot(self.UX, self.UY))
        self.assertEqual(op2.compose(op1), targ)
        self.assertEqual(op2 @ op1, targ)

    def test_dot(self):
        """Test dot method."""
        op1 = Operator(self.UY)
        op2 = Operator(self.UX)

        targ = Operator(np.dot(self.UY, self.UX))
        self.assertEqual(op1.dot(op2), targ)
        self.assertEqual(op1 * op2, targ)

        targ = Operator(np.dot(self.UX, self.UY))
        self.assertEqual(op2.dot(op1), targ)
        self.assertEqual(op2 * op1, targ)

    def test_compose_front(self):
        """Test front compose method."""

        opYX = Operator(self.UY).compose(Operator(self.UX), front=True)
        matYX = np.dot(self.UY, self.UX)
        self.assertEqual(opYX, Operator(matYX))

        opXY = Operator(self.UX).compose(Operator(self.UY), front=True)
        matXY = np.dot(self.UX, self.UY)
        self.assertEqual(opXY, Operator(matXY))

    def test_compose_subsystem(self):
        """Test subsystem compose method."""
        # 3-qubit operator
        mat = self.rand_matrix(8, 8)
        mat_a = self.rand_matrix(2, 2)
        mat_b = self.rand_matrix(2, 2)
        mat_c = self.rand_matrix(2, 2)
        op = Operator(mat)
        op1 = Operator(mat_a)
        op2 = Operator(np.kron(mat_b, mat_a))
        op3 = Operator(np.kron(mat_c, np.kron(mat_b, mat_a)))

        # op3 qargs=[0, 1, 2]
        targ = np.dot(np.kron(mat_c, np.kron(mat_b, mat_a)), mat)
        self.assertEqual(op.compose(op3, qargs=[0, 1, 2]), Operator(targ))
        self.assertEqual(op.compose(op3([0, 1, 2])), Operator(targ))
        self.assertEqual(op @ op3([0, 1, 2]), Operator(targ))
        # op3 qargs=[2, 1, 0]
        targ = np.dot(np.kron(mat_a, np.kron(mat_b, mat_c)), mat)
        self.assertEqual(op.compose(op3, qargs=[2, 1, 0]), Operator(targ))
        self.assertEqual(op @ op3([2, 1, 0]), Operator(targ))

        # op2 qargs=[0, 1]
        targ = np.dot(np.kron(np.eye(2), np.kron(mat_b, mat_a)), mat)
        self.assertEqual(op.compose(op2, qargs=[0, 1]), Operator(targ))
        self.assertEqual(op @ op2([0, 1]), Operator(targ))
        # op2 qargs=[2, 0]
        targ = np.dot(np.kron(mat_a, np.kron(np.eye(2), mat_b)), mat)
        self.assertEqual(op.compose(op2, qargs=[2, 0]), Operator(targ))
        self.assertEqual(op @ op2([2, 0]), Operator(targ))

        # op1 qargs=[0]
        targ = np.dot(np.kron(np.eye(4), mat_a), mat)
        self.assertEqual(op.compose(op1, qargs=[0]), Operator(targ))
        self.assertEqual(op @ op1([0]), Operator(targ))
        # op1 qargs=[1]
        targ = np.dot(np.kron(np.eye(2), np.kron(mat_a, np.eye(2))), mat)
        self.assertEqual(op.compose(op1, qargs=[1]), Operator(targ))
        self.assertEqual(op @ op1([1]), Operator(targ))
        # op1 qargs=[2]
        targ = np.dot(np.kron(mat_a, np.eye(4)), mat)
        self.assertEqual(op.compose(op1, qargs=[2]), Operator(targ))
        self.assertEqual(op @ op1([2]), Operator(targ))

    def test_dot_subsystem(self):
        """Test subsystem dot method."""
        # 3-qubit operator
        mat = self.rand_matrix(8, 8)
        mat_a = self.rand_matrix(2, 2)
        mat_b = self.rand_matrix(2, 2)
        mat_c = self.rand_matrix(2, 2)
        op = Operator(mat)
        op1 = Operator(mat_a)
        op2 = Operator(np.kron(mat_b, mat_a))
        op3 = Operator(np.kron(mat_c, np.kron(mat_b, mat_a)))

        # op3 qargs=[0, 1, 2]
        targ = np.dot(mat, np.kron(mat_c, np.kron(mat_b, mat_a)))
        self.assertEqual(op.dot(op3, qargs=[0, 1, 2]), Operator(targ))
        self.assertEqual(op * op3([0, 1, 2]), Operator(targ))
        # op3 qargs=[2, 1, 0]
        targ = np.dot(mat, np.kron(mat_a, np.kron(mat_b, mat_c)))
        self.assertEqual(op.dot(op3, qargs=[2, 1, 0]), Operator(targ))
        self.assertEqual(op * op3([2, 1, 0]), Operator(targ))

        # op2 qargs=[0, 1]
        targ = np.dot(mat, np.kron(np.eye(2), np.kron(mat_b, mat_a)))
        self.assertEqual(op.dot(op2, qargs=[0, 1]), Operator(targ))
        self.assertEqual(op * op2([0, 1]), Operator(targ))
        # op2 qargs=[2, 0]
        targ = np.dot(mat, np.kron(mat_a, np.kron(np.eye(2), mat_b)))
        self.assertEqual(op.dot(op2, qargs=[2, 0]), Operator(targ))
        self.assertEqual(op * op2([2, 0]), Operator(targ))

        # op1 qargs=[0]
        targ = np.dot(mat, np.kron(np.eye(4), mat_a))
        self.assertEqual(op.dot(op1, qargs=[0]), Operator(targ))
        self.assertEqual(op * op1([0]), Operator(targ))
        # op1 qargs=[1]
        targ = np.dot(mat, np.kron(np.eye(2), np.kron(mat_a, np.eye(2))))
        self.assertEqual(op.dot(op1, qargs=[1]), Operator(targ))
        self.assertEqual(op * op1([1]), Operator(targ))
        # op1 qargs=[2]
        targ = np.dot(mat, np.kron(mat_a, np.eye(4)))
        self.assertEqual(op.dot(op1, qargs=[2]), Operator(targ))
        self.assertEqual(op * op1([2]), Operator(targ))

    def test_compose_front_subsystem(self):
        """Test subsystem front compose method."""
        # 3-qubit operator
        mat = self.rand_matrix(8, 8)
        mat_a = self.rand_matrix(2, 2)
        mat_b = self.rand_matrix(2, 2)
        mat_c = self.rand_matrix(2, 2)
        op = Operator(mat)
        op1 = Operator(mat_a)
        op2 = Operator(np.kron(mat_b, mat_a))
        op3 = Operator(np.kron(mat_c, np.kron(mat_b, mat_a)))

        # op3 qargs=[0, 1, 2]
        targ = np.dot(mat, np.kron(mat_c, np.kron(mat_b, mat_a)))
        self.assertEqual(op.compose(op3, qargs=[0, 1, 2], front=True), Operator(targ))
        # op3 qargs=[2, 1, 0]
        targ = np.dot(mat, np.kron(mat_a, np.kron(mat_b, mat_c)))
        self.assertEqual(op.compose(op3, qargs=[2, 1, 0], front=True), Operator(targ))

        # op2 qargs=[0, 1]
        targ = np.dot(mat, np.kron(np.eye(2), np.kron(mat_b, mat_a)))
        self.assertEqual(op.compose(op2, qargs=[0, 1], front=True), Operator(targ))
        # op2 qargs=[2, 0]
        targ = np.dot(mat, np.kron(mat_a, np.kron(np.eye(2), mat_b)))
        self.assertEqual(op.compose(op2, qargs=[2, 0], front=True), Operator(targ))

        # op1 qargs=[0]
        targ = np.dot(mat, np.kron(np.eye(4), mat_a))
        self.assertEqual(op.compose(op1, qargs=[0], front=True), Operator(targ))

        # op1 qargs=[1]
        targ = np.dot(mat, np.kron(np.eye(2), np.kron(mat_a, np.eye(2))))
        self.assertEqual(op.compose(op1, qargs=[1], front=True), Operator(targ))

        # op1 qargs=[2]
        targ = np.dot(mat, np.kron(mat_a, np.eye(4)))
        self.assertEqual(op.compose(op1, qargs=[2], front=True), Operator(targ))

    def test_power(self):
        """Test power method."""
        X90 = la.expm(-1j * 0.5 * np.pi * np.array([[0, 1], [1, 0]]) / 2)
        op = Operator(X90)
        self.assertEqual(op.power(2), Operator([[0, -1j], [-1j, 0]]))
        self.assertEqual(op.power(4), Operator(-1 * np.eye(2)))
        self.assertEqual(op.power(8), Operator(np.eye(2)))

    def test_expand(self):
        """Test expand method."""
        mat1 = self.UX
        mat2 = np.eye(3, dtype=complex)

        mat21 = np.kron(mat2, mat1)
        op21 = Operator(mat1).expand(Operator(mat2))
        self.assertEqual(op21.dim, (6, 6))
        assert_allclose(op21.data, Operator(mat21).data)

        mat12 = np.kron(mat1, mat2)
        op12 = Operator(mat2).expand(Operator(mat1))
        self.assertEqual(op12.dim, (6, 6))
        assert_allclose(op12.data, Operator(mat12).data)

    def test_tensor(self):
        """Test tensor method."""
        mat1 = self.UX
        mat2 = np.eye(3, dtype=complex)

        mat21 = np.kron(mat2, mat1)
        op21 = Operator(mat2).tensor(Operator(mat1))
        self.assertEqual(op21.dim, (6, 6))
        assert_allclose(op21.data, Operator(mat21).data)

        mat12 = np.kron(mat1, mat2)
        op12 = Operator(mat1).tensor(Operator(mat2))
        self.assertEqual(op12.dim, (6, 6))
        assert_allclose(op12.data, Operator(mat12).data)

    def test_power_except(self):
        """Test power method raises exceptions."""
        op = Operator(self.rand_matrix(3, 3))
        # Non-integer power raises error
        self.assertRaises(QiskitError, op.power, 0.5)

    def test_add(self):
        """Test add method."""
        mat1 = self.rand_matrix(4, 4)
        mat2 = self.rand_matrix(4, 4)
        op1 = Operator(mat1)
        op2 = Operator(mat2)
        self.assertEqual(op1._add(op2), Operator(mat1 + mat2))
        self.assertEqual(op1 + op2, Operator(mat1 + mat2))
        self.assertEqual(op1 - op2, Operator(mat1 - mat2))

    def test_add_except(self):
        """Test add method raises exceptions."""
        op1 = Operator(self.rand_matrix(2, 2))
        op2 = Operator(self.rand_matrix(3, 3))
        self.assertRaises(QiskitError, op1._add, op2)

    def test_multiply(self):
        """Test multiply method."""
        mat = self.rand_matrix(4, 4)
        val = np.exp(5j)
        op = Operator(mat)
        self.assertEqual(op._multiply(val), Operator(val * mat))
        self.assertEqual(val * op, Operator(val * mat))

    def test_multiply_except(self):
        """Test multiply method raises exceptions."""
        op = Operator(self.rand_matrix(2, 2))
        self.assertRaises(QiskitError, op._multiply, 's')
        self.assertRaises(QiskitError, op.__rmul__, 's')
        self.assertRaises(QiskitError, op._multiply, op)
        self.assertRaises(QiskitError, op.__rmul__, op)

    def test_negate(self):
        """Test negate method"""
        mat = self.rand_matrix(4, 4)
        op = Operator(mat)
        self.assertEqual(-op, Operator(-1 * mat))

    def test_equiv(self):
        """Test negate method"""
        mat = np.diag([1, np.exp(1j * np.pi / 2)])
        phase = np.exp(-1j * np.pi / 4)
        op = Operator(mat)
        self.assertTrue(op.equiv(phase * mat))
        self.assertTrue(op.equiv(Operator(phase * mat)))
        self.assertFalse(op.equiv(2 * mat))


if __name__ == '__main__':
    unittest.main()

[((1065, 1092), 'logging.getLogger', 'logging.getLogger', (['__name__'], {}), '(__name__)\n', (1082, 1092), False, 'import logging\n'), ((1208, 1217), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (1214, 1217), True, 'import numpy as np\n'), ((1227, 1253), 'numpy.array', 'np.array', (['[[0, 1], [1, 0]]'], {}), '([[0, 1], [1, 0]])\n', (1235, 1253), True, 'import numpy as np\n'), ((1263, 1296), 'numpy.array', 'np.array', (['[[0, -1.0j], [1.0j, 0]]'], {}), '([[0, -1.0j], [1.0j, 0]])\n', (1271, 1296), True, 'import numpy as np\n'), ((1302, 1318), 'numpy.diag', 'np.diag', (['[1, -1]'], {}), '([1, -1])\n', (1309, 1318), True, 'import numpy as np\n'), ((22115, 22130), 'unittest.main', 'unittest.main', ([], {}), '()\n', (22128, 22130), False, 'import unittest\n'), ((1328, 1355), 'numpy.array', 'np.array', (['[[1, 1], [1, -1]]'], {}), '([[1, 1], [1, -1]])\n', (1336, 1355), True, 'import numpy as np\n'), ((1358, 1368), 'numpy.sqrt', 'np.sqrt', (['(2)'], {}), '(2)\n', (1365, 1368), True, 'import numpy as np\n'), ((1601, 1628), 'numpy.random.RandomState', 'np.random.RandomState', (['seed'], {}), '(seed)\n', (1622, 1628), True, 'import numpy as np\n'), ((1730, 1743), 'numpy.trace', 'np.trace', (['rho'], {}), '(rho)\n', (1738, 1743), True, 'import numpy as np\n'), ((2022, 2049), 'numpy.random.RandomState', 'np.random.RandomState', (['seed'], {}), '(seed)\n', (2043, 2049), True, 'import numpy as np\n'), ((2352, 2370), 'qiskit.QuantumRegister', 'QuantumRegister', (['(3)'], {}), '(3)\n', (2367, 2370), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((2386, 2404), 'qiskit.QuantumCircuit', 'QuantumCircuit', (['qr'], {}), '(qr)\n', (2400, 2404), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((2753, 2771), 'qiskit.QuantumRegister', 'QuantumRegister', (['(2)'], {}), '(2)\n', (2768, 2771), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((2785, 2805), 'qiskit.ClassicalRegister', 'ClassicalRegister', (['(2)'], {}), '(2)\n', (2802, 2805), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((2821, 2843), 'qiskit.QuantumCircuit', 'QuantumCircuit', (['qr', 'cr'], {}), '(qr, cr)\n', (2835, 2843), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((3236, 3249), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (3244, 3249), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((3258, 3287), 'numpy.testing.assert_allclose', 'assert_allclose', (['op.data', 'mat'], {}), '(op.data, mat)\n', (3273, 3287), False, 'from numpy.testing import assert_allclose\n'), ((3450, 3492), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {'input_dims': '(8)', 'output_dims': '(8)'}), '(mat, input_dims=8, output_dims=8)\n', (3458, 3492), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((3501, 3530), 'numpy.testing.assert_allclose', 'assert_allclose', (['op.data', 'mat'], {}), '(op.data, mat)\n', (3516, 3530), False, 'from numpy.testing import assert_allclose\n'), ((3771, 3780), 'numpy.eye', 'np.eye', (['(3)'], {}), '(3)\n', (3777, 3780), True, 'import numpy as np\n'), ((3794, 3807), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (3802, 3807), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((3816, 3845), 'numpy.testing.assert_allclose', 'assert_allclose', (['op.data', 'mat'], {}), '(op.data, mat)\n', (3831, 3845), False, 'from numpy.testing import assert_allclose\n'), ((4047, 4102), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {'input_dims': '[4, 5]', 'output_dims': '[2, 3, 4]'}), '(mat, input_dims=[4, 5], output_dims=[2, 3, 4])\n', (4055, 4102), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((4111, 4140), 'numpy.testing.assert_allclose', 'assert_allclose', (['op.data', 'mat'], {}), '(op.data, mat)\n', (4126, 4140), False, 'from numpy.testing import assert_allclose\n'), ((4789, 4802), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['op1'], {}), '(op1)\n', (4797, 4802), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((4987, 5004), 'qiskit.QuantumCircuit', 'QuantumCircuit', (['(3)'], {}), '(3)\n', (5001, 5004), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((5093, 5110), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['circuit'], {}), '(circuit)\n', (5101, 5110), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((5263, 5311), 'qiskit.quantum_info.operators.predicates.matrix_equal', 'matrix_equal', (['op.data', 'target'], {'ignore_phase': '(True)'}), '(op.data, target, ignore_phase=True)\n', (5275, 5311), False, 'from qiskit.quantum_info.operators.predicates import matrix_equal\n'), ((5468, 5485), 'qiskit.QuantumCircuit', 'QuantumCircuit', (['(2)'], {}), '(2)\n', (5482, 5485), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((5530, 5547), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['circuit'], {}), '(circuit)\n', (5538, 5547), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((5636, 5684), 'qiskit.quantum_info.operators.predicates.matrix_equal', 'matrix_equal', (['op.data', 'target'], {'ignore_phase': '(True)'}), '(op.data, target, ignore_phase=True)\n', (5648, 5684), False, 'from qiskit.quantum_info.operators.predicates import matrix_equal\n'), ((5816, 5833), 'qiskit.QuantumCircuit', 'QuantumCircuit', (['(2)'], {}), '(2)\n', (5830, 5833), False, 'from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n'), ((5872, 5889), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['circuit'], {}), '(circuit)\n', (5880, 5889), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((6024, 6072), 'qiskit.quantum_info.operators.predicates.matrix_equal', 'matrix_equal', (['op.data', 'target'], {'ignore_phase': '(True)'}), '(op.data, target, ignore_phase=True)\n', (6036, 6072), False, 'from qiskit.quantum_info.operators.predicates import matrix_equal\n'), ((6238, 6246), 'qiskit.extensions.standard.CXGate', 'CXGate', ([], {}), '()\n', (6244, 6246), False, 'from qiskit.extensions.standard import HGate, CHGate, CXGate\n'), ((6348, 6391), 'qiskit.quantum_info.operators.predicates.matrix_equal', 'matrix_equal', (['op', 'target'], {'ignore_phase': '(True)'}), '(op, target, ignore_phase=True)\n', (6360, 6391), False, 'from qiskit.quantum_info.operators.predicates import matrix_equal\n'), ((6457, 6465), 'qiskit.extensions.standard.CHGate', 'CHGate', ([], {}), '()\n', (6463, 6465), False, 'from qiskit.extensions.standard import HGate, CHGate, CXGate\n'), ((6665, 6708), 'qiskit.quantum_info.operators.predicates.matrix_equal', 'matrix_equal', (['op', 'target'], {'ignore_phase': '(True)'}), '(op, target, ignore_phase=True)\n', (6677, 6708), False, 'from qiskit.quantum_info.operators.predicates import matrix_equal\n'), ((7463, 7476), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (7471, 7476), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((7485, 7514), 'numpy.testing.assert_allclose', 'assert_allclose', (['mat', 'op.data'], {}), '(mat, op.data)\n', (7500, 7514), False, 'from numpy.testing import assert_allclose\n'), ((9766, 9775), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (9772, 9775), True, 'import numpy as np\n'), ((10839, 10867), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(matr + 1.0j * mati)'], {}), '(matr + 1.0j * mati)\n', (10847, 10867), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11142, 11170), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(matr + 1.0j * mati)'], {}), '(matr + 1.0j * mati)\n', (11150, 11170), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11439, 11467), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(matr + 1.0j * mati)'], {}), '(matr + 1.0j * mati)\n', (11447, 11467), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11947, 11964), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UX'], {}), '(self.UX)\n', (11955, 11964), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11979, 11996), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UY'], {}), '(self.UY)\n', (11987, 11996), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((12351, 12368), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UY'], {}), '(self.UY)\n', (12359, 12368), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((12383, 12400), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UX'], {}), '(self.UX)\n', (12391, 12400), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((12842, 12866), 'numpy.dot', 'np.dot', (['self.UY', 'self.UX'], {}), '(self.UY, self.UX)\n', (12848, 12866), True, 'import numpy as np\n'), ((13004, 13028), 'numpy.dot', 'np.dot', (['self.UX', 'self.UY'], {}), '(self.UX, self.UY)\n', (13010, 13028), True, 'import numpy as np\n'), ((13355, 13368), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (13363, 13368), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((13383, 13398), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat_a'], {}), '(mat_a)\n', (13391, 13398), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15400, 15413), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (15408, 15413), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15428, 15443), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat_a'], {}), '(mat_a)\n', (15436, 15443), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((17368, 17381), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (17376, 17381), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((17396, 17411), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat_a'], {}), '(mat_a)\n', (17404, 17411), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((18897, 18910), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['X90'], {}), '(X90)\n', (18905, 18910), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19204, 19228), 'numpy.eye', 'np.eye', (['(3)'], {'dtype': 'complex'}), '(3, dtype=complex)\n', (19210, 19228), True, 'import numpy as np\n'), ((19246, 19265), 'numpy.kron', 'np.kron', (['mat2', 'mat1'], {}), '(mat2, mat1)\n', (19253, 19265), True, 'import numpy as np\n'), ((19436, 19455), 'numpy.kron', 'np.kron', (['mat1', 'mat2'], {}), '(mat1, mat2)\n', (19443, 19455), True, 'import numpy as np\n'), ((19709, 19733), 'numpy.eye', 'np.eye', (['(3)'], {'dtype': 'complex'}), '(3, dtype=complex)\n', (19715, 19733), True, 'import numpy as np\n'), ((19751, 19770), 'numpy.kron', 'np.kron', (['mat2', 'mat1'], {}), '(mat2, mat1)\n', (19758, 19770), True, 'import numpy as np\n'), ((19941, 19960), 'numpy.kron', 'np.kron', (['mat1', 'mat2'], {}), '(mat1, mat2)\n', (19948, 19960), True, 'import numpy as np\n'), ((20486, 20500), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat1'], {}), '(mat1)\n', (20494, 20500), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((20515, 20529), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat2'], {}), '(mat2)\n', (20523, 20529), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((21057, 21069), 'numpy.exp', 'np.exp', (['(5.0j)'], {}), '(5.0j)\n', (21063, 21069), True, 'import numpy as np\n'), ((21081, 21094), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (21089, 21094), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((21692, 21705), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (21700, 21705), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((21883, 21908), 'numpy.exp', 'np.exp', (['(-1.0j * np.pi / 4)'], {}), '(-1.0j * np.pi / 4)\n', (21889, 21908), True, 'import numpy as np\n'), ((21920, 21933), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (21928, 21933), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((2516, 2543), 'numpy.array', 'np.array', (['[[1, -1], [1, 1]]'], {}), '([[1, -1], [1, 1]])\n', (2524, 2543), True, 'import numpy as np\n'), ((5144, 5171), 'numpy.array', 'np.array', (['[[1, -1], [1, 1]]'], {}), '([[1, -1], [1, 1]])\n', (5152, 5171), True, 'import numpy as np\n'), ((5202, 5227), 'numpy.kron', 'np.kron', (['self.UX', 'self.UH'], {}), '(self.UX, self.UH)\n', (5209, 5227), True, 'import numpy as np\n'), ((6260, 6274), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['gate'], {}), '(gate)\n', (6268, 6274), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((6479, 6493), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['gate'], {}), '(gate)\n', (6487, 6493), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((7186, 7199), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (7194, 7199), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((7312, 7325), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (7320, 7325), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((9835, 9848), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (9843, 9848), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((10017, 10030), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (10025, 10030), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((10051, 10066), 'copy.copy', 'copy.copy', (['orig'], {}), '(orig)\n', (10060, 10066), False, 'import copy\n'), ((10935, 10963), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(matr - 1.0j * mati)'], {}), '(matr - 1.0j * mati)\n', (10943, 10963), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11232, 11264), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(matr.T + 1.0j * mati.T)'], {}), '(matr.T + 1.0j * mati.T)\n', (11240, 11264), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11531, 11563), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(matr.T - 1.0j * mati.T)'], {}), '(matr.T - 1.0j * mati.T)\n', (11539, 11563), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((12022, 12046), 'numpy.dot', 'np.dot', (['self.UY', 'self.UX'], {}), '(self.UY, self.UX)\n', (12028, 12046), True, 'import numpy as np\n'), ((12164, 12188), 'numpy.dot', 'np.dot', (['self.UX', 'self.UY'], {}), '(self.UX, self.UY)\n', (12170, 12188), True, 'import numpy as np\n'), ((12426, 12450), 'numpy.dot', 'np.dot', (['self.UY', 'self.UX'], {}), '(self.UY, self.UX)\n', (12432, 12450), True, 'import numpy as np\n'), ((12564, 12588), 'numpy.dot', 'np.dot', (['self.UX', 'self.UY'], {}), '(self.UX, self.UY)\n', (12570, 12588), True, 'import numpy as np\n'), ((12795, 12812), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UX'], {}), '(self.UX)\n', (12803, 12812), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((12898, 12913), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['matYX'], {}), '(matYX)\n', (12906, 12913), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((12957, 12974), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UY'], {}), '(self.UY)\n', (12965, 12974), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((13060, 13075), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['matXY'], {}), '(matXY)\n', (13068, 13075), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((13422, 13443), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (13429, 13443), True, 'import numpy as np\n'), ((13663, 13677), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (13671, 13677), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((13732, 13746), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (13740, 13746), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((13794, 13808), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (13802, 13808), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((13965, 13979), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (13973, 13979), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14027, 14041), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14035, 14041), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14197, 14211), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14205, 14211), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14256, 14270), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14264, 14270), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14425, 14439), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14433, 14439), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14484, 14498), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14492, 14498), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14632, 14646), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14640, 14646), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14688, 14702), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14696, 14702), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14855, 14869), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14863, 14869), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((14911, 14925), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (14919, 14925), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15058, 15072), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (15066, 15072), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15114, 15128), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (15122, 15128), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15467, 15488), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (15474, 15488), True, 'import numpy as np\n'), ((15704, 15718), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (15712, 15718), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15766, 15780), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (15774, 15780), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15933, 15947), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (15941, 15947), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((15995, 16009), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16003, 16009), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16161, 16175), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16169, 16175), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16220, 16234), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16228, 16234), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16385, 16399), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16393, 16399), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16444, 16458), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16452, 16458), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16588, 16602), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16596, 16602), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16644, 16658), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16652, 16658), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16807, 16821), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16815, 16821), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((16863, 16877), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (16871, 16877), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((17006, 17020), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (17014, 17020), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((17062, 17076), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (17070, 17076), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((17435, 17456), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (17442, 17456), True, 'import numpy as np\n'), ((17688, 17702), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (17696, 17702), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((17871, 17885), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (17879, 17885), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((18053, 18067), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (18061, 18067), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((18234, 18248), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (18242, 18248), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((18394, 18408), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (18402, 18408), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((18574, 18588), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (18582, 18588), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((18734, 18748), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['targ'], {}), '(targ)\n', (18742, 18748), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((18949, 18983), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['[[0, -1.0j], [-1.0j, 0]]'], {}), '([[0, -1.0j], [-1.0j, 0]])\n', (18957, 18983), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19303, 19317), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat2'], {}), '(mat2)\n', (19311, 19317), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19493, 19507), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat1'], {}), '(mat1)\n', (19501, 19507), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19808, 19822), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat1'], {}), '(mat1)\n', (19816, 19822), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19998, 20012), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat2'], {}), '(mat2)\n', (20006, 20012), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((20570, 20591), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(mat1 + mat2)'], {}), '(mat1 + mat2)\n', (20578, 20591), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((20629, 20650), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(mat1 + mat2)'], {}), '(mat1 + mat2)\n', (20637, 20650), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((20688, 20709), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(mat1 - mat2)'], {}), '(mat1 - mat2)\n', (20696, 20709), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((21139, 21158), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(val * mat)'], {}), '(val * mat)\n', (21147, 21158), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((21195, 21214), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(val * mat)'], {}), '(val * mat)\n', (21203, 21214), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((21736, 21754), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(-1 * mat)'], {}), '(-1 * mat)\n', (21744, 21754), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((1492, 1510), 'numpy.iinfo', 'np.iinfo', (['np.int32'], {}), '(np.int32)\n', (1500, 1510), True, 'import numpy as np\n'), ((1910, 1928), 'numpy.iinfo', 'np.iinfo', (['np.int32'], {}), '(np.int32)\n', (1918, 1928), True, 'import numpy as np\n'), ((2502, 2512), 'numpy.sqrt', 'np.sqrt', (['(2)'], {}), '(2)\n', (2509, 2512), True, 'import numpy as np\n'), ((2583, 2608), 'numpy.kron', 'np.kron', (['self.UX', 'self.UH'], {}), '(self.UX, self.UH)\n', (2590, 2608), True, 'import numpy as np\n'), ((5130, 5140), 'numpy.sqrt', 'np.sqrt', (['(2)'], {}), '(2)\n', (5137, 5140), True, 'import numpy as np\n'), ((5583, 5601), 'numpy.exp', 'np.exp', (['(1.0j * lam)'], {}), '(1.0j * lam)\n', (5589, 5601), True, 'import numpy as np\n'), ((5924, 5939), 'numpy.diag', 'np.diag', (['[1, 0]'], {}), '([1, 0])\n', (5931, 5939), True, 'import numpy as np\n'), ((5973, 5988), 'numpy.diag', 'np.diag', (['[0, 1]'], {}), '([0, 1])\n', (5980, 5988), True, 'import numpy as np\n'), ((6513, 6520), 'qiskit.extensions.standard.HGate', 'HGate', ([], {}), '()\n', (6518, 6520), False, 'from qiskit.extensions.standard import HGate, CHGate, CXGate\n'), ((6563, 6578), 'numpy.diag', 'np.diag', (['[0, 1]'], {}), '([0, 1])\n', (6570, 6578), True, 'import numpy as np\n'), ((6603, 6612), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (6609, 6612), True, 'import numpy as np\n'), ((6614, 6629), 'numpy.diag', 'np.diag', (['[1, 0]'], {}), '([1, 0])\n', (6621, 6629), True, 'import numpy as np\n'), ((7130, 7158), 'numpy.array', 'np.array', (['mat'], {'dtype': 'complex'}), '(mat, dtype=complex)\n', (7138, 7158), True, 'import numpy as np\n'), ((7644, 7657), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {}), '(mat)\n', (7652, 7657), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((7696, 7742), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {'input_dims': '[4]', 'output_dims': '[4]'}), '(mat, input_dims=[4], output_dims=[4])\n', (7704, 7742), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((7781, 7833), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat'], {'input_dims': '[2, 2]', 'output_dims': '[2, 2]'}), '(mat, input_dims=[2, 2], output_dims=[2, 2])\n', (7789, 7833), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11785, 11794), 'numpy.eye', 'np.eye', (['(3)'], {}), '(3)\n', (11791, 11794), True, 'import numpy as np\n'), ((12769, 12786), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UY'], {}), '(self.UY)\n', (12777, 12786), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((12931, 12948), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['self.UX'], {}), '(self.UX)\n', (12939, 12948), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((13483, 13504), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (13490, 13504), True, 'import numpy as np\n'), ((13575, 13596), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (13582, 13596), True, 'import numpy as np\n'), ((13877, 13898), 'numpy.kron', 'np.kron', (['mat_b', 'mat_c'], {}), '(mat_b, mat_c)\n', (13884, 13898), True, 'import numpy as np\n'), ((14101, 14110), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (14107, 14110), True, 'import numpy as np\n'), ((14112, 14133), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (14119, 14133), True, 'import numpy as np\n'), ((14555, 14564), 'numpy.eye', 'np.eye', (['(4)'], {}), '(4)\n', (14561, 14564), True, 'import numpy as np\n'), ((14758, 14767), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (14764, 14767), True, 'import numpy as np\n'), ((14988, 14997), 'numpy.eye', 'np.eye', (['(4)'], {}), '(4)\n', (14994, 14997), True, 'import numpy as np\n'), ((15528, 15549), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (15535, 15549), True, 'import numpy as np\n'), ((15625, 15646), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (15632, 15646), True, 'import numpy as np\n'), ((15854, 15875), 'numpy.kron', 'np.kron', (['mat_b', 'mat_c'], {}), '(mat_b, mat_c)\n', (15861, 15875), True, 'import numpy as np\n'), ((16074, 16083), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (16080, 16083), True, 'import numpy as np\n'), ((16085, 16106), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (16092, 16106), True, 'import numpy as np\n'), ((16520, 16529), 'numpy.eye', 'np.eye', (['(4)'], {}), '(4)\n', (16526, 16529), True, 'import numpy as np\n'), ((16719, 16728), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (16725, 16728), True, 'import numpy as np\n'), ((16945, 16954), 'numpy.eye', 'np.eye', (['(4)'], {}), '(4)\n', (16951, 16954), True, 'import numpy as np\n'), ((17496, 17517), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (17503, 17517), True, 'import numpy as np\n'), ((17593, 17614), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (17600, 17614), True, 'import numpy as np\n'), ((17776, 17797), 'numpy.kron', 'np.kron', (['mat_b', 'mat_c'], {}), '(mat_b, mat_c)\n', (17783, 17797), True, 'import numpy as np\n'), ((17950, 17959), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (17956, 17959), True, 'import numpy as np\n'), ((17961, 17982), 'numpy.kron', 'np.kron', (['mat_b', 'mat_a'], {}), '(mat_b, mat_a)\n', (17968, 17982), True, 'import numpy as np\n'), ((18310, 18319), 'numpy.eye', 'np.eye', (['(4)'], {}), '(4)\n', (18316, 18319), True, 'import numpy as np\n'), ((18470, 18479), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (18476, 18479), True, 'import numpy as np\n'), ((18657, 18666), 'numpy.eye', 'np.eye', (['(4)'], {}), '(4)\n', (18663, 18666), True, 'import numpy as np\n'), ((19092, 19101), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (19098, 19101), True, 'import numpy as np\n'), ((19281, 19295), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat1'], {}), '(mat1)\n', (19289, 19295), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19397, 19412), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat21'], {}), '(mat21)\n', (19405, 19412), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19471, 19485), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat2'], {}), '(mat2)\n', (19479, 19485), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19587, 19602), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat12'], {}), '(mat12)\n', (19595, 19602), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19786, 19800), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat2'], {}), '(mat2)\n', (19794, 19800), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19902, 19917), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat21'], {}), '(mat21)\n', (19910, 19917), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((19976, 19990), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat1'], {}), '(mat1)\n', (19984, 19990), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((20092, 20107), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['mat12'], {}), '(mat12)\n', (20100, 20107), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((21842, 21866), 'numpy.exp', 'np.exp', (['(1.0j * np.pi / 2)'], {}), '(1.0j * np.pi / 2)\n', (21848, 21866), True, 'import numpy as np\n'), ((22014, 22035), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['(phase * mat)'], {}), '(phase * mat)\n', (22022, 22035), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((10282, 10308), 'numpy.array', 'np.array', (['[[0, 1], [1, 0]]'], {}), '([[0, 1], [1, 0]])\n', (10290, 10308), True, 'import numpy as np\n'), ((10338, 10351), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['X90'], {}), '(X90)\n', (10346, 10351), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((10433, 10459), 'qiskit.quantum_info.operators.operator.Operator', 'Operator', (['[[1, 0], [0, 0]]'], {}), '([[1, 0], [0, 0]])\n', (10441, 10459), False, 'from qiskit.quantum_info.operators.operator import Operator\n'), ((11730, 11739), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (11736, 11739), True, 'import numpy as np\n'), ((11845, 11854), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (11851, 11854), True, 'import numpy as np\n'), ((14344, 14353), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (14350, 14353), True, 'import numpy as np\n'), ((14784, 14793), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (14790, 14793), True, 'import numpy as np\n'), ((16313, 16322), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (16319, 16322), True, 'import numpy as np\n'), ((16745, 16754), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (16751, 16754), True, 'import numpy as np\n'), ((18146, 18155), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (18152, 18155), True, 'import numpy as np\n'), ((18496, 18505), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (18502, 18505), True, 'import numpy as np\n'), ((18852, 18878), 'numpy.array', 'np.array', (['[[0, 1], [1, 0]]'], {}), '([[0, 1], [1, 0]])\n', (18860, 18878), True, 'import numpy as np\n'), ((19033, 19042), 'numpy.eye', 'np.eye', (['(2)'], {}), '(2)\n', (19039, 19042), True, 'import numpy as np\n')]