Пример #1
0
 def test_apply_phase_1qubit(self):
     eng = MainEngine()
     reg = eng.allocate_qubit()
     H | reg
     apply_phase(reg, 0, 0.03)
     eng.flush()
     self.assertAlmostEqual(numpy.angle(ordered_wavefunction(eng)[1]) -
                            numpy.angle(ordered_wavefunction(eng)[0]),
                            0.06)
     Measure | reg
Пример #2
0
 def test_apply_phase_multiple_qubits(self):
     All(H) | self.reg
     apply_phase(self.reg, 1, 0.07)
     self.eng.flush()
     wavefunction = ordered_wavefunction(self.eng)
     self.assertAlmostEqual(numpy.angle(wavefunction[1]),
                            numpy.angle(wavefunction[0]))
     self.assertAlmostEqual(numpy.angle(wavefunction[6]),
                            numpy.angle(wavefunction[2]))
     self.assertAlmostEqual(
         numpy.angle(wavefunction[2]) - numpy.angle(wavefunction[0]), 0.14)