Skip to content

Commit

Permalink
syncing qiskit/qasm/libs/qelib1.inc and qiskit/extensions/standard/cu…
Browse files Browse the repository at this point in the history
…3.py (Qiskit#3479)

* update qiskit/qasm/libs/qelib1.inc according to Qiskit#2755

* re adjust the length

* test
  • Loading branch information
Luciano authored and mergify[bot] committed Nov 20, 2019
1 parent 074473d commit 9d7623c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions qiskit/extensions/standard/cu3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
"""
Expand Down
1 change: 1 addition & 0 deletions qiskit/qasm/libs/qelib1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/python/test_qasm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 9d7623c

Please sign in to comment.