@@ -202,18 +202,17 @@ def _less_than_equal_expected_t_complexity(gate: LessThanEqual):
202202 # When both registers are of the same size the T complexity is
203203 # 8n - 4 same as in the second reference.
204204 return TComplexity (t = 8 * n - 4 , clifford = 46 * n - 21 )
205+ # When the registers differ in size and `n` is the size of the smaller one and
206+ # `d` is the difference in size. The T complexity is the sum of the tree
207+ # decomposition as before giving 8n + O(1) and the T complexity of an `And` gate
208+ # over `d` registers giving 4d + O(1) totaling 8n + 4d + O(1).
209+ # From the decomposition we get that the constant is -4 as well as the clifford counts.
210+ elif d == 1 :
211+ return TComplexity (t = 8 * n , clifford = 46 * n - 1 + 2 * is_second_longer )
205212 else :
206- # When the registers differ in size and `n` is the size of the smaller one and
207- # `d` is the difference in size. The T complexity is the sum of the tree
208- # decomposition as before giving 8n + O(1) and the T complexity of an `And` gate
209- # over `d` registers giving 4d + O(1) totaling 8n + 4d + O(1).
210- # From the decomposition we get that the constant is -4 as well as the clifford counts.
211- if d == 1 :
212- return TComplexity (t = 8 * n , clifford = 46 * n - 1 + 2 * is_second_longer )
213- else :
214- return TComplexity (
215- t = 8 * n + 4 * d - 4 , clifford = 46 * n + 17 * d - 18 + 2 * is_second_longer
216- )
213+ return TComplexity (
214+ t = 8 * n + 4 * d - 4 , clifford = 46 * n + 17 * d - 18 + 2 * is_second_longer
215+ )
217216
218217
219218@pytest .mark .parametrize ("x_bitsize" , [* range (1 , 5 )])
@@ -302,7 +301,7 @@ def test_greater_than_constant():
302301 q0 = bb .add_register ('x' , bitsize )
303302 anc = bb .add_register ('result' , 1 )
304303 q0 , anc = bb .add (GreaterThanConstant (bitsize , 17 ), x = q0 , target = anc )
305- cbloq = bb .finalize (x = q0 , result = anc )
304+ bb .finalize (x = q0 , result = anc )
306305 qlt_testing .assert_wire_symbols_match_expected (
307306 GreaterThanConstant (bitsize , 17 ), ['In(x)' , '⨁(x > 17)' ]
308307 )
0 commit comments