QNLP
v1.0
|
Class definition for IntelSimulator. The purpose of this class is to map the functionality of the underlying quantum simulator to this class so that it can be used as the template for the CRTP templated SimulatorGeneral class. More...
Public Types | |
using | TMDP = qhipster::TinyMatrix< ComplexDP, 2, 2, 32 > |
using | QRDP = QubitRegister< ComplexDP > |
using | CST = const std::size_t |
Public Member Functions | |
IntelSimulator (int numQubits, bool useFusion=false) | |
Construct a new Intel Simulator object. The constructor also sets up and initialises the MPI environemnt if MPI is enabled in the build process. More... | |
~IntelSimulator () | |
Destroy the Intel Simulator object. More... | |
void | applyGateU (const TMDP &U, CST qubitIndex, std::string label="U") |
Apply arbitrary user-defined unitary gate to qubit at qubit_idx. More... | |
void | applyGateI (std::size_t qubitIndex) |
Apply the Identity gate to the given qubit. More... | |
void | applyGatePhaseShift (std::size_t qubit_idx, double angle) |
Apply phase shift to given Qubit; [[1 0] [0 exp(i*angle)]]. More... | |
void | applyGateSqrtSwap (std::size_t qubit_idx0, std::size_t qubit_idx1) |
Performs Sqrt SWAP gate between two given qubits (half way SWAP) More... | |
void | applyGateCCX (std::size_t ctrl_qubit0, std::size_t ctrl_qubit1, std::size_t target_qubit) |
Controlled controlled NOT (CCNOT, CCX) gate. More... | |
void | applyGateCSwap (std::size_t ctrl_qubit, std::size_t qubit_swap0, std::size_t qubit_swap1) |
void | applyGateX (CST qubitIndex) |
Apply the Pauli X gate to the given qubit. More... | |
void | applyGateY (CST qubitIndex) |
Apply the Pauli Y gate to the given qubit. More... | |
void | applyGateZ (CST qubitIndex) |
Apply the Pauli Z gate to the given qubit. More... | |
void | applyGateH (CST qubitIndex) |
Apply the Hadamard gate to the given qubit. More... | |
void | applyGateSqrtX (CST qubitIndex) |
Apply the Sqrt{Pauli X} gate to the given qubit. More... | |
void | applyGateRotX (CST qubitIndex, double angle) |
Apply the given Rotation about X-axis to the given qubit. More... | |
void | applyGateRotY (CST qubitIndex, double angle) |
Apply the given Rotation about Y-axis to the given qubit. More... | |
void | applyGateRotZ (CST qubitIndex, double angle) |
Apply the given Rotation about Z-axis to the given qubit. More... | |
TMDP | getGateX () |
Get the Pauli-X gate. More... | |
TMDP | getGateY () |
Get the Pauli-Y gate. More... | |
TMDP | getGateZ () |
Get the Pauli-Z gate. More... | |
TMDP | getGateI () |
Get the Identity. More... | |
TMDP | getGateH () |
Get the Hadamard gate. More... | |
void | applyGateCU (const TMDP &U, CST control, CST target, std::string label="U") |
Apply the given controlled unitary gate on target qubit. More... | |
void | applyGateCX (CST control, CST target) |
Apply Controlled Pauli-X (CNOT) on target qubit. More... | |
void | applyGateCY (CST control, CST target) |
Apply Controlled Pauli-Y on target qubit. More... | |
void | applyGateCZ (CST control, CST target) |
Apply Controlled Pauli-Z on target qubit. More... | |
void | applyGateCH (CST control, CST target) |
Apply Controlled Hadamard on target qubit. More... | |
void | applyGateCPhaseShift (double angle, unsigned int control, unsigned int target) |
Perform controlled phase shift gate. More... | |
void | applyGateCRotX (CST control, CST target, const double theta) |
Apply the given Controlled Rotation about X-axis to the given qubit. More... | |
void | applyGateCRotY (CST control, CST target, double theta) |
Apply the given Controlled Rotation about Y-axis to the given qubit. More... | |
void | applyGateCRotZ (CST control, CST target, const double theta) |
Apply the given Controlled Rotation about Z-axis to the given qubit. More... | |
void | applyGateSwap (CST qubit_idx0, CST qubit_idx1) |
Swap the qubits at the given indices. More... | |
QubitRegister< ComplexDP > & | getQubitRegister () |
Get the Qubit Register object. More... | |
const QubitRegister< ComplexDP > & | getQubitRegister () const |
Get the Qubit Register object. More... | |
std::size_t | getNumQubits () |
Get the number of Qubits. More... | |
void | initRegister () |
(Re)Initialise the underlying register of the encapsulated simulator to well-defined state (|0....0>) More... | |
void | applyAmplitudeNorm () |
Apply normalization to the amplitudes of each state. This is required after a qubit in a state is collapsed. More... | |
bool | applyMeasurement (CST target, bool normalize=true) |
Apply measurement to a target qubit, randomly collapsing the qubit proportional to the amplitude and returns the collapsed value. If built with MPI enabled, this member function collpases the corresponding qubit in each state across all processes. More... | |
void | collapseToBasisZ (CST target, bool collapseValue) |
Apply measurement to a target qubit with respect to the Z-basis, collapsing to a specified value (0 or 1). Amplitudes are r-normalized afterwards. More... | |
void | PrintStates (std::string x, std::vector< std::size_t > qubits={}) |
Prints the string x and then for each state of the specified qubits in the superposition, prints each its amplitude, followed by state and then by the probability of that state. Note that this state observation method is not a permitted quantum operation, however it is provided for convenience and debugging/testing. More... | |
std::pair< std::size_t, std::size_t > | getGateCounts () |
Print 1 and 2 qubit gate call counts. More... | |
complex< double > | overlap (IntelSimulator &sim) |
Compute overlap between different simulators. Number of qubits must be the same. More... | |
void | applyGateX (std::size_t qubit_idx) |
Apply the Pauli X gate to the given qubit. More... | |
void | applyGateY (std::size_t qubit_idx) |
Apply the Pauli Y gate to the given qubit. More... | |
void | applyGateZ (std::size_t qubit_idx) |
Apply the Pauli Z gate to the given qubit. More... | |
void | applyGateH (std::size_t qubit_idx) |
Apply the Hadamard gate to the given qubit. More... | |
void | applyGateSqrtX (std::size_t qubit_idx) |
Apply the Sqrt{Pauli X} gate to the given qubit. More... | |
void | applyGateRotX (std::size_t qubit_idx, double angle_rad) |
Apply the given Rotation about X-axis to the given qubit. More... | |
void | applyGateRotY (std::size_t qubit_idx, double angle_rad) |
Apply the given Rotation about Y-axis to the given qubit. More... | |
void | applyGateRotZ (std::size_t qubit_idx, double angle_rad) |
Apply the given Rotation about Z-axis to the given qubit. More... | |
void | applyGateU (const Mat2x2Type &U, std::size_t qubit_idx) |
Apply arbitrary user-defined unitary gate to qubit at qubit_idx. More... | |
void | applyGateCU (const Mat2x2Type &U, const std::size_t control, const std::size_t target, std::string label="CU") |
Apply the given controlled unitary gate on target qubit. More... | |
void | applyGateCX (const std::size_t control, const std::size_t target) |
Apply Controlled Pauli-X (CNOT) on target qubit. More... | |
void | applyGateCY (const std::size_t control, const std::size_t target) |
Apply Controlled Pauli-Y on target qubit. More... | |
void | applyGateCZ (const std::size_t control, const std::size_t target) |
Apply Controlled Pauli-Z on target qubit. More... | |
void | applyGateCH (const std::size_t control, const std::size_t target) |
Apply Controlled Hadamard on target qubit. More... | |
void | applyGateSwap (std::size_t qubit_idx0, std::size_t qubit_idx1) |
Swap the qubits at the given indices. More... | |
void | applyGatePhaseShift (double angle, std::size_t qubit_idx) |
Apply phase shift to given Qubit; [[1 0] [0 exp(i*angle)]]. More... | |
void | applyGateCPhaseShift (double angle, std::size_t control, std::size_t target) |
Perform controlled phase shift gate. More... | |
void | applyGateCRotX (std::size_t ctrl_qubit, std::size_t qubit_idx, double angle_rad) |
Apply the given Controlled Rotation about X-axis to the given qubit. More... | |
void | applyGateCRotY (std::size_t ctrl_qubit, std::size_t qubit_idx, double angle_rad) |
Apply the given Controlled Rotation about Y-axis to the given qubit. More... | |
void | applyGateCRotZ (std::size_t ctrl_qubit, std::size_t qubit_idx, double angle_rad) |
Apply the given Controlled Rotation about Z-axis to the given qubit. More... | |
void | applyQFT (std::size_t minIdx, std::size_t maxIdx) |
Apply the forward Quantum Fourier transform (QFT) to the given register index range. More... | |
void | applyIQFT (std::size_t minIdx, std::size_t maxIdx) |
Apply the inverse Quantum Fourier transform (IQFT) to the given register index range. More... | |
void | sumReg (std::size_t r0_minIdx, std::size_t r0_maxIdx, std::size_t r1_minIdx, std::size_t r1_maxIdx) |
Applies |r1>|r2> -> |r1>|r1+r2> More... | |
void | subReg (std::size_t r0_minIdx, std::size_t r0_maxIdx, std::size_t r1_minIdx, std::size_t r1_maxIdx) |
Applies |r1>|r2> -> |r1>|r1-r2> More... | |
void | applyGateNCU (const Mat2x2Type &U, const std::vector< std::size_t > &ctrlIndices, std::size_t target, std::string label) |
Apply n-control unitary gate to the given qubit target. More... | |
void | applyGateNCU (const Mat2x2Type &U, const std::vector< std::size_t > &ctrlIndices, const std::vector< std::size_t > &auxIndices, std::size_t target, std::string label) |
Apply n-control sigma_x gate to the given qubit target, using auxiliary qubits for 5CX optimisation. More... | |
void | applyOracleU (std::size_t bit_pattern, const std::vector< std::size_t > &ctrlIndices, std::size_t target, const Mat2x2Type &U, std::string gateLabel) |
Apply oracle to match given binary index with non adjacent controls. More... | |
void | applyOracleU (std::size_t bit_pattern, const std::vector< std::size_t > &ctrlIndices, const std::vector< std::size_t > &auxIndices, std::size_t target, const Mat2x2Type &U, std::string gateLabel) |
Apply oracle to match given binary index with non adjacent controls. More... | |
void | applyOraclePhase (std::size_t bit_pattern, const std::vector< std::size_t > &ctrlIndices, std::size_t target) |
Apply oracle to match given binary index with linearly adjacent controls. More... | |
void | applyDiffusion (const std::vector< std::size_t > &ctrlIndices, std::size_t target) |
Apply diffusion operator on marked state. More... | |
void | encodeToRegister (std::size_t target_pattern, const std::vector< std::size_t > target_register, std::size_t len_bin_pattern) |
Encodes a defined binary pattern into a defined target register (initially in state |00...0>) of all quantum states in the superposition. More... | |
void | encodeBinToSuperpos_unique (const std::vector< std::size_t > ®_memory, const std::vector< std::size_t > ®_auxiliary, const std::vector< std::size_t > &bin_patterns, const std::size_t len_bin_pattern) |
Encode inputted binary strings to the memory register specified as a superposition of states. Note that this implementation does not allow for multiple instances of the same input pattern but allows for 0 to be encoded. More... | |
void | applyHammingDistanceRotY (std::size_t test_pattern, const std::vector< std::size_t > reg_mem, const std::vector< std::size_t > reg_auxiliary, std::size_t len_bin_pattern) |
Computes the relative Hamming distance between the test pattern and the pattern stored in each state of the superposition, storing the result in the amplitude of the corresponding state. More... | |
void | applyHammingDistanceOverwrite (std::size_t test_pattern, const std::vector< std::size_t > reg_mem, const std::vector< std::size_t > reg_auxiliary, std::size_t len_bin_pattern) |
Computes the relative Hamming distance between the test pattern and the pattern stored in each state of the superposition, overwriting the aux register pattern with the resulting bit differences. More... | |
bool | applyMeasurement (std::size_t target, bool normalize=true) |
Apply measurement to a target qubit, randomly collapsing the qubit proportional to the amplitude and returns the collapsed value. More... | |
std::size_t | applyMeasurementToRegister (std::vector< std::size_t > target_qubits, bool normalize=true) |
Apply measurement to a set of target qubits, randomly collapsing the qubits proportional to the amplitude and returns the bit string of the qubits in the order they are represented in the vector of indexes, in the form of an unsigned integer. More... | |
void | groupQubits (const std::vector< std::size_t > reg_auxiliary, bool lsb=true) |
Group all set qubits to MSB in register (ie |010100> -> |000011>) More... | |
void | collapseToBasisZ (std::size_t target, bool collapseValue) |
Apply measurement to a target qubit with respect to the Z-basis, collapsing to a specified value (0 or 1). Amplitudes are r-normalized afterwards. More... | |
void | initCaches () |
Initialise caches used in NCU operation. More... | |
void | addUToCache (std::string gateLabel, const Mat2x2Type &U) |
Adds a matrix to the cache, assigning it to a defined label. This is used in the caching for the NCU operation. More... | |
Mat2x2Type | matrixSqrt (const Mat2x2Type &U) |
Calculates the unitary matrix square root (U == VV, where V is returned) More... | |
void | InvertRegister (const unsigned int minIdx, const unsigned int maxIdx) |
Invert the register about the given indides: 0,1,2...n-1,n -> n,n-1,...,1,0. More... | |
Static Public Member Functions | |
static Mat2x2Type | adjointMatrix (const Mat2x2Type &U) |
Function to calculate the adjoint of an input matrix. More... | |
Protected Attributes | |
std::any | sim_ncu |
Private Member Functions | |
void | collapseQubit (CST target, bool collapseValue) |
Collapses specified qubit in register to the collapseValue without applying normalization. More... | |
double | getStateProbability (CST target) |
Get the probability of the specified qubit being in the state |1> More... | |
Private Attributes | |
const std::size_t | uid |
std::size_t | numQubits |
QRDP | qubitRegister |
std::vector< TMDP > | gates |
std::size_t | gate_count_1qubit |
std::size_t | gate_count_2qubit |
std::random_device | rd |
std::mt19937 | mt |
std::uniform_real_distribution< double > | dist |
Class definition for IntelSimulator. The purpose of this class is to map the functionality of the underlying quantum simulator to this class so that it can be used as the template for the CRTP templated SimulatorGeneral class.
Definition at line 35 of file IntelSimulator.cpp.
using QNLP::IntelSimulator::CST = const std::size_t |
Definition at line 39 of file IntelSimulator.cpp.
using QNLP::IntelSimulator::QRDP = QubitRegister<ComplexDP> |
Definition at line 38 of file IntelSimulator.cpp.
using QNLP::IntelSimulator::TMDP = qhipster::TinyMatrix<ComplexDP, 2, 2, 32> |
Definition at line 37 of file IntelSimulator.cpp.
|
inline |
Construct a new Intel Simulator object. The constructor also sets up and initialises the MPI environemnt if MPI is enabled in the build process.
numQubits | Number of qubits in quantum register |
useFusion | Implement gate fusion (default is False) |
Definition at line 47 of file IntelSimulator.cpp.
References dist, gate_count_1qubit, gate_count_2qubit, gates, QNLP::SimulatorGeneral< IntelSimulator >::initCaches(), mt, qubitRegister, ncu_opt_tester::rank, and rd.
|
inline |
|
inlineinherited |
Adds a matrix to the cache, assigning it to a defined label. This is used in the caching for the NCU operation.
Mat2x2Type | Matrix type to be cached |
gateLabel | Label assigned to the matrix being cached |
U | Matrix to be cached |
Definition at line 703 of file Simulator.hpp.
|
inlinestaticinherited |
Function to calculate the adjoint of an input matrix.
Mat2x2Type | Matrix type |
U | Unitary matrix to be adjointed |
Definition at line 757 of file Simulator.hpp.
|
inline |
Apply normalization to the amplitudes of each state. This is required after a qubit in a state is collapsed.
Definition at line 642 of file IntelSimulator.cpp.
References qubitRegister.
Referenced by applyMeasurement(), and collapseToBasisZ().
|
inlineinherited |
Apply diffusion operator on marked state.
ctrlIndices | Vector of control line indices |
target | Target qubit index to apply Ctrl-Z upon. |
Definition at line 536 of file Simulator.hpp.
|
inline |
Controlled controlled NOT (CCNOT, CCX) gate.
ctrl_qubit0 | Control qubit 0 |
ctrl_qubit1 | Control qubit 1 |
target_qubit | Target qubit |
Definition at line 193 of file IntelSimulator.cpp.
References QNLP::SimulatorGeneral< IntelSimulator >::applyGateNCU(), and getGateX().
|
inlineinherited |
Apply Controlled Hadamard on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 294 of file Simulator.hpp.
Apply Controlled Hadamard on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 496 of file IntelSimulator.cpp.
References gate_count_2qubit, getGateH(), qubitRegister, and ncu_opt_tester::target.
|
inlineinherited |
Perform controlled phase shift gate.
angle | Angle of phase shift in rads |
control | Index of control qubit |
target | Index of target qubit |
Definition at line 335 of file Simulator.hpp.
|
inline |
Perform controlled phase shift gate.
angle | Angle of phase shift in rads |
control | Index of control qubit |
target | Index of target qubit |
Definition at line 515 of file IntelSimulator.cpp.
References gate_count_2qubit, gates, qubitRegister, and ncu_opt_tester::target.
|
inlineinherited |
Apply the given Controlled Rotation about X-axis to the given qubit.
ctrl_qubit | Control qubit |
qubit_idx | Index of qubit to rotate about X-axis |
angle_rad | Rotation angle |
Definition at line 373 of file Simulator.hpp.
Apply the given Controlled Rotation about X-axis to the given qubit.
control | Control qubit |
target | Index of qubit to rotate about X-axis |
theta | Rotation angle |
Definition at line 537 of file IntelSimulator.cpp.
References gate_count_2qubit, getGateI(), qubitRegister, and ncu_opt_tester::target.
|
inlineinherited |
Apply the given Controlled Rotation about Y-axis to the given qubit.
ctrl_qubit | Control qubit |
qubit_idx | Index of qubit to rotate about Y-axis |
angle_rad | Rotation angle |
Definition at line 384 of file Simulator.hpp.
Apply the given Controlled Rotation about Y-axis to the given qubit.
control | Control qubit |
target | Index of qubit to rotate about Y-axis |
theta | Rotation angle |
Definition at line 556 of file IntelSimulator.cpp.
References gate_count_2qubit, getGateI(), qubitRegister, and ncu_opt_tester::target.
|
inlineinherited |
Apply the given Controlled Rotation about Z-axis to the given qubit.
ctrl_qubit | Control qubit |
qubit_idx | Index of qubit to rotate about Z-axis |
angle_rad | Rotation angle |
Definition at line 395 of file Simulator.hpp.
Apply the given Controlled Rotation about Z-axis to the given qubit.
control | Control qubit |
target | Index of qubit to rotate about Z-axis |
theta | Rotation angle |
Definition at line 575 of file IntelSimulator.cpp.
References gate_count_2qubit, getGateI(), qubitRegister, and ncu_opt_tester::target.
|
inline |
@brief Controlled SWAP gate (Controlled swap decomposition taken from arXiV:1301.3727
)
@param ctrl_qubit Control qubit @param qubit_swap0 Swap qubit 0 @param qubit_swap1 Swap qubit 1
Definition at line 205 of file IntelSimulator.cpp.
References applyGateCU(), and applyGateCX().
|
inlineinherited |
Apply the given controlled unitary gate on target qubit.
U | User-defined arbitrary 2x2 unitary gate (matrix) |
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 254 of file Simulator.hpp.
|
inline |
Apply the given controlled unitary gate on target qubit.
U | User-defined arbitrary 2x2 unitary gate (matrix) |
control | Qubit index acting as control |
target | Qubit index acting as target |
label | Optional parameter to label the gate U |
Definition at line 424 of file IntelSimulator.cpp.
References gate_count_2qubit, qubitRegister, and ncu_opt_tester::target.
Referenced by applyGateCSwap().
|
inlineinherited |
Apply Controlled Pauli-X (CNOT) on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 264 of file Simulator.hpp.
Apply Controlled Pauli-X (CNOT) on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 442 of file IntelSimulator.cpp.
References gate_count_2qubit, getGateX(), qubitRegister, and ncu_opt_tester::target.
Referenced by applyGateCSwap().
|
inlineinherited |
Apply Controlled Pauli-Y on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 274 of file Simulator.hpp.
Apply Controlled Pauli-Y on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 460 of file IntelSimulator.cpp.
References gate_count_2qubit, getGateY(), qubitRegister, and ncu_opt_tester::target.
|
inlineinherited |
Apply Controlled Pauli-Z on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 284 of file Simulator.hpp.
Apply Controlled Pauli-Z on target qubit.
control | Qubit index acting as control |
target | Qubit index acting as target |
Definition at line 478 of file IntelSimulator.cpp.
References gate_count_2qubit, getGateZ(), qubitRegister, and ncu_opt_tester::target.
|
inlineinherited |
Apply the Hadamard gate to the given qubit.
qubit_idx |
Definition at line 155 of file Simulator.hpp.
|
inline |
Apply the Hadamard gate to the given qubit.
qubitIndex |
Definition at line 287 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateH(), and qubitRegister.
|
inline |
Apply the Identity gate to the given qubit.
qubitIndex |
Definition at line 138 of file IntelSimulator.cpp.
References applyGateU(), gate_count_1qubit, and getGateI().
|
inlineinherited |
Apply n-control unitary gate to the given qubit target.
Mat2x2Type | 2x2 Matrix type of unitary gate in the format expected by the derived simulator object; decltype(simulator.getGateX()) can be used in template |
U | 2x2 unitary matrix |
ctrlIndices | Vector of the control lines for NCU operation |
target | Target qubit index to apply nCU |
label | Gate label string (U, X, Y, etc.) |
Definition at line 462 of file Simulator.hpp.
|
inlineinherited |
Apply n-control sigma_x gate to the given qubit target, using auxiliary qubits for 5CX optimisation.
Mat2x2Type | 2x2 Matrix type of unitary gate in the format expected by the derived simulator object; decltype(simulator.getGateX()) can be used in template |
U | 2x2 unitary matrix |
minIdx | Lowest index of the control lines expected for nCU |
maxIdx | Highest index of the control lines expected for the nCU |
target | Target qubit index to apply nCU |
Definition at line 480 of file Simulator.hpp.
|
inline |
Apply phase shift to given Qubit; [[1 0] [0 exp(i*angle)]].
qubit_idx | Qubit index to perform phase shift upon |
angle | Angle of phase shift in rads |
Definition at line 156 of file IntelSimulator.cpp.
References applyGateU(), gate_count_1qubit, and gates.
|
inlineinherited |
Apply phase shift to given Qubit; [[1 0] [0 exp(i*angle)]].
angle | Angle of phase shift in rads |
qubit_idx | Qubit index to perform phase shift upon |
Definition at line 324 of file Simulator.hpp.
|
inlineinherited |
Apply the given Rotation about X-axis to the given qubit.
qubit_idx | Index of qubit to rotate about X-axis |
angle_rad | Rotation angle |
Definition at line 172 of file Simulator.hpp.
|
inline |
Apply the given Rotation about X-axis to the given qubit.
qubitIndex | Index of qubit to rotate about X-axis |
angle | Rotation angle |
Definition at line 326 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateI(), and qubitRegister.
|
inlineinherited |
Apply the given Rotation about Y-axis to the given qubit.
qubit_idx | Index of qubit to rotate about Y-axis |
angle_rad | Rotation angle |
Definition at line 181 of file Simulator.hpp.
|
inline |
Apply the given Rotation about Y-axis to the given qubit.
qubitIndex | Index of qubit to rotate about X-axis |
angle | Rotation angle |
Definition at line 348 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateI(), and qubitRegister.
|
inlineinherited |
Apply the given Rotation about Z-axis to the given qubit.
qubit_idx | Index of qubit to rotate about Z-axis |
angle_rad | Rotation angle |
Definition at line 190 of file Simulator.hpp.
|
inline |
Apply the given Rotation about Z-axis to the given qubit.
qubitIndex | Index of qubit to rotate about X-axis |
angle | Rotation angle |
Definition at line 370 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateI(), and qubitRegister.
|
inline |
Performs Sqrt SWAP gate between two given qubits (half way SWAP)
qubit_idx0 | Qubit index 0 |
qubit_idx1 | Qubit index 1 |
Definition at line 180 of file IntelSimulator.cpp.
|
inlineinherited |
Apply the Sqrt{Pauli X} gate to the given qubit.
qubit_idx |
Definition at line 163 of file Simulator.hpp.
|
inline |
Apply the Sqrt{Pauli X} gate to the given qubit.
qubit_idx |
Definition at line 304 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateX(), QNLP::SimulatorGeneral< IntelSimulator >::matrixSqrt(), and qubitRegister.
|
inlineinherited |
Swap the qubits at the given indices.
qubit_idx0 | Index of qubit 0 to swap &(0 -> 1) |
qubit_idx1 | Index of qubit 1 to swap &(1 -> 0) |
Definition at line 304 of file Simulator.hpp.
Swap the qubits at the given indices.
qubit_idx0 | Index of qubit 0 to swap &(0 -> 1) |
qubit_idx1 | Index of qubit 1 to swap &(1 -> 0) |
Definition at line 593 of file IntelSimulator.cpp.
References getGateI(), and qubitRegister.
|
inline |
Apply arbitrary user-defined unitary gate to qubit at qubit_idx.
U | User-defined unitary 2x2 matrix of templated type Mat2x2Type |
qubitIndex | Index of qubit to apply gate upon |
label | Label for the gate U |
Definition at line 121 of file IntelSimulator.cpp.
References gate_count_1qubit, and qubitRegister.
Referenced by applyGateI(), and applyGatePhaseShift().
|
inlineinherited |
Apply arbitrary user-defined unitary gate to qubit at qubit_idx.
U | User-defined unitary 2x2 matrix of templated type Mat2x2Type |
qubit_idx | Index of qubit to apply gate upon |
Definition at line 201 of file Simulator.hpp.
|
inlineinherited |
Apply the Pauli X gate to the given qubit.
qubit_idx |
Definition at line 123 of file Simulator.hpp.
|
inline |
Apply the Pauli X gate to the given qubit.
qubitIndex |
Definition at line 236 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateX(), and qubitRegister.
|
inlineinherited |
Apply the Pauli Y gate to the given qubit.
qubit_idx |
Definition at line 131 of file Simulator.hpp.
|
inline |
Apply the Pauli Y gate to the given qubit.
qubitIndex |
Definition at line 253 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateY(), and qubitRegister.
|
inlineinherited |
Apply the Pauli Z gate to the given qubit.
qubit_idx |
Definition at line 139 of file Simulator.hpp.
|
inline |
Apply the Pauli Z gate to the given qubit.
qubitIndex |
Definition at line 270 of file IntelSimulator.cpp.
References gate_count_1qubit, getGateZ(), and qubitRegister.
|
inlineinherited |
Computes the relative Hamming distance between the test pattern and the pattern stored in each state of the superposition, overwriting the aux register pattern with the resulting bit differences.
test_pattern | The binary pattern used as the the basis for the Hamming Distance. |
reg_mem | Vector containing the indices of the register qubits that contain the training patterns. |
reg_auxiliary | Vector containing the indices of the register qubits which the first len_bin_pattern qubits will store the test_pattern. |
Definition at line 609 of file Simulator.hpp.
|
inlineinherited |
Computes the relative Hamming distance between the test pattern and the pattern stored in each state of the superposition, storing the result in the amplitude of the corresponding state.
test_pattern | The binary pattern used as the the basis for the Hamming Distance. |
reg_mem | Vector containing the indices of the register qubits that contain the training patterns. |
reg_auxiliary | Vector containing the indices of the register qubits which the first len_bin_pattern qubits will store the test_pattern. |
len_bin_pattern | Length of the binary patterns |
Definition at line 584 of file Simulator.hpp.
|
inlineinherited |
Apply the inverse Quantum Fourier transform (IQFT) to the given register index range.
minIdx | Lowest qubit index of the IQFT range |
maxIdx | Highest qubit index of the IQFT range |
Definition at line 433 of file Simulator.hpp.
|
inlineinherited |
Apply measurement to a target qubit, randomly collapsing the qubit proportional to the amplitude and returns the collapsed value.
target | The index of the qubit being collapsed |
normalize | Optional argument specifying whether amplitudes shoud be normalized (true) or not (false). Default value is true. |
Definition at line 629 of file Simulator.hpp.
|
inline |
Apply measurement to a target qubit, randomly collapsing the qubit proportional to the amplitude and returns the collapsed value. If built with MPI enabled, this member function collpases the corresponding qubit in each state across all processes.
target | The index of the qubit being collapsed |
normalize | Optional argument specifying whether amplitudes should be normalized (true) or not (false). Default value is true. |
Definition at line 653 of file IntelSimulator.cpp.
References applyAmplitudeNorm(), collapseQubit(), dist, getStateProbability(), mt, ncu_opt_tester::rank, and ncu_opt_tester::target.
|
inlineinherited |
Apply measurement to a set of target qubits, randomly collapsing the qubits proportional to the amplitude and returns the bit string of the qubits in the order they are represented in the vector of indexes, in the form of an unsigned integer.
target_qubits | Vector of indices of qubits being collapsed |
normalize | Optional argument specifying whether amplitudes shoud be normalized (true) or not (false). Default value is true. |
Definition at line 640 of file Simulator.hpp.
|
inlineinherited |
Apply oracle to match given binary index with linearly adjacent controls.
bit_pattern | Oracle pattern in binary |
ctrlIndices | Control lines for oracle |
target | Target qubit index to apply Z gate upon |
Definition at line 524 of file Simulator.hpp.
|
inlineinherited |
Apply oracle to match given binary index with non adjacent controls.
bit_pattern | Oracle state pattern (bitstring: 0-> |0>, 1-> |1>) |
U | 2x2 unitary matrix to apply |
ctrlIndices | Control indices for operation |
target | Target qubit index to apply U on |
gateLabel | Label used to access required cached matrix for NCU |
Definition at line 498 of file Simulator.hpp.
|
inlineinherited |
Apply oracle to match given binary index with non adjacent controls.
bit_pattern | Oracle state pattern (bitstring: 0-> |0>, 1-> |1>) |
U | 2x2 unitary matrix to apply |
ctrlIndices | Control indices for operation |
auxIndices | Auxiliary indices for operation |
target | Target qubit index to apply U on |
gateLabel | Label used to access required cached matrix for NCU |
Definition at line 513 of file Simulator.hpp.
|
inlineinherited |
Apply the forward Quantum Fourier transform (QFT) to the given register index range.
Definition at line 423 of file Simulator.hpp.
|
inlineprivate |
Collapses specified qubit in register to the collapseValue without applying normalization.
target | Index of qubit to be collapsed |
collapseValue | Value qubit is collapsed to (0 or 1) |
Definition at line 758 of file IntelSimulator.cpp.
References qubitRegister, and ncu_opt_tester::target.
Referenced by applyMeasurement(), and collapseToBasisZ().
|
inlineinherited |
Apply measurement to a target qubit with respect to the Z-basis, collapsing to a specified value (0 or 1). Amplitudes are r-normalized afterwards.
target | The index of the qubit being collapsed |
collapseValue | The value that the register will be collapsed to (either 0 ro 1). |
Definition at line 671 of file Simulator.hpp.
|
inline |
Apply measurement to a target qubit with respect to the Z-basis, collapsing to a specified value (0 or 1). Amplitudes are r-normalized afterwards.
target | The index of the qubit being collapsed |
collapseValue | The value that the register will be collapsed to (either 0 ro 1). |
Definition at line 679 of file IntelSimulator.cpp.
References applyAmplitudeNorm(), collapseQubit(), and ncu_opt_tester::target.
|
inlineinherited |
Encode inputted binary strings to the memory register specified as a superposition of states. Note that this implementation does not allow for multiple instances of the same input pattern but allows for 0 to be encoded.
reg_memory | std::vector of unsigned integers containing the indices of the circuit's memory register |
reg_auxiliary | std::vector of unsigned integers type containing the indices of the circuit's auxiliary register |
bin_patterns | std::vector of unsigned integers representing the binary patterns to encode |
len_bin_pattern | The length of the binary patterns being encoded |
Definition at line 567 of file Simulator.hpp.
|
inlineinherited |
Encodes a defined binary pattern into a defined target register (initially in state |00...0>) of all quantum states in the superposition.
target_pattern | The binary pattern that is to be encoded |
target_register | Vector containing the indices of the register qubits that the pattern is to be encoded into (beginning at least significant digit). Note, the target register is expected to be in the state consisting of all 0's before the encoding. |
Length | of the binary pattern to be encoded |
Definition at line 548 of file Simulator.hpp.
|
inline |
Print 1 and 2 qubit gate call counts.
Definition at line 709 of file IntelSimulator.cpp.
References gate_count_1qubit, and gate_count_2qubit.
|
inline |
Get the Hadamard gate.
Definition at line 414 of file IntelSimulator.cpp.
References gates.
Referenced by applyGateCH(), and applyGateH().
|
inline |
Get the Identity.
Definition at line 408 of file IntelSimulator.cpp.
References gates.
Referenced by applyGateCRotX(), applyGateCRotY(), applyGateCRotZ(), applyGateI(), applyGateRotX(), applyGateRotY(), applyGateRotZ(), and applyGateSwap().
|
inline |
Get the Pauli-X gate.
Definition at line 390 of file IntelSimulator.cpp.
References gates.
Referenced by applyGateCCX(), applyGateCX(), applyGateSqrtX(), and applyGateX().
|
inline |
Get the Pauli-Y gate.
Definition at line 396 of file IntelSimulator.cpp.
References gates.
Referenced by applyGateCY(), and applyGateY().
|
inline |
Get the Pauli-Z gate.
Definition at line 402 of file IntelSimulator.cpp.
References gates.
Referenced by applyGateCZ(), and applyGateZ().
|
inline |
Get the number of Qubits.
Definition at line 623 of file IntelSimulator.cpp.
References numQubits.
Referenced by TEST_CASE().
|
inline |
Get the Qubit Register object.
Definition at line 605 of file IntelSimulator.cpp.
References qubitRegister.
Referenced by TEST_CASE().
|
inline |
Get the Qubit Register object.
Definition at line 614 of file IntelSimulator.cpp.
References qubitRegister.
|
inlineprivate |
Get the probability of the specified qubit being in the state |1>
target | Target qubit |
Definition at line 768 of file IntelSimulator.cpp.
References qubitRegister, and ncu_opt_tester::target.
Referenced by applyMeasurement().
|
inlineinherited |
Group all set qubits to MSB in register (ie |010100> -> |000011>)
reg_mem | The indices of the qubits to perform operation upon |
reg_auxiliary | The auxiliary control qubit register set to |......10> at the beginning, and guaranteed to be set the same at end. |
lsb | Shifts to LSB position in register if true; MSB otherwise. |
Definition at line 656 of file Simulator.hpp.
|
inlineinherited |
Initialise caches used in NCU operation.
Definition at line 687 of file Simulator.hpp.
|
inline |
(Re)Initialise the underlying register of the encapsulated simulator to well-defined state (|0....0>)
Definition at line 631 of file IntelSimulator.cpp.
References gate_count_1qubit, gate_count_2qubit, QNLP::SimulatorGeneral< IntelSimulator >::initCaches(), and qubitRegister.
|
inlineinherited |
Invert the register about the given indides: 0,1,2...n-1,n -> n,n-1,...,1,0.
Definition at line 776 of file Simulator.hpp.
|
inlineinherited |
Calculates the unitary matrix square root (U == VV, where V is returned)
Mat2x2Type | Matrix type |
U | Unitary matrix to be rooted |
Definition at line 729 of file Simulator.hpp.
|
inline |
Compute overlap between different simulators. Number of qubits must be the same.
Definition at line 723 of file IntelSimulator.cpp.
References qubitRegister, and ncu_opt_tester::sim.
|
inline |
Prints the string x and then for each state of the specified qubits in the superposition, prints each its amplitude, followed by state and then by the probability of that state. Note that this state observation method is not a permitted quantum operation, however it is provided for convenience and debugging/testing.
x | String to be printed to stdout |
qubits | Indices of qubits in register to be printed |
Definition at line 690 of file IntelSimulator.cpp.
|
inlineinherited |
Applies |r1>|r2> -> |r1>|r1-r2>
Definition at line 448 of file Simulator.hpp.
|
inlineinherited |
Applies |r1>|r2> -> |r1>|r1+r2>
Definition at line 441 of file Simulator.hpp.
|
private |
Definition at line 748 of file IntelSimulator.cpp.
Referenced by applyMeasurement(), and IntelSimulator().
|
private |
Definition at line 743 of file IntelSimulator.cpp.
Referenced by applyGateH(), applyGateI(), applyGatePhaseShift(), applyGateRotX(), applyGateRotY(), applyGateRotZ(), applyGateSqrtX(), applyGateU(), applyGateX(), applyGateY(), applyGateZ(), getGateCounts(), initRegister(), and IntelSimulator().
|
private |
Definition at line 744 of file IntelSimulator.cpp.
Referenced by applyGateCH(), applyGateCPhaseShift(), applyGateCRotX(), applyGateCRotY(), applyGateCRotZ(), applyGateCU(), applyGateCX(), applyGateCY(), applyGateCZ(), getGateCounts(), initRegister(), and IntelSimulator().
|
private |
Definition at line 738 of file IntelSimulator.cpp.
Referenced by applyGateCPhaseShift(), applyGatePhaseShift(), getGateH(), getGateI(), getGateX(), getGateY(), getGateZ(), and IntelSimulator().
|
private |
Definition at line 747 of file IntelSimulator.cpp.
Referenced by applyMeasurement(), and IntelSimulator().
|
private |
Definition at line 736 of file IntelSimulator.cpp.
Referenced by getNumQubits().
|
private |
Definition at line 737 of file IntelSimulator.cpp.
Referenced by applyAmplitudeNorm(), applyGateCH(), applyGateCPhaseShift(), applyGateCRotX(), applyGateCRotY(), applyGateCRotZ(), applyGateCU(), applyGateCX(), applyGateCY(), applyGateCZ(), applyGateH(), applyGateRotX(), applyGateRotY(), applyGateRotZ(), applyGateSqrtX(), applyGateSwap(), applyGateU(), applyGateX(), applyGateY(), applyGateZ(), collapseQubit(), getQubitRegister(), getStateProbability(), initRegister(), IntelSimulator(), and overlap().
|
private |
Definition at line 746 of file IntelSimulator.cpp.
Referenced by IntelSimulator().
|
protectedinherited |
Definition at line 104 of file Simulator.hpp.
|
private |
Definition at line 734 of file IntelSimulator.cpp.