@@ -285,7 +285,7 @@ def nonft_t_tel(self, aux: Steane):
285
285
aux .cx (self ),
286
286
self .mz (self .t_meas ),
287
287
If (self .t_meas == 1 ).Then (aux .x (), aux .sz ()),
288
- Permute ( self .d , aux . d ),
288
+ self .permute ( aux ),
289
289
)
290
290
291
291
def t_tel (
@@ -308,7 +308,7 @@ def t_tel(
308
308
aux .cx (self ),
309
309
self .mz (self .t_meas ),
310
310
If (self .t_meas == 1 ).Then (aux .x (), aux .sz ()), # SZ/S correction.
311
- Permute ( self .d , aux . d ),
311
+ self .permute ( aux ),
312
312
)
313
313
314
314
def nonft_tdg_tel (self , aux : Steane ):
@@ -326,7 +326,7 @@ def nonft_tdg_tel(self, aux: Steane):
326
326
aux .cx (self ),
327
327
self .mz (self .tdg_meas ),
328
328
If (self .tdg_meas == 1 ).Then (aux .x (), aux .szdg ()),
329
- Permute ( self .d , aux . d ),
329
+ self .permute ( aux ),
330
330
)
331
331
332
332
def tdg_tel (
@@ -349,7 +349,7 @@ def tdg_tel(
349
349
aux .cx (self ),
350
350
self .mz (self .tdg_meas ),
351
351
If (self .t_meas == 1 ).Then (aux .x (), aux .szdg ()), # SZdg/Sdg correction.
352
- Permute ( self .d , aux . d ),
352
+ self .permute ( aux ),
353
353
)
354
354
355
355
def t_cor (
@@ -495,3 +495,18 @@ def qec(self, flag: Bit | None = None):
495
495
if flag is not None :
496
496
block .extend (If (self .flags != 0 ).Then (flag .set (1 )))
497
497
return block
498
+
499
+ def permute (self , other : Steane ):
500
+ """Permute this code block (including both quantum and classical registers) with another."""
501
+ block = Block (
502
+ Permute (self .d , other .d ),
503
+ Permute (self .a , other .a ),
504
+ )
505
+ for var_a , var_b in zip (self .vars , other .vars ):
506
+ if isinstance (var_a , CReg ):
507
+ block .extend (
508
+ var_a .set (var_a ^ var_b ),
509
+ var_b .set (var_b ^ var_a ),
510
+ var_a .set (var_a ^ var_b ),
511
+ )
512
+ return block
0 commit comments