Class definition for defining and applying an Oracle.
More...
#include <oracle.hpp>
|
static void | bitStringNCU (SimulatorType &s, std::size_t bitstring, const std::vector< std::size_t > &ctrl_indices, const std::size_t target, const Mat2x2Type &U, std::string gateLabel) |
| Takes bitstring as the binary pattern and indices as the qubits to operate upon. Applies the appropriate PauliX gates to the control lines to call the NCU with the given matrix. More...
|
|
static void | bitStringNCU (SimulatorType &s, std::size_t bitstring, const std::vector< std::size_t > &ctrl_indices, const std::vector< std::size_t > &aux_indices, const std::size_t target, const Mat2x2Type &U, std::string gateLabel) |
| Takes bitstring as the binary pattern and indices as the qubits to operate upon. Applies the appropriate PauliX gates to the control lines to call the NCU with the given matrix. Optimised variant using auxiliary qubits to reduce circuit depth. More...
|
|
static void | bitStringPhaseOracle (SimulatorType &s, std::size_t bitstring, const std::vector< std::size_t > &ctrlIndices, std::size_t target) |
| Takes bitstring as the binary pattern and indices as the qubits to operate upon. Applies the appropriate PauliX gates to the control lines to call the NCU with the given matrix. More...
|
|
|
using | Mat2x2Type = decltype(std::declval< SimulatorType >().getGateX()) |
|
template<class SimulatorType>
class QNLP::Oracle< SimulatorType >
Class definition for defining and applying an Oracle.
- Template Parameters
-
SimulatorType | Class Simulator type |
Definition at line 26 of file oracle.hpp.
◆ Mat2x2Type
template<class SimulatorType>
◆ Oracle()
template<class SimulatorType>
◆ ~Oracle()
template<class SimulatorType>
◆ bitStringNCU() [1/2]
template<class SimulatorType>
static void QNLP::Oracle< SimulatorType >::bitStringNCU |
( |
SimulatorType & |
s, |
|
|
std::size_t |
bitstring, |
|
|
const std::vector< std::size_t > & |
ctrl_indices, |
|
|
const std::size_t |
target, |
|
|
const Mat2x2Type & |
U, |
|
|
std::string |
gateLabel |
|
) |
| |
|
inlinestatic |
Takes bitstring as the binary pattern and indices as the qubits to operate upon. Applies the appropriate PauliX gates to the control lines to call the NCU with the given matrix.
- Parameters
-
s | Instance of quantum simulator |
bitstring | Binary pattern represented by a std::size_t bitstring |
ctrl_indices | Indices of the control qubits in the register |
target | Qubit acting as target |
U | Unitary matrix to apply |
gateLabel | Label to assign operation for U |
Definition at line 54 of file oracle.hpp.
55 std::size_t bitmask = 0b1;
56 std::vector<std::size_t> reverse_pattern;
57 for(std::size_t i = 0; i < ctrl_indices.size() + 1; ++i){
60 if( ! (bitstring & (bitmask<<i) ) ){
61 reverse_pattern.push_back(i);
62 if( i < ctrl_indices.size())
63 s.applyGateX(ctrl_indices[i]);
68 s.applyGateNCU(U, ctrl_indices,
target, gateLabel);
70 for(
auto& revIdx : reverse_pattern){
71 if( revIdx < ctrl_indices.size()){
72 s.applyGateX(ctrl_indices[revIdx]);
References ncu_opt_tester::target.
Referenced by QNLP::SimulatorGeneral< IntelSimulator >::applyOracleU(), QNLP::Oracle< SimulatorType >::bitStringPhaseOracle(), and TEST_CASE().
◆ bitStringNCU() [2/2]
template<class SimulatorType>
static void QNLP::Oracle< SimulatorType >::bitStringNCU |
( |
SimulatorType & |
s, |
|
|
std::size_t |
bitstring, |
|
|
const std::vector< std::size_t > & |
ctrl_indices, |
|
|
const std::vector< std::size_t > & |
aux_indices, |
|
|
const std::size_t |
target, |
|
|
const Mat2x2Type & |
U, |
|
|
std::string |
gateLabel |
|
) |
| |
|
inlinestatic |
Takes bitstring as the binary pattern and indices as the qubits to operate upon. Applies the appropriate PauliX gates to the control lines to call the NCU with the given matrix. Optimised variant using auxiliary qubits to reduce circuit depth.
- Parameters
-
s | Instance of quantum simulator |
bitstring | Binary pattern represented by a std::size_t bitstring |
ctrl_indices | Indices of the control qubits in the register |
aux_indices | Indices of the auxiliary qubits in the register to reduce depth. State will be returned to pre-method call values. |
target | Qubit acting as target |
U | Unitary matrix to apply |
gateLabel | Label to assign operation for U |
Definition at line 92 of file oracle.hpp.
93 std::size_t bitmask = 0b1;
94 std::vector<std::size_t> reverse_pattern;
95 for(std::size_t i = 0; i < ctrl_indices.size() + 1; ++i){
98 if( ! (bitstring & (bitmask<<i) ) ){
99 reverse_pattern.push_back(i);
100 if( i < ctrl_indices.size())
101 s.applyGateX(ctrl_indices[i]);
106 s.applyGateNCU(U, ctrl_indices, aux_indices,
target, gateLabel);
108 for(
auto& revIdx : reverse_pattern){
109 if( revIdx < ctrl_indices.size()){
110 s.applyGateX(ctrl_indices[revIdx]);
References ncu_opt_tester::target.
◆ bitStringPhaseOracle()
template<class SimulatorType>
static void QNLP::Oracle< SimulatorType >::bitStringPhaseOracle |
( |
SimulatorType & |
s, |
|
|
std::size_t |
bitstring, |
|
|
const std::vector< std::size_t > & |
ctrlIndices, |
|
|
std::size_t |
target |
|
) |
| |
|
inlinestatic |
The documentation for this class was generated from the following file:
- /Users/mlxd/Desktop/intel-qnlp-rc2/modules/gate_ops/oracle/oracle.hpp