Function applyQFT

Source
pub unsafe extern "C" fn applyQFT(
    qureg: Qureg,
    qubits: *mut c_int,
    numQubits: c_int,
)
Expand description

Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register \p qureg.

The order of \p qubits affects the ultimate unitary. The canonical full-state QFT (applyFullQFT()) is achieved by targeting every qubit in increasing order.

The effected unitary circuit (shown here for \p numQubits = 4) resembles @htmlonly

@endhtmlonly though is performed more efficiently.
  • If \p qureg is a state-vector, the output amplitudes are a kronecker product of the discrete Fourier transform (DFT) acting upon the targeted amplitudes, and the remaining. \n Precisely,

    • let \f$|x,r\rangle\f$ represent a computational basis state where \f$x\f$ is the binary value of the targeted qubits, and \f$r\f$ is the binary value of the remaining qubits.
    • let \f$|x_j,r_j\rangle\f$ be the \f$j\text{th}\f$ such state.
    • §let \f$n =\f$ \p numQubits, and \f$N =\f$ qureg.numQubitsRepresented.\n Then, this function effects \f[ (\text{QFT}\otimes 1) , \left( \sum\limits_{j=0}^{2^N-1} \alpha_j , |x_j,r_j\rangle \right)

      \frac{1}{\sqrt{2^n}} \sum\limits_{j=0}^{2^N-1} \alpha_j \left( \sum\limits_{y=0}^{2^n-1} e^{2 \pi , i , x_j , y / 2^n} ; |y,r_j \rangle \right) \f]
  • If \p qureg is a density matrix \f$\rho\f$, it will be changed under the unitary action of the QFT. This can be imagined as each mixed state-vector undergoing the DFT on its amplitudes. This is true even if \p qureg is unnormalised. \f[ \rho ; \rightarrow ; \text{QFT} ; \rho ; \text{QFT}^{\dagger} \f]

This function merges contiguous controlled-phase gates into single invocations of applyNamedPhaseFunc(), and hence is significantly faster than performing the QFT circuit directly.

Furthermore, in distributed mode, this function requires only \f$\log_2(\text{#nodes})\f$ rounds of pair-wise communication, and hence is exponentially faster than directly performing the DFT on the amplitudes of \p qureg.

@see

  • applyFullQFT() to apply the QFT to the entirety of \p qureg.

@ingroup operator @param[in,out] qureg a state-vector or density matrix to modify @param[in] qubits a list of the qubits to operate the QFT upon @param[in] numQubits the length of list \p qubits @throws invalidQuESTInputError()

  • if any qubit in \p qubits is invalid, i.e. outside [0, qureg.numQubitsRepresented)
  • if \p qubits contain any repetitions
  • if \p numQubits < 1
  • if \p numQubits >qureg.numQubitsRepresented @throws segmentation-fault
  • if \p qubits contains fewer elements than \p numQubits @author Tyson Jones