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

Method dump

runtime/common/SampleResult.cpp:444–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444void sample_result::dump(std::ostream &os) const {
445 os << "{ ";
446 if (sampleResults.size() > 1) {
447 os << "\n ";
448 std::size_t counter = 0;
449 for (auto &result : sortByKeys(sampleResults)) {
450 os << result->first << " : { ";
451 for (auto &kv : sortByKeys(result->second.counts)) {
452 os << kv->first << ":" << kv->second << " ";
453 }
454 bool isLast = counter == sampleResults.size() - 1;
455 counter++;
456 os << "}\n" << (!isLast ? " " : "");
457 }
458
459 } else if (sampleResults.size() == 1) {
460
461 CountsDictionary counts;
462 auto [found, result] = try_retrieve_result(GlobalRegisterName);
463 if (found)
464 counts = result.counts;
465 else {
466 auto first = sampleResults.begin();
467 os << "\n " << first->first << " : { ";
468 counts = sampleResults.begin()->second.counts;
469 }
470
471 for (auto &kv : sortByKeys(counts)) {
472 os << kv->first << ":" << kv->second << " ";
473 }
474
475 if (!found)
476 os << "}\n";
477 }
478 os << "}\n";
479}
480
481void sample_result::dump() const { dump(std::cout); }
482

Callers

nothing calls this directly

Calls 3

sortByKeysFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected