r-gate-cudaq
Table of Contents
Rotation gates (CUDA-Q)
Rotation gates implementation using CUDA-Q. The example applies $R_x(\pi/2)$ to $\lvert 0\rangle$, producing $\frac{1}{\sqrt{2}}(\lvert 0\rangle - i\lvert 1\rangle)$.
// Compile: nvq++ main.cpp -o main // Run: ./main #include <cudaq.h> #include <cmath> struct kernel { __qpu__ void operator()() { cudaq::qubit q; rx(M_PI / 2.0, q); // R_x(pi/2) on |0> mz(q); } }; int main() { auto counts = cudaq::sample(kernel{}); counts.dump(); // ~50% |0>, ~50% |1> }
r-gate-cudaq.txt ยท Last modified: by 127.0.0.1
