5 #include "catch2/catch.hpp"    19 TEST_CASE(
"3 qubit Oracle standalone class",
"[oracle]"){
    22     auto& reg = 
sim.getQubitRegister();
    25     SECTION(
"2^3 bit patterns (8)"){
    27         const std::vector<std::size_t> bit_patterns {0, 1, 2, 3, 4, 5, 6, 7};
    30         std::vector<std::size_t> ctrl_indices;
    32             ctrl_indices.push_back(i);
    36         for(
auto &i : bit_patterns){
    37             DYNAMIC_SECTION(
"bitStringNCU with pattern " << i){
    49                 REQUIRE( reg[i].real() < 0.);
    52             DYNAMIC_SECTION(
"bitStringPhaseOracle with pattern " << i){
    64                 REQUIRE( reg[i].real() < 0.);
    69     SECTION(
"4 bit patterns"){
    71         const std::vector<std::size_t> bit_patterns {0, 5, 6, 7};
    74         std::vector<std::size_t> ctrl_indices;
    76             ctrl_indices.push_back(i);
    80         for(
auto &i : bit_patterns){
    81             DYNAMIC_SECTION(
"bitStringNCU with pattern " << i){
    93                 REQUIRE( reg[i].real() < 0.);
    96             DYNAMIC_SECTION(
"bitStringPhaseOracle with pattern " << i){
   107                 CAPTURE( reg[i], i );
   108                 REQUIRE( reg[i].real() < 0.);
   118 TEST_CASE(
"8 qubit Oracle standalone class",
"[oracle]"){
   121     auto& reg = 
sim.getQubitRegister();
   124     SECTION(
"2^8 bit patterns (256)"){
   126         std::vector<std::size_t> bit_patterns;
   127         for (std::size_t s = 0; s < (std::size_t) (0b1 << 
num_qubits); s++){
   128             bit_patterns.push_back(s);
   132         std::vector<std::size_t> ctrl_indices;
   133         for(std::size_t i = 0; i < 
num_qubits-1; ++i){
   134             ctrl_indices.push_back(i);
   138         for(
auto &i : bit_patterns){
   139             DYNAMIC_SECTION(
"bitStringNCU with pattern " << i){
   150                 CAPTURE( reg[i], i );
   151                 REQUIRE( reg[i].real() < 0.);
   154             DYNAMIC_SECTION(
"bitStringPhaseOracle with pattern " << i){
   165                 CAPTURE( reg[i], i );
   166                 REQUIRE( reg[i].real() < 0.);
   171     SECTION(
"4 bit patterns"){
   173         const std::vector<std::size_t> bit_patterns {0, 5, 6, 7};
   176         std::vector<std::size_t> ctrl_indices;
   177         for(std::size_t i = 0; i < 
num_qubits-1; ++i){
   178             ctrl_indices.push_back(i);
   182         for(
auto &i : bit_patterns){
   183             DYNAMIC_SECTION(
"bitStringNCU with pattern " << i){
   194                 CAPTURE( reg[i], i );
   195                 REQUIRE( reg[i].real() < 0.);
   198             DYNAMIC_SECTION(
"bitStringPhaseOracle with pattern " << i){
   209                 CAPTURE( reg[i], i );
   210                 REQUIRE( reg[i].real() < 0.);
   220 TEST_CASE(
"3 qubit Oracle simulator method",
"[oracle]"){
   223     auto& reg = 
sim.getQubitRegister();
   225     SECTION(
"2^3 bit patterns (8)"){
   227         const std::vector<std::size_t> bit_patterns {0, 1, 2, 3, 4, 5, 6, 7};
   230         std::vector<std::size_t> ctrl_indices;
   231         for(std::size_t i = 0; i < 
num_qubits-1; ++i){
   232             ctrl_indices.push_back(i);
   236         for(
auto &i : bit_patterns){
   237             DYNAMIC_SECTION(
"applyOracleU with pattern " << i){
   249                 CAPTURE( reg[i], i );
   250                 REQUIRE( reg[i].real() < 0.);
   253             DYNAMIC_SECTION(
"applyOraclePhase with pattern " << i){
   264                 CAPTURE( reg[i], i );
   265                 REQUIRE( reg[i].real() < 0.);
   270     SECTION(
"4 bit patterns"){
   272         const std::vector<std::size_t> bit_patterns {0, 5, 6, 7};
   275         std::vector<std::size_t> ctrl_indices;
   276         for(std::size_t i = 0; i < 
num_qubits-1; ++i){
   277             ctrl_indices.push_back(i);
   281         for(
auto &i : bit_patterns){
   282             DYNAMIC_SECTION(
"applyOracleU with pattern " << i){
   293                 CAPTURE( reg[i], i );
   294                 REQUIRE( reg[i].real() < 0.);
   297             DYNAMIC_SECTION(
"applyOraclePhase with pattern " << i){
   308                 CAPTURE( reg[i], i );
   309                 REQUIRE( reg[i].real() < 0.);
   319 TEST_CASE(
"8 qubit Oracle simulator method",
"[oracle]"){
   322     auto& reg = 
sim.getQubitRegister();
   324     SECTION(
"2^8 bit patterns (256)"){
   326         std::vector<std::size_t> bit_patterns;
   327         for (std::size_t s = 0; s < (std::size_t) (0b1 << 
num_qubits); s++){
   328             bit_patterns.push_back(s);
   332         std::vector<std::size_t> ctrl_indices;
   333         for(std::size_t i = 0; i < 
num_qubits-1; ++i){
   334             ctrl_indices.push_back(i);
   338         for(
auto &i : bit_patterns){
   339             DYNAMIC_SECTION(
"applyOracleU with pattern " << i){
   350                 CAPTURE( reg[i], i );
   351                 REQUIRE( reg[i].real() < 0.);
   354             DYNAMIC_SECTION(
"applyOraclePhase with pattern " << i){
   365                 CAPTURE( reg[i], i );
   366                 REQUIRE( reg[i].real() < 0.);
   371     SECTION(
"4 bit patterns"){
   373         const std::vector<std::size_t> bit_patterns {0, 5, 6, 7};
   376         std::vector<std::size_t> ctrl_indices;
   377         for(std::size_t i = 0; i < 
num_qubits-1; ++i){
   378             ctrl_indices.push_back(i);
   382         for(
auto &i : bit_patterns){
   383             DYNAMIC_SECTION(
"applyOracleU with pattern " << i){
   394                 CAPTURE( reg[i], i );
   395                 REQUIRE( reg[i].real() < 0.);
   398             DYNAMIC_SECTION(
"applyOraclePhase with pattern " << i){
   409                 CAPTURE( reg[i], i );
   410                 REQUIRE( reg[i].real() < 0.);
 
Class definition for IntelSimulator. The purpose of this class is to map the functionality of the und...
 
TEST_CASE("3 qubit Oracle standalone class","[oracle]")
Test 3 qubit Oracle standalone class.
 
Class definition for defining and applying an Oracle.
 
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 appropri...
 
Functions for applying black-box like functions to select appropriate qubits matching given patterns.
 
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 appropri...