Пример #1
0
def get_simon(bitmap=None):
    """ Instanciates and returns the circuit for Simon's algorithm """
    if bitmap is None:
        bitmap = create_1to1_bitmap("101")
    sm = Simon()
    sm._init_attr(bitmap)
    return sm.simon_circuit
Пример #2
0
def test_bit_map_generation():
    mask = '101'
    expected_map = {
        '000': '101',
        '001': '100',
        '010': '111',
        '011': '110',
        '100': '001',
        '101': '000',
        '110': '011',
        '111': '010'
    }
    actual_map = create_1to1_bitmap(mask)
    assert actual_map == expected_map
Пример #3
0
def run_simon(qc, bitmap=create_1to1_bitmap("101"), trials=30):
    """ 
    Runs simon's algorithm with preset parameters, mostly for testing
    the execution process's stability.

    Args:
        qc: The instance of rigetti's simulator/connection to use
        bitmap: The bitmap to use for this algorithm
        trials: number of samples
    Returns:
        pyquil result object with measures.
"""
    circ = get_simon(bitmap)
    return qc.run_and_measure(circ, qubits=list(circ.get_qubits()), trials=trials)
Пример #4
0
def get_simon(bitmap=create_1to1_bitmap("101")):
    sm = Simon()
    sm._init_attr(bitmap)
    return sm.simon_circuit