Definition of class to encode a binary string represented by an integer into a superposition of states.
More...
|
| EncodeBinIntoSuperpos ()=delete |
| Construct a new object instance to encode a binary string into a superposition (disabled) More...
|
|
| 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. More...
|
|
| ~EncodeBinIntoSuperpos () |
| Destroy the Encode Bin Into Superpos object. More...
|
|
void | initialiseMats () |
| Initialiser of the encoder (define the required PauliX and the unitary matrix S) More...
|
|
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. Requires each binary input to be unique. More...
|
|
template<class SimulatorType>
class QNLP::EncodeBinIntoSuperpos< SimulatorType >
Definition of class to encode a binary string represented by an integer into a superposition of states.
- Template Parameters
-
SimulatorType | Class simulator type |
Definition at line 36 of file bin_into_superpos.hpp.
template<class SimulatorType >
void QNLP::EncodeBinIntoSuperpos< SimulatorType >::encodeBinInToSuperpos_unique |
( |
SimulatorType & |
qSim, |
|
|
const std::vector< std::size_t > & |
reg_memory, |
|
|
const std::vector< std::size_t > & |
reg_auxiliary, |
|
|
const std::vector< std::size_t > & |
bin_patterns |
|
) |
| |
|
inline |
Encodes each element of inputted vector as a binary string in a superpostiion of states. Requires each binary input to be unique.
- Parameters
-
qReg | Qubit register |
reg_memory | A vector containing the indices of the qubits of the memory register. |
reg_auxiliary | A vector containing the indices of the qubits of the auxiliary register. |
Vector | of non-negative integers which represent the inputted binary patters that are to be encoded. |
Definition at line 112 of file bin_into_superpos.hpp.
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
std::size_t len_bin_pattern
#define IS_SET(byte, bit)
Checks if the bit'th bit of the integer byte is set.
std::unique_ptr< std::vector< Mat2x2Type > > S
References IS_SET, QNLP::EncodeBinIntoSuperpos< SimulatorType >::len_bin_pattern, QNLP::EncodeBinIntoSuperpos< SimulatorType >::len_reg_auxiliary, QNLP::EncodeBinIntoSuperpos< SimulatorType >::m, QNLP_Python_MPI::reg_auxiliary, QNLP_EndToEnd_MPI::reg_memory, and QNLP::EncodeBinIntoSuperpos< SimulatorType >::S.
Referenced by QNLP::SimulatorGeneral< IntelSimulator >::encodeBinToSuperpos_unique(), and TEST_CASE().