NVIDIA / cuda-quantum

C++ and Python support for the CUDA Quantum programming model for heterogeneous quantum-classical workflows
https://nvidia.github.io/cuda-quantum/
Other
561 stars 191 forks source link

Classical bit operations like bit shift and bitand #2331

Open ikkoham opened 1 month ago

ikkoham commented 1 month ago

Required prerequisites

Describe the feature

It would be useful to write code like this.

import cudaq

@cudaq.kernel
def test(num_qubits: int, mask: int):
    q = cudaq.qvector(num_qubits)
    for i in range(num_qubits):
        if mask >> i & 1:
            x(q[i])
    mz(q)

Now I got errors unhandled binary operator - <ast.BitAnd object at 0x7fe9703569b0>.

ikkoham commented 1 month ago

Probably more useful for MCM.