コード例 #1
0
def demo_adonis(do_measure=False, use_qsim=False):
    """Run the demo using the Adonis architecture."""

    print('\nAdonis demo\n===========\n')
    device = Adonis()
    qasm_program = """
        OPENQASM 2.0;
        include "qelib1.inc";
        qreg q[3];
        creg meas[3];
        U(0.2, 0.5, 1.7) q[1];
        h q[0];
        cx q[2], q[1];
        ising(-0.6) q[0], q[2];  // QASM extension
    """
    if do_measure:
        qasm_program += '\nmeasure q -> meas;'

    circuit = circuit_from_qasm(qasm_program)

    # add some more gates
    q0 = cirq.NamedQubit('q_0')
    q2 = cirq.NamedQubit('q_2')
    circuit.insert(len(circuit) - 1, cirq.CXPowGate(exponent=0.723)(q2, q0))

    demo(device, circuit, do_measure, use_qsim=use_qsim)
コード例 #2
0
def demo_valkmusa(do_measure=False, use_qsim=False):
    """Run the demo using the Valkmusa architecture."""

    print('\nValkmusa demo\n=============\n')
    device = Valkmusa()
    qasm_program = """
        OPENQASM 2.0;
        include "qelib1.inc";
        qreg q[2];
        creg meas[2];
        U(1.3, 0.4, -0.3) q[1];
        h q[0];
        rx(1.1) q[0];
        cx q[0], q[1];
    """
    if do_measure:
        qasm_program += '\nmeasure q -> meas;'

    circuit = circuit_from_qasm(qasm_program)

    # add some more gates
    q0 = cirq.NamedQubit('q_0')
    q1 = cirq.NamedQubit('q_1')
    circuit.insert(len(circuit) - 1, cirq.ISwapPowGate(exponent=0.4)(q0, q1))

    qubit_mapping = {'q_0': 'QB1', 'q_1': 'QB2'}
    demo(device, circuit, do_measure, use_qsim=use_qsim, qubit_mapping=qubit_mapping)
コード例 #3
0
def demo_apollo(do_measure=False, use_qsim=False):
    """Run the demo using the Apollo architecture."""

    print('\nApollo demo\n===========\n')
    device = Apollo()
    qasm_program = """
        OPENQASM 2.0;
        include "qelib1.inc";
        qreg q[6];
        creg meas[3];
        U(0.2, 0.5, 1.7) q[1];
        h q[0];
        h q[2];
        h q[4];
        h q[5];
        cx q[0], q[1];
        cx q[3], q[4];
    """
    if do_measure:
        qasm_program += '\nmeasure q -> meas;'

    circuit = circuit_from_qasm(qasm_program)

    # add some more gates
    q2 = cirq.NamedQubit('q_2')
    q3 = cirq.NamedQubit('q_3')
    circuit.insert(len(circuit) - 1, cirq.CXPowGate(exponent=0.723)(q2, q3))

    qubit_mapping = {
        'q_0': 'QB1',
        'q_1': 'QB2',
        'q_2': 'QB3',
        'q_3': 'QB4',
        'q_4': 'QB5',
        'q_5': 'QB6'
    }
    demo(device,
         circuit,
         do_measure,
         use_qsim=use_qsim,
         qubit_mapping=qubit_mapping)
コード例 #4
0
# Demo for CG.
# Requires Pysparse (http://pysparse.sf.net)
# The test matrix may be obtained from http://math.nist.gov/MatrixMarket

from pykrylov.cg import CG
from demo_common import demo
import logging
import sys

if __name__ == '__main__':

    # Create logger for CG.
    cglog = logging.getLogger('CG')
    cglog.setLevel(logging.INFO)
    fmt = logging.Formatter('%(name)-2s %(levelname)-8s %(message)s')
    hndlr = logging.StreamHandler(sys.stdout)
    hndlr.setFormatter(fmt)
    cglog.addHandler(hndlr)

    demo(CG, sys.argv[1], check_symmetric=True, logger=cglog)
コード例 #5
0
ファイル: demo_minres.py プロジェクト: wyllmein2000/pykrylov
# Demo for MINRES.
# Requires Pysparse (http://pysparse.sf.net)
# The test matrix may be obtained from http://math.nist.gov/MatrixMarket

from pykrylov.minres import Minres
from demo_common import demo
import logging
import sys

if __name__ == '__main__':

    # Create logger for MINRES.
    mrlog = logging.getLogger('MINRES')
    mrlog.setLevel(logging.INFO)
    fmt = logging.Formatter('%(name)-2s %(levelname)-8s %(message)s')
    hndlr = logging.StreamHandler(sys.stdout)
    hndlr.setFormatter(fmt)
    mrlog.addHandler(hndlr)

    demo(Minres, sys.argv[1], check_symmetric=True, logger=mrlog)
コード例 #6
0
ファイル: demo_minres.py プロジェクト: dromanov/pykrylov
# Demo for MINRES.
# Requires Pysparse (http://pysparse.sf.net)
# The test matrix may be obtained from http://math.nist.gov/MatrixMarket

from pykrylov.minres import Minres
from demo_common import demo
import sys

if __name__ == '__main__':

    demo(Minres, sys.argv[1])