diff --git a/qiskit/extensions/standard/cu3.py b/qiskit/extensions/standard/cu3.py index 4b4769bba24a..95ce2fb6fd73 100644 --- a/qiskit/extensions/standard/cu3.py +++ b/qiskit/extensions/standard/cu3.py @@ -35,8 +35,11 @@ def __init__(self, theta, phi, lam): def _define(self): """ gate cu3(theta,phi,lambda) c, t - { u1((lambda+phi)/2) c; u1((lambda-phi)/2) t; cx c,t; - u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t; + { u1((lambda+phi)/2) c; + u1((lambda-phi)/2) t; + cx c,t; + u3(-theta/2,0,-(phi+lambda)/2) t; + cx c,t; u3(theta/2,phi,0) t; } """ diff --git a/qiskit/qasm/libs/qelib1.inc b/qiskit/qasm/libs/qelib1.inc index cac5075484d2..756aecce1af3 100644 --- a/qiskit/qasm/libs/qelib1.inc +++ b/qiskit/qasm/libs/qelib1.inc @@ -98,6 +98,7 @@ gate cu1(lambda) a,b gate cu3(theta,phi,lambda) c, t { // implements controlled-U(theta,phi,lambda) with target t and control c + u1((lambda+phi)/2) c; u1((lambda-phi)/2) t; cx c,t; u3(-theta/2,0,-(phi+lambda)/2) t; diff --git a/test/python/test_qasm_parser.py b/test/python/test_qasm_parser.py index a1703c2851ef..2247afa8f4d1 100644 --- a/test/python/test_qasm_parser.py +++ b/test/python/test_qasm_parser.py @@ -47,10 +47,10 @@ def test_parser(self): res = parse(self.qasm_file_path) self.log.info(res) # TODO: For now only some basic checks. - self.assertEqual(len(res), 1563) + self.assertEqual(len(res), 1589) self.assertEqual(res[:12], "OPENQASM 2.0") self.assertEqual(res[14:41], "gate u3(theta,phi,lambda) q") - self.assertEqual(res[1547:1562], "measure r -> d;") + self.assertEqual(res[1573:1588], "measure r -> d;") def test_parser_fail(self): """should fail a for a not valid circuit."""