From 0d0fda8f0ee36c1356adce728d6dc5053ee866e2 Mon Sep 17 00:00:00 2001 From: Anthony Cabrera Date: Thu, 26 Sep 2024 14:52:27 -0500 Subject: [PATCH] [WIP] [runtime] adding mx and my support for qarrays --- runtime/cudaq/qis/qubit_qis.h | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/runtime/cudaq/qis/qubit_qis.h b/runtime/cudaq/qis/qubit_qis.h index 3d5b0b99603..3bc3205e663 100644 --- a/runtime/cudaq/qis/qubit_qis.h +++ b/runtime/cudaq/qis/qubit_qis.h @@ -791,6 +791,42 @@ std::vector mz(QubitRange &q) { return b; } +// Measure all qubits in the range, return vector of 0,1 +#if CUDAQ_USE_STD20 +template + requires std::ranges::range +#else +template < + typename QubitRange, + typename = std::enable_if_t>, cudaq::qubit>>> +#endif +std::vector my(QubitRange &q) { + std::vector b; + for (auto &qq : q) { + b.push_back(my(qq)); + } + return b; +} + +// Measure all qubits in the range, return vector of 0,1 +#if CUDAQ_USE_STD20 +template + requires std::ranges::range +#else +template < + typename QubitRange, + typename = std::enable_if_t>, cudaq::qubit>>> +#endif +std::vector mx(QubitRange &q) { + std::vector b; + for (auto &qq : q) { + b.push_back(mx(qq)); + } + return b; +} + template std::vector mz(qubit &q, Qs &&...qs);