Пример #1
0
def test_commuting_sets_2():
    ham1 = PauliSum([PauliTerm('X', i) for i in [0, 1]])
    ham2 = PauliSum([PauliTerm('X', i) for i in [2, 3, 4]])
    actual = commuting_sets_by_indices([ham1, ham2], check_trivial_commutation)

    desired = [[(0, 0), (0, 1), (1, 0), (1, 1), (1, 2)]]
    assert actual == desired
Пример #2
0
def test_commuting_sets_4():
    ham1 = PauliSum([PauliTerm('Z', 0), PauliTerm('X', 0)])
    ham2 = PauliSum([PauliTerm('X', 1), PauliTerm('Z', 1)])
    actual = commuting_sets_by_indices([ham1, ham2], check_trivial_commutation)

    desired = [
        [(0, 0), (1, 0)],
        [(0, 1), (1, 1)],
    ]
    assert actual == desired
Пример #3
0
def test_commuting_terms_indexed():
    """
    Test performance of commuting_sets_by_index
    """
    pauli_term_1 = PauliSum([sX(0) * sZ(1)])
    pauli_term_2 = PauliSum([sX(1) * sZ(2)])
    pauli_term_3 = PauliSum([sX(0) * sY(3)])
    commuting_set_tuples = commuting_sets_by_indices(
        [pauli_term_1, pauli_term_2, pauli_term_3], check_trivial_commutation)
    correct_tuples = [[(0, 0)], [(1, 0), (2, 0)]]

    assert commuting_set_tuples == correct_tuples