MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / bitStringToIntVec

Function bitStringToIntVec

python/runtime/cudaq/algorithms/py_state.cpp:158–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static 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.
173static state get_state_impl(const std::string &shortName, MlirModule mod,

Callers 1

bindPyStateMethod · 0.85

Calls 4

emplace_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected