Skip to content

Commit

Permalink
Revert "Reverse QPager::Compose() (debugged)"
Browse files Browse the repository at this point in the history
This reverts commit 3e033bd.
  • Loading branch information
WrathfulSpatula committed Jul 10, 2021
1 parent 3e033bd commit 3eb872f
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions src/qpager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,46 +438,7 @@ void QPager::CombineAndOpControlled(
CombineAndOp(fn, bits);
}

bitLenInt QPager::Compose(QPagerPtr toCopy)
{
if (qubitCount >= toCopy->qubitCount) {
return Compose(toCopy, qubitCount);
}

if ((qubitCount + toCopy->qubitCount) > maxQubits) {
throw std::invalid_argument(
"Cannot instantiate a QPager with greater capacity than environment variable QRACK_MAX_PAGING_QB.");
}

// TODO: Avoid CombineEngines();
toCopy->CombineEngines();

bitLenInt qpp = qubitsPerPage();
bitLenInt tcqpp = toCopy->qubitCount;

if ((qpp + tcqpp) > maxPageQubits) {
qpp = (maxPageQubits <= tcqpp) ? 1U : (maxPageQubits - tcqpp);
SeparateEngines(qpp, true);
}

bitCapIntOcl i;
bitCapIntOcl maxI = (bitCapIntOcl)qPages.size();
std::vector<QEnginePtr> nQPages;

QEnginePtr engine = toCopy->qPages[0];
for (i = 0; i < maxI; i++) {
nQPages.push_back(std::dynamic_pointer_cast<QEngine>(engine->Clone()));
nQPages.back()->Compose(qPages[i], 0);
}

qPages = nQPages;

bitLenInt toRet = qubitCount;

SetQubitCount(qubitCount + toCopy->qubitCount);

return toRet;
}
bitLenInt QPager::Compose(QPagerPtr toCopy) { return Compose(toCopy, qubitCount); }

bitLenInt QPager::Compose(QPagerPtr toCopy, bitLenInt start)
{
Expand Down

0 comments on commit 3eb872f

Please sign in to comment.