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

Method append

runtime/common/SampleResult.cpp:192–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void sample_result::append(const ExecutionResult &result, bool concatenate) {
193 // If given a result corresponding to the same register name, either a)
194 // replace the existing one if concatenate is false, or b) if concatenate is
195 // true, stitch the bitstrings from "result" into the existing one.
196 auto iter = sampleResults.find(result.registerName);
197 if (iter != sampleResults.end()) {
198 auto &existingExecResult = iter->second;
199 if (concatenate) {
200 // Stitch the bitstrings together
201 if (this->totalShots == result.sequentialData.size()) {
202 existingExecResult.counts.clear();
203 for (std::size_t i = 0; i < this->totalShots; i++) {
204 std::string newStr =
205 existingExecResult.sequentialData[i] + result.sequentialData[i];
206 existingExecResult.counts[newStr]++;
207 existingExecResult.sequentialData[i] = std::move(newStr);
208 }
209 }
210 } else {
211 // Replace the existing one
212 existingExecResult = result;
213 }
214 } else {
215 sampleResults.insert({result.registerName, result});
216 }
217 if (!totalShots)
218 for (auto &[bits, count] : result.counts)
219 totalShots += count;
220}
221
222bool sample_result::operator==(const sample_result &counts) const {
223 return sampleResults == counts.sampleResults;

Callers 8

push_backMethod · 0.45
gzipCompressMethod · 0.45
gzipDecompressMethod · 0.45
updatePassPipelineMethod · 0.45
processResultsMethod · 0.45
latex_diagram_from_traceFunction · 0.45

Calls 4

endMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected