QNLP
v1.0
|
Class definition for applying n-qubit controlled unitary operations. More...
#include <ncu.hpp>
Data Structures | |
struct | OptParamsCX |
For the 5+ controlled NCX decomposition routines defined within https://arxiv.org/pdf/quant-ph/9503016.pdf. More... | |
Public Member Functions | |
NCU () | |
Construct a new NCU object. More... | |
NCU (SimulatorType &qSim) | |
Construct a new NCU object. More... | |
~NCU () | |
Destroy the NCU object. More... | |
void | initialiseMaps (SimulatorType &qSim, std::size_t num_ctrl_lines) |
Add the PauliX and the given unitary U to the maps. More... | |
void | addToMaps (SimulatorType &qSim, std::string U_label, const Mat2x2Type &U, std::size_t num_ctrl_lines) |
Add the given unitary matrix to the maps up to the required depth. More... | |
GateCache< SimulatorType > & | getGateCache () |
Get the Map of cached gates. Keys are strings, and values are vectors of paired (gate, gate adjoint) types where the index give the value of (gate)^(1/2^i) More... | |
void | clearMaps () |
Clears the maps of stored sqrt matrices. More... | |
void | applyNQubitControl (SimulatorType &qSim, const std::vector< std::size_t > ctrlIndices, const std::vector< std::size_t > auxIndices, const unsigned int qTarget, const std::string gateLabel, const Mat2x2Type &U, const std::size_t depth) |
Decompose n-qubit controlled op into 1 and 2 qubit gates. Control indices can be in any specified location. Ensure the gate cache has been populated with the appropriate gate type before running. This avoids O(n) checking of the container at each call for the associated gates. More... | |
std::size_t | get_op_calls (std::size_t num_ctrl_lines) |
Returns the number of 2-qubit operations a non optimised decomposition will make. Cache intermediate results. More... | |
std::size_t | get_ops_for_params (std::size_t l, std::size_t m) |
Helper method to get optimised number of 2-gate ops for given decomposition params. More... | |
OptParamsCX | find_optimal_params (std::size_t num_ctrl_lines) |
Returns the number of 2-qubit operations an optimised decomposition will make for nCX. Caches intermediate results. More... | |
Protected Types | |
using | Mat2x2Type = decltype(std::declval< SimulatorType >().getGateX()) |
Static Protected Attributes | |
static std::size_t | num_gate_ops |
Private Attributes | |
std::unordered_set< std::string > | default_gates |
std::unordered_map< std::size_t, std::size_t > | op_call_counts_CX |
std::unordered_map< std::size_t, OptParamsCX > | opt_op_call_params_CX |
GateCache< SimulatorType > | gate_cache |
Class definition for applying n-qubit controlled unitary operations.
SimulatorType | Class Simulator Type |
|
protected |
Construct a new NCU object.
Definition at line 64 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::op_call_counts_CX.
Construct a new NCU object.
qSim | Instance of quantum simulator |
Definition at line 77 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::gate_cache.
Destroy the NCU object.
Definition at line 85 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::clearMaps(), and QNLP::NCU< SimulatorType >::gate_cache.
|
inline |
Add the given unitary matrix to the maps up to the required depth.
U |
Definition at line 104 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::gate_cache.
|
inline |
Decompose n-qubit controlled op into 1 and 2 qubit gates. Control indices can be in any specified location. Ensure the gate cache has been populated with the appropriate gate type before running. This avoids O(n) checking of the container at each call for the associated gates.
Type | ComplexDP or ComplexSP |
qReg | Qubit register |
ctrlIndices | Vector of indices for control lines |
qTarget | Target qubit for the unitary matrix U |
U | Unitary matrix, U |
depth | Depth of recursion. |
Definition at line 136 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::gate_cache.
|
inline |
Clears the maps of stored sqrt matrices.
Definition at line 121 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::gate_cache.
Referenced by QNLP::NCU< SimulatorType >::~NCU().
|
inline |
Returns the number of 2-qubit operations an optimised decomposition will make for nCX. Caches intermediate results.
num_ctrl_lines | The number of control lines in the nCX call |
Definition at line 286 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::get_ops_for_params(), QNLP::NCU< SimulatorType >::OptParamsCX::l, QNLP::NCU< SimulatorType >::OptParamsCX::m, QNLP::NCU< SimulatorType >::OptParamsCX::num_ops, QNLP::NCU< SimulatorType >::op_call_counts_CX, and QNLP::NCU< SimulatorType >::opt_op_call_params_CX.
|
inline |
Returns the number of 2-qubit operations a non optimised decomposition will make. Cache intermediate results.
Definition at line 247 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::op_call_counts_CX.
Referenced by QNLP::NCU< SimulatorType >::get_ops_for_params().
|
inline |
Helper method to get optimised number of 2-gate ops for given decomposition params.
l | multi-control gate partition 2, l = n-m-1 |
m | multi-control gate partition 1, m \in {2,...,n-3} |
Definition at line 275 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::get_op_calls().
Referenced by QNLP::NCU< SimulatorType >::find_optimal_params().
|
inline |
Get the Map of cached gates. Keys are strings, and values are vectors of paired (gate, gate adjoint) types where the index give the value of (gate)^(1/2^i)
Definition at line 113 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::gate_cache.
|
inline |
Add the PauliX and the given unitary U to the maps.
U |
Definition at line 95 of file ncu.hpp.
References QNLP::NCU< SimulatorType >::gate_cache.
|
private |
|
private |
Definition at line 51 of file ncu.hpp.
Referenced by QNLP::NCU< SimulatorType >::addToMaps(), QNLP::NCU< SimulatorType >::applyNQubitControl(), QNLP::NCU< SimulatorType >::clearMaps(), QNLP::NCU< SimulatorType >::getGateCache(), QNLP::NCU< SimulatorType >::initialiseMaps(), QNLP::NCU< SimulatorType >::NCU(), and QNLP::NCU< SimulatorType >::~NCU().
|
staticprotected |
|
private |
Definition at line 47 of file ncu.hpp.
Referenced by QNLP::NCU< SimulatorType >::find_optimal_params(), QNLP::NCU< SimulatorType >::get_op_calls(), and QNLP::NCU< SimulatorType >::NCU().
|
private |
Definition at line 48 of file ncu.hpp.
Referenced by QNLP::NCU< SimulatorType >::find_optimal_params().