def test_get_merged_bad_gate(): hamiltonian = QubitOperator("Z2", 2) gate = te.TimeEvolution(2, hamiltonian) other = BasicGate() with pytest.raises(NotMergeable): gate.get_merged(other)
def __init__(self): r""" Abstract XmonGate class to distinguish mon from regular proejctq gates. """ BasicGate.__init__(self)
def __init__(self): BasicGate.__init__(self) self.cnt = 0
LocalOptimizer(cache_depth), AutoReplacer(rule_set), TagRemover(), LocalOptimizer(cache_depth), #,CommandPrinter(), GreedyScheduler() ] eng = HiQMainEngine(backend, engines) m = 2 epsilon = 0.1 # the estimation algorithm successs with probability 1 - epsilon n_accuracy = 3 # the estimation algorithm estimates with 3 bits accuracy n = _bits_required_to_achieve_accuracy(n_accuracy, epsilon) ## we create a unitary U = R(cmath.pi*3/4) \ox R(cmath.pi*3/4) U = BasicGate() theta = math.pi * 3 / 4 U.matrix = np.matrix([[1, 0, 0, 0], [0, cmath.exp(1j * theta), 0, 0], [0, 0, cmath.exp(1j * theta), 0], [0, 0, 0, cmath.exp(1j * 2 * theta)]]) state = eng.allocate_qureg(m + n) # prepare the input state to be |psi>=|01> X | state[1] run_phase_estimation(eng, U, state, m, n) # we have to post-process the state that stores the estimated phase OFFSET = m Tensor(Measure) | state[OFFSET:]