| 858 | |
| 859 | |
| 860 | void anyCtrlSwapBetweenPrefixAndSuffix(Qureg qureg, vector<int> ctrls, vector<int> ctrlStates, int suffixTarg, int prefixTarg) { |
| 861 | |
| 862 | // every node exchanges at most half its amps; those where suffixTarg bit differs from rank's fixed prefixTarg bit |
| 863 | int pairRank = util_getRankWithQubitFlipped(prefixTarg, qureg); |
| 864 | int suffixState = ! util_getRankBitOfQubit(prefixTarg, qureg); |
| 865 | |
| 866 | // pack and exchange only to-be-communicated amps between sub-buffers |
| 867 | vector<int> qubits = ctrls; |
| 868 | vector<int> states = ctrlStates; |
| 869 | qubits.push_back(suffixTarg); |
| 870 | states.push_back(suffixState); |
| 871 | exchangeAmpsToBuffersWhereQubitsAreInStates(qureg, pairRank, qubits, states); |
| 872 | |
| 873 | // we use the recevied buffer amplitudes to modify half of the local bits which satisfy ctrls |
| 874 | accel_statevec_anyCtrlSwap_subC(qureg, ctrls, ctrlStates, suffixTarg, suffixState); |
| 875 | } |
| 876 | |
| 877 | |
| 878 | void localiser_statevec_anyCtrlSwap(Qureg qureg, vector<int> ctrls, vector<int> ctrlStates, int targ1, int targ2) { |
no test coverage detected