| 156 | } |
| 157 | |
| 158 | static std::vector<int> bitStringToIntVec(const std::string &bitString) { |
| 159 | // Check that this is a valid bit string. |
| 160 | const bool isValidBitString = |
| 161 | std::all_of(bitString.begin(), bitString.end(), |
| 162 | [](char c) { return c == '0' || c == '1'; }); |
| 163 | if (!isValidBitString) |
| 164 | throw std::invalid_argument("Invalid bitstring: " + bitString); |
| 165 | std::vector<int> result; |
| 166 | result.reserve(bitString.size()); |
| 167 | for (const auto c : bitString) |
| 168 | result.emplace_back(c == '0' ? 0 : 1); |
| 169 | return result; |
| 170 | } |
| 171 | |
| 172 | /// @brief Run `cudaq::get_state` on the provided kernel and spin operator. |
| 173 | static state get_state_impl(const std::string &shortName, MlirModule mod, |
no test coverage detected