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

Class definition for applying Grover diffusion to a marked register. More...

#include <diffusion.hpp>

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

Public Member Functions

 Diffusion ()
 Construct a new Diffusion object. More...
 
 ~Diffusion ()
 Destroy the Diffusion object. More...
 
void applyOpDiffusion (SimulatorType &sim, const std::vector< std::size_t > &ctrlIndices, const std::size_t target)
 Application of the Grover diffusion operator to already marked register. Follows the Q = -A S_0 A structure as defined in https://arxiv.org/pdf/quant-ph/0005055.pdf. More...
 

Detailed Description

template<class SimulatorType>
class QNLP::Diffusion< SimulatorType >

Class definition for applying Grover diffusion to a marked register.

Template Parameters
SimulatorTypeClass Simulator type

Definition at line 27 of file diffusion.hpp.

Constructor & Destructor Documentation

◆ Diffusion()

template<class SimulatorType>
QNLP::Diffusion< SimulatorType >::Diffusion ( )
inline

Construct a new Diffusion object.

Definition at line 34 of file diffusion.hpp.

34 {};

◆ ~Diffusion()

template<class SimulatorType>
QNLP::Diffusion< SimulatorType >::~Diffusion ( )
inline

Destroy the Diffusion object.

Definition at line 40 of file diffusion.hpp.

40 {};

Member Function Documentation

◆ applyOpDiffusion()

template<class SimulatorType>
void QNLP::Diffusion< SimulatorType >::applyOpDiffusion ( SimulatorType &  sim,
const std::vector< std::size_t > &  ctrlIndices,
const std::size_t  target 
)
inline

Application of the Grover diffusion operator to already marked register. Follows the Q = -A S_0 A structure as defined in https://arxiv.org/pdf/quant-ph/0005055.pdf.

Parameters
simThe quantum simulator object to apply the operator.
ctrlIndicesVector of qubit indices on ctrl lines (non NCU target)
targetTarget for application of the nCZ op

Definition at line 49 of file diffusion.hpp.

49  {
50  //For n-controlled not
51  for(auto& ctrl : ctrlIndices){
52  sim.applyGateH(ctrl);
53  sim.applyGateX(ctrl);
54  }
55  sim.applyGateH(target);
56  sim.applyGateX(target);
57 
58  sim.applyGateNCU(sim.getGateZ(), ctrlIndices, target, "Z");
59 
60  sim.applyGateX(target);
61  sim.applyGateH(target);
62 
63  for(auto& ctrl : ctrlIndices){
64  sim.applyGateX(ctrl);
65  sim.applyGateH(ctrl);
66  }
67  }

References ncu_opt_tester::sim, and ncu_opt_tester::target.

Referenced by QNLP::SimulatorGeneral< IntelSimulator >::applyDiffusion(), and TEST_CASE().

Here is the caller graph for this function:

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