diff --git a/src/qrisp/alg_primitives/mcx_algs/balauca.py b/src/qrisp/alg_primitives/mcx_algs/balauca.py index 06093400..de85714e 100644 --- a/src/qrisp/alg_primitives/mcx_algs/balauca.py +++ b/src/qrisp/alg_primitives/mcx_algs/balauca.py @@ -465,8 +465,10 @@ def jasp_balauca_mcx(ctrls, target, ctrl_state): with control(N == 1): cx(ctrls[0], target[0]) + with control(N == 2): mcx([ctrls[0], ctrls[1]], target[0]) + with control(N > 2): balauca_anc = QuantumVariable(N-2+N%2) with conjugate(jasp_balauca_helper)(ctrls, balauca_anc): @@ -497,5 +499,4 @@ def jasp_balauca_helper(ctrls, balauca_anc): balauca_anc[l+k+j], method = "gidney") - l = cond(jnp.bool(k%2), lambda x : x-1, lambda x : x, l) - l += k \ No newline at end of file + l += k - k%2 \ No newline at end of file diff --git a/src/qrisp/core/gate_application_functions.py b/src/qrisp/core/gate_application_functions.py index fe509223..37bc1a5b 100644 --- a/src/qrisp/core/gate_application_functions.py +++ b/src/qrisp/core/gate_application_functions.py @@ -19,7 +19,7 @@ import sympy import qrisp.circuit.standard_operations as std_ops -from qrisp.jasp import check_for_tracing_mode +from qrisp.jasp import check_for_tracing_mode, DynamicQubitArray def append_operation(operation, qubits=[], clbits=[], param_tracers = []): from qrisp import find_qs @@ -510,6 +510,8 @@ def benchmark_mcx(n, methods): ) else: qubits_0 = controls + if isinstance(qubits_0, (QuantumVariable, DynamicQubitArray)): + method = "balauca" qubits_1 = [target] from qrisp.alg_primitives.mcx_algs import ( balauca_dirty,