28 #define IS_SET(byte,bit) (((byte) & (1UL << (bit))) >> (bit)) 35 template <
class SimulatorType>
38 using Mat2x2Type = decltype(std::declval<SimulatorType>().getGateX());
40 std::unique_ptr< std::vector<Mat2x2Type> >
S;
85 S.reset(
new std::vector<Mat2x2Type> (
m));
88 double diag, off_diag;
90 for(std::size_t i = 0; i <
m; i++){
91 off_diag = 1.0/sqrt((
double)(p));
92 diag = off_diag * sqrt((
double)(p-1));
94 (*S)[i](0,0) = {diag, 0.0};
95 (*S)[i](0,1) = {off_diag, 0.0};
96 (*S)[i](1,0) = {-off_diag, 0.0};
97 (*S)[i](1,1) = {diag, 0.0};
115 const std::vector<std::size_t>& bin_patterns){
122 qSim.getGateWriter().segmentMarkerOut(
"Prepare state in |0...>|0...0>|01> of lengths n,n,2");
128 for(std::size_t i = 0; i <
m; i++){
133 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_0 \\rangle");
136 if(
IS_SET(bin_patterns[i],j)){
144 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_1 \\rangle");
153 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_2 \\rangle");
163 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_3 \\rangle");
174 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_4 \\rangle");
182 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_5 \\rangle");
189 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_6 \\rangle");
199 qSim.getGateWriter().segmentMarkerOut(
"| \\Psi_7 \\rangle");
207 qSim.getGateWriter().segmentMarkerOut(
"Reset p to | 00\\ldots 0 \\rangle");
211 if(
IS_SET(bin_patterns[i],j)){
std::size_t len_reg_auxiliary
EncodeBinIntoSuperpos()=delete
Construct a new object instance to encode a binary string into a superposition (disabled)
void encodeBinInToSuperpos_unique(SimulatorType &qSim, const std::vector< std::size_t > ®_memory, const std::vector< std::size_t > ®_auxiliary, const std::vector< std::size_t > &bin_patterns)
Encodes each element of inputted vector as a binary string in a superpostiion of states....
void initialiseMats()
Initialiser of the encoder (define the required PauliX and the unitary matrix S)
EncodeBinIntoSuperpos(const std::size_t num_bin_patterns, const std::size_t len_bin_pattern_)
Construct a new object instance to encode a binary string into a superposition.
std::size_t len_bin_pattern
#define IS_SET(byte, bit)
Checks if the bit'th bit of the integer byte is set.
~EncodeBinIntoSuperpos()
Destroy the Encode Bin Into Superpos object.
std::unique_ptr< std::vector< Mat2x2Type > > S
decltype(std::declval< SimulatorType >().getGateX()) Mat2x2Type
Definition of class to encode a binary string represented by an integer into a superposition of state...