Skip to content

Commit e6d2bb1

Browse files
authored
Add tket_squash_phasedx_rz() to C API (#2058)
1 parent cbe7acc commit e6d2bb1

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

TKET_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.57
1+
2.1.58

tket-c-api/include/tket-c-api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ TketError tket_two_qubit_squash(
6161
TketError tket_clifford_simp(
6262
TketCircuit *circuit, TketTargetGate target_gate, bool allow_swaps);
6363

64+
/**
65+
* Squash sequences of single-qubit gates into PhasedX and Rz gates.
66+
*
67+
* Also remove identity gates. Commute Rz gates to the back if possible.
68+
*
69+
* @param circuit Circuit to transform (modified in-place)
70+
* @return TKET_SUCCESS if successful, error code otherwise
71+
*/
72+
TketError tket_squash_phasedx_rz(TketCircuit *circuit);
73+
6474
// Utility functions
6575
const char *tket_error_string(TketError error);
6676

tket-c-api/src/tket-c-api.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ TketError tket_clifford_simp(
106106
return TKET_SUCCESS;
107107
}
108108

109+
TketError tket_squash_phasedx_rz(TketCircuit *tc) {
110+
if (!tc) return TKET_ERROR_NULL_POINTER;
111+
112+
Transforms::squash_1qb_to_Rz_PhasedX(true).apply(tc->circuit);
113+
114+
return TKET_SUCCESS;
115+
}
116+
109117
const char *tket_error_string(TketError error) {
110118
switch (error) {
111119
case TKET_SUCCESS:

0 commit comments

Comments
 (0)