def test_valid_2(self) -> None: u1 = UnitaryMatrix.random(3) u2 = UnitaryMatrix.random(2) ub = UnitaryBuilder(3) ub.apply_right(u1, [0, 1, 2]) assert ub.get_unitary() == u1 ub.apply_right(u2, [0, 1]) prod = np.kron(u2.get_numpy(), np.identity(2)) @ u1.get_numpy() assert ub.get_unitary() == prod
def test_valid_3(self) -> None: u1 = UnitaryMatrix.random(3) u2 = UnitaryMatrix.random(2) ub = UnitaryBuilder(3) ub.apply_left(u1, [0, 1, 2]) assert ub.get_unitary() == u1 ub.apply_left(u2, [1, 2]) prod = u1 @ np.kron(np.identity(2), u2.get_numpy()) assert ub.get_unitary() == prod
def test_valid(self, size: int, radixes: Sequence[int]) -> None: ub = UnitaryBuilder(size, radixes) assert ub.get_size() == size assert isinstance(ub.get_radixes(), tuple) assert len(ub.get_radixes()) == size if len(radixes) > 0: for radix1, radix2 in zip(radixes, ub.get_radixes()): assert radix1 == radix2 assert ub.get_dim() == int(np.prod(ub.get_radixes())) assert np.allclose( ub.get_unitary().get_numpy(), np.identity(ub.get_dim()), )
def test_valid_1(self) -> None: u1 = UnitaryMatrix.random(3) ub = UnitaryBuilder(3) ub.apply_right(u1, [0, 1, 2]) assert ub.get_unitary() == u1