p-gate-cudaq
Table of Contents
Phase gate (CUDA-Q)
Phase gate implementation using CUDA-Q. The example applies $P(\pi/2) = S$ to $\lvert +\rangle$, rotating it to $\lvert i\rangle = \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; h(q); // |0> -> |+> r1(M_PI / 2.0, q); // P(pi/2) = S gate mz(q); } }; int main() { auto counts = cudaq::sample(kernel{}); counts.dump(); // ~50% |0>, ~50% |1> (phase not observable in Z basis) }
p-gate-cudaq.txt ยท Last modified: by 127.0.0.1
