MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / reorderReducedQureg

Function reorderReducedQureg

quest/src/core/localiser.cpp:1761–1788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1759
1760
1761void reorderReducedQureg(Qureg inQureg, Qureg outQureg, vector<int> allTargs, vector<int> suffixTargs) {
1762
1763 /// @todo
1764 /// this function performs a sequence of SWAPs which are NOT necessarily upon disjoint qubits,
1765 /// and ergo do not commute. We still however may be able to effect this more efficiently in
1766 /// a single communicating operation rather than this sequence of SWAP gates, and might still
1767 /// even be able to use cuQuantum's distributed bit index swaps API. Check this!
1768
1769 // determine the relative ordering of outQureg's remaining qubits
1770 auto remainingQubits = getNonTracedQubitOrder(inQureg, allTargs, suffixTargs);
1771
1772 // perform additional swaps to re-order the remaining qubits (heuristically starting from back)
1773 for (int qubit=(int)remainingQubits.size(); qubit-- != 0; ) {
1774
1775 // locate the next qubit which is out of its sorted position
1776 if (remainingQubits[qubit] == qubit)
1777 continue;
1778
1779 // qubit is misplaced; locate its position among the remaining qubits
1780 int pair = 0;
1781 while (remainingQubits[pair] != qubit)
1782 pair++;
1783
1784 // and swap it directly to its required position, triggering any communication scenario (I think)
1785 localiser_statevec_anyCtrlSwap(outQureg, {}, {}, qubit, pair);
1786 std::swap(remainingQubits[qubit], remainingQubits[pair]);
1787 }
1788}
1789
1790
1791void partialTraceOnSuffix(Qureg inQureg, Qureg outQureg, vector<int> ketTargs) {

Callers 1

partialTraceOnPrefixFunction · 0.85

Calls 2

getNonTracedQubitOrderFunction · 0.85

Tested by

no test coverage detected