The Quantum Exact Simulation Toolkit v4.3.0
Loading...
Searching...
No Matches

Functions for applying the Quantum Fourier Transform. More...

Functions

void applyFullQuantumFourierTransform (Qureg qureg, bool inverse)
 
void applyQuantumFourierTransform (Qureg qureg, int *targets, int numTargets, bool inverse)
 

Detailed Description

Functions for applying the Quantum Fourier Transform.

Function Documentation

◆ applyFullQuantumFourierTransform()

void applyFullQuantumFourierTransform ( Qureg qureg,
bool inverse )

Applies the Quantum Fourier Transform upon all qubits in qureg. Alternatively, applies the Inverse Quantum Fourier Transform according to inverse.

Formulae

The Quantum Fourier Transform maps each computational basis state \( \ket{j} \) in an \( N \) qubit qureg according to

\[ \ket{j} \rightarrow \frac{1}{\sqrt{2^N}} \sum_{k=0}^{2^N-1} e^{2 \pi i j k / 2^N} \ket{k}. \]

Similarly the Inverse Quantum Fourier Transform maps each basis state like

\[ \ket{j} \rightarrow \frac{1}{\sqrt{2^N}} \sum_{k=0}^{2^N-1} e^{-2 \pi i j k / 2^N} \ket{k}. \]

Equivalences
Parameters
[in,out]quregthe state to modify.
[in]inversewhether to apply the inverse QFT or forward QFT
Exceptions
error
  • if qureg is uninitialised.
See also
Author
Vasco Ferreira

Definition at line 1793 of file operations.cpp.

1793 {
1794 validate_quregFields(qureg, __func__);
1795
1796 auto targets = util_getRange(qureg.numQubits);
1797 applyQuantumFourierTransform(qureg, targets.data(), targets.size(), inverse);
1798}
void applyQuantumFourierTransform(Qureg qureg, int *targets, int numTargets, bool inverse)

◆ applyQuantumFourierTransform()

void applyQuantumFourierTransform ( Qureg qureg,
int * targets,
int numTargets,
bool inverse )

Applies the Quantum Fourier Transform upon the specified targets of qureg. Alternatively, applies the Inverse Quantum Fourier Transform according to inverse.

Formulae

Letting \( N \) = numTargets, the \( N \) qubit Quantum Fourier Transform maps each computational basis state of the targeted qubits, \( \ket{j} \), according to

\[ \ket{j} \rightarrow \frac{1}{\sqrt{2^N}} \sum_{k=0}^{2^N-1} e^{2 \pi i j k / 2^N} \ket{k}. \]

Similarly the Inverse Quantum Fourier Transform maps each basis state like

\[ \ket{j} \rightarrow \frac{1}{\sqrt{2^N}} \sum_{k=0}^{2^N-1} e^{-2 \pi i j k / 2^N} \ket{k}. \]

Parameters
[in,out]quregthe state to modify.
[in]targetsthe indices of the target qubits.
[in]numTargetsthe length of list targets
[in]inversewhether to apply the inverse QFT or forward QFT
Exceptions
error
  • if qureg is uninitialised.
  • if targets are invalid qubit indices.
  • if targets are not unique.
  • if numTargets < 1.
See also
Author
Vasco Ferreira

Definition at line 1755 of file operations.cpp.

1755 {
1756 validate_quregFields(qureg, __func__);
1757 validate_targets(qureg, targets, numTargets, __func__);
1758
1759 /// @todo
1760 /// change this placeholder implementation to the bespoke, optimised routine,
1761 /// wherein each contiguous controlled-phase gate is merged
1762
1763 int mid = numTargets/2; // floors
1764
1765 // don't think it is worth overcomplicating this to avoid slight repetition
1766 if (inverse) {
1767 for (int n=0; n<mid; n++)
1768 applySwap(qureg, targets[n], targets[numTargets-1-n]);
1769
1770 for (int n=0; n<numTargets; n++) {
1771 for (int m=0; m<n; m++) {
1772 qreal arg = - const_PI / powerOf2(m+1);
1773 applyTwoQubitPhaseShift(qureg, targets[n], targets[n-m-1], arg);
1774 }
1775 applyHadamard(qureg, targets[n]);
1776 }
1777
1778 } else {
1779 for (int n=numTargets-1; n>=0; n--) {
1780 applyHadamard(qureg, targets[n]);
1781
1782 for (int m=0; m<n; m++) {
1783 qreal arg = const_PI / powerOf2(m+1);
1784 applyTwoQubitPhaseShift(qureg, targets[n], targets[n-m-1], arg);
1785 }
1786 }
1787
1788 for (int n=0; n<mid; n++)
1789 applySwap(qureg, targets[n], targets[numTargets-1-n]);
1790 }
1791}
void applyHadamard(Qureg qureg, int target)
void applyTwoQubitPhaseShift(Qureg qureg, int target1, int target2, qreal angle)
void applySwap(Qureg qureg, int qubit1, int qubit2)

Referenced by applyFullQuantumFourierTransform(), and applyQuantumFourierTransform().