QNLP  v1.0
QNLP::QFT< SimulatorType > Class Template Reference

Class definition for performing quantum forward and inverse Fourier transforms. More...

#include <qft.hpp>

Collaboration diagram for QNLP::QFT< SimulatorType >:
Collaboration graph

Static Public Member Functions

static void applyQFT (SimulatorType &qSim, const unsigned int minIdx, const unsigned int maxIdx)
 Applies the forward QFT on the given register. More...
 
static void applyIQFT (SimulatorType &qSim, const unsigned int minIdx, const unsigned int maxIdx)
 Applies the inverse QFT on the given register. More...
 

Detailed Description

template<class SimulatorType>
class QNLP::QFT< SimulatorType >

Class definition for performing quantum forward and inverse Fourier transforms.

Template Parameters
SimulatorTypeClass Simulator type

Definition at line 23 of file qft.hpp.

Member Function Documentation

◆ applyIQFT()

template<class SimulatorType >
static void QNLP::QFT< SimulatorType >::applyIQFT ( SimulatorType &  qSim,
const unsigned int  minIdx,
const unsigned int  maxIdx 
)
inlinestatic

Applies the inverse QFT on the given register.

Parameters
qSimThe qubit register
minIdxthe lower-bounded index in the register to transform
maxIdxthe upper-bounded index in the register to transform

Definition at line 55 of file qft.hpp.

55  {
56  double theta=0;
57  qSim.InvertRegister(minIdx, maxIdx);
58 
59  //Target lines
60  for(int i = minIdx; i <= (int) maxIdx; i++){
61 
62  //Control lines:
63  for(int j = minIdx; j < i; j++){
64  theta = -2.0*M_PI / (std::size_t) (0b1<<(1+(i-j)));
65  qSim.applyGateCPhaseShift(theta, j, i);
66  }
67  qSim.applyGateH( i );
68  }
69  }

◆ applyQFT()

template<class SimulatorType >
static void QNLP::QFT< SimulatorType >::applyQFT ( SimulatorType &  qSim,
const unsigned int  minIdx,
const unsigned int  maxIdx 
)
inlinestatic

Applies the forward QFT on the given register.

Parameters
qSimThe qubit register
minIdxthe lower-bounded index in the register to transform
maxIdxthe upper-bounded index in the register to transform

Definition at line 32 of file qft.hpp.

32  {
33  double theta=0;
34 
35  //target lines
36  for(int i = maxIdx; i >= (int) minIdx; i--){
37  qSim.applyGateH(i);
38 
39  //Control lines:
40  for(int j = i-1; j >= (int) minIdx; j--){
41  theta = 2.0*M_PI / (std::size_t) (0b1<<(1+(i-j)));
42  qSim.applyGateCPhaseShift(theta, j, i);
43  }
44  }
45  qSim.InvertRegister(minIdx, maxIdx);
46  }

The documentation for this class was generated from the following file: