Add support for multi-indexed data loading for both QROM and SelectSwapQROM
Unary iteration now supports writing nested for-loops by iterating over multiple qubit registers, each of different lengths. This support should be extended to QROM so that we can load, for example, data[i][j] in the target register when selection registers store i and j.
- For QROM, this should be trivial to extend.
- For SelectSwapQROM, we need to choose a parameter $k_{i}$ for each nested for-loop and then load $N_{i} / k_{i}$ elements using QROM and do swaps correctly for each loaded batch. See Appendix G of https://arxiv.org/pdf/2011.03494.pdf for more details.
We also need multi-indexed selectedmajoranafermion and applygatetolthqubit for #107
Is this done?
QROM yes (I think). For SelectSwapQROM where I've seen this in the literature they typically form a contiguous index from the multi index and do 1D array access if I'm reading this correctly. Although now that I write this I would assume QROM would also incur a contiguous index formation cost...
For SelectSwapQROM where I've seen this in the literature they typically form a contiguous index from the multi index and do 1D array access if I'm reading this correctly
@fdmalone The additional cost for computing a contiguous register is required only for the cases where one of the selection indices depends upon the other. For example
for i in range(N):
for j in range(i):
# Load data[i][j] ==> This requires computing a contiguous register
for i in range(N):
for j in range(M):
# Load data[i][j] ==> This DOES NOT require computing a contiguous register
QROM supports the second case, SelectSwapQROM does not. Appendix G of the linked THC paper explains how to do this for SelectSwapQROM
thanks, I always found that appendix confusing.