Skip to content

Commit

Permalink
[WIP] [runtime] adding mx and my support for qarrays
Browse files Browse the repository at this point in the history
  • Loading branch information
cabreraam committed Sep 30, 2024
1 parent f5ab479 commit 0d0fda8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions runtime/cudaq/qis/qubit_qis.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,42 @@ std::vector<measure_result> mz(QubitRange &q) {
return b;
}

// Measure all qubits in the range, return vector of 0,1
#if CUDAQ_USE_STD20
template <typename QubitRange>
requires std::ranges::range<QubitRange>
#else
template <
typename QubitRange,
typename = std::enable_if_t<!std::is_same_v<
std::remove_reference_t<std::remove_cv_t<QubitRange>>, cudaq::qubit>>>
#endif
std::vector<measure_result> my(QubitRange &q) {
std::vector<measure_result> 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 <typename QubitRange>
requires std::ranges::range<QubitRange>
#else
template <
typename QubitRange,
typename = std::enable_if_t<!std::is_same_v<
std::remove_reference_t<std::remove_cv_t<QubitRange>>, cudaq::qubit>>>
#endif
std::vector<measure_result> mx(QubitRange &q) {
std::vector<measure_result> b;
for (auto &qq : q) {
b.push_back(mx(qq));
}
return b;
}

template <typename... Qs>
std::vector<measure_result> mz(qubit &q, Qs &&...qs);

Expand Down

0 comments on commit 0d0fda8

Please sign in to comment.