Quantum Gate Decomposer
v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
|
A class to determine the decomposition of a unitary into a sequence of CNOT and U3 operations. More...
#include <N_Qubit_Decomposition.h>
Public Member Functions | |
void | add_cnot_to_end (int control_qbit, int target_qbit) |
Append a C_NOT gate operation to the list of operations. More... | |
void | add_cnot_to_front (int control_qbit, int target_qbit) |
Add a C_NOT gate operation to the front of the list of operations. More... | |
void | add_operation_to_end (Operation *operation) |
Append a general operation to the list of operations. More... | |
void | add_operation_to_front (Operation *operation) |
Add an operation to the front of the list of operations. More... | |
void | add_operations_to_end (std::vector< Operation * > operations_in) |
Append a list of operations to the list of operations. More... | |
void | add_operations_to_front (std::vector< Operation * > operations_in) |
Add an array of operations to the front of the list of operations. More... | |
void | add_u3_to_end (int target_qbit, bool Theta, bool Phi, bool Lambda) |
Append a U3 gate to the list of operations. More... | |
void | add_u3_to_front (int target_qbit, bool Theta, bool Phi, bool Lambda) |
Add a U3 gate to the front of the list of operations. More... | |
Matrix | apply_operation (Matrix &operation_mtx, Matrix &input_matrix) |
Apply an operations on the input matrix. More... | |
bool | check_optimization_solution () |
check_optimization_solution More... | |
N_Qubit_Decomposition * | clone () |
Create a clone of the present class. More... | |
void | combine (Operation_block *op_block) |
Call to append the operations of an operation block to the current block. More... | |
void | decompose_submatrix () |
Start the decompostion process to recursively decompose the submatrices. More... | |
int | extract_operations (Operation_block *op_block) |
Call to extract the operations stored in the class. More... | |
void | extract_subdecomposition_results (Sub_Matrix_Decomposition *cSub_decomposition) |
Call to extract and store the calculated parameters and operations of the sub-decomposition processes. More... | |
void | final_optimization () |
final optimization procedure improving the accuracy of the decompositin when all the qubits were already disentangled. More... | |
void | finalize_decomposition () |
After the main optimization problem is solved, the indepent qubits can be rotated into state |0> by this def. More... | |
int | get_control_qbit () |
Call to get the index of the control qubit. More... | |
Matrix | get_decomposed_matrix () |
Calculate the decomposed matrix resulted by the effect of the optimized operations on the unitary Umtx. More... | |
double | get_decomposition_error () |
Call to get the error of the decomposition. More... | |
Matrix | get_finalizing_operations (Matrix &mtx, Operation_block *finalizing_operations, double *finalizing_parameters) |
This method determine the operations needed to rotate the indepent qubits into the state |0> More... | |
gates_num | get_gate_nums () |
Call to get the number of the individual gate types in the list of operations. More... | |
std::vector< int > | get_involved_qubits () |
Call to get the qubits involved in the operations stored in the block of operations. More... | |
std::vector< Matrix > | get_matrices (const double *parameters) |
Call to get the list of matrix representation of the operations grouped in the block. More... | |
Matrix | get_matrix (const double *parameters) |
Call to retrieve the operation matrix (Which is the product of all the operation matrices stored in the operation block) More... | |
Matrix | get_matrix () |
Call to retrieve the operation matrix. More... | |
int | get_operation (unsigned int n, operation_type &type, int &target_qbit, int &control_qbit, double *parameters) |
Call to prepare the optimized operations to export. More... | |
int | get_operation_num () |
Call to get the number of operations grouped in the class. More... | |
std::vector< Matrix, tbb::cache_aligned_allocator< Matrix > > | get_operation_products (double *parameters, std::vector< Operation * >::iterator operations_it, int num_of_operations) |
Calculate the list of gate operation matrices such that the i>0-th element in the result list is the product of the operations of all 0<=n<i operations from the input list and the 0th element in the result list is the identity. More... | |
std::vector< Operation * > | get_operations () |
Call to get the operations stored in the class. More... | |
double * | get_optimized_parameters () |
Call to get the optimized parameters. More... | |
void | get_optimized_parameters (double *ret) |
Call to get the optimized parameters. More... | |
int | get_parameter_num () |
Call to get the number of free parameters. More... | |
int | get_qbit_num () |
Call to get the number of qubits composing the unitary. More... | |
int | get_target_qbit () |
Call to get the index of the target qubit. More... | |
Matrix | get_transformed_matrix (const double *parameters, std::vector< Operation * >::iterator operations_it, int num_of_operations) |
Calculate the transformed matrix resulting by an array of operations on the matrix Umtx. More... | |
Matrix | get_transformed_matrix (const double *parameters, std::vector< Operation * >::iterator operations_it, int num_of_operations, Matrix &initial_matrix) |
Calculate the transformed matrix resulting by an array of operations on a given initial matrix. More... | |
operation_type | get_type () |
Call to get the type of the operation. More... | |
Matrix | get_Umtx () |
Call to retrive a pointer to the unitary to be transformed. More... | |
int | get_Umtx_size () |
Call to get the size of the unitary to be transformed. More... | |
void | list_operations (int start_index) |
Call to print the operations decomposing the initial unitary. More... | |
void | list_operations (const double *parameters, int start_index) |
Call to print the list of operations stored in the block of operations for a specific set of parameters. More... | |
N_Qubit_Decomposition (Matrix Umtx_in, int qbit_num_in, bool optimize_layer_num_in, guess_type initial_guess_in) | |
Constructor of the class. More... | |
double | optimization_problem (const double *parameters) |
The optimization problem of the final optimization. More... | |
void | prepare_operations_to_export () |
Call to prepare the optimized operations to export. More... | |
std::vector< Operation * > | prepare_operations_to_export (std::vector< Operation * > ops, const double *parameters) |
Call to prepare the optimized operations to export. More... | |
std::vector< Operation * > | prepare_operations_to_export (Operation_block *block_op, const double *parameters) |
Call to prepare the operations of an operation block to export. More... | |
void | release_operations () |
Call to release the stored operations. More... | |
void | reorder_qubits (std::vector< int > qbit_list) |
Call to reorder the qubits in the matrix of the operation. More... | |
int | set_identical_blocks (int n, int identical_blocks_in) |
Set the number of identical successive blocks during the subdecomposition of the n-th qubit. More... | |
int | set_identical_blocks (std::map< int, int > identical_blocks_in) |
Set the number of identical successive blocks during the subdecomposition of the n-th qubit. More... | |
int | set_iteration_loops (int n, int iteration_loops_in) |
Set the number of iteration loops during the subdecomposition of the n-th qubit. More... | |
int | set_iteration_loops (std::map< int, int > iteration_loops_in) |
Set the number of iteration loops during the subdecomposition of the qbit-th qubit. More... | |
void | set_matrix (Matrix input) |
Call to set the stored matrix in the operation. More... | |
void | set_max_iteration (int max_iterations_in) |
Call to set the maximal number of the iterations in the optimization process. More... | |
int | set_max_layer_num (int n, int max_layer_num_in) |
Set the maximal number of layers used in the subdecomposition of the n-th qubit. More... | |
int | set_max_layer_num (std::map< int, int > max_layer_num_in) |
Set the maximal number of layers used in the subdecomposition of the n-th qubit. More... | |
void | set_optimization_blocks (int optimization_block_in) |
Call to set the number of operation blocks to be optimized in one shot. More... | |
void | set_qbit_num (int qbit_num_in) |
Set the number of qubits spanning the matrix of the operations stored in the block of operations. More... | |
void | set_verbose (bool verbose_in) |
Call to set the verbose attribute to true or false. More... | |
int | simplify_layer (Operation_block *layer, double *parameters, unsigned int parameter_num_block, std::map< int, int > max_layer_num_loc, Operation_block *&simplified_layer, double *&simplified_parameters, unsigned int &simplified_parameter_num) |
Call to simplify the gate structure in a block of operations (i.e. More... | |
void | simplify_layers () |
Call to simplify the gate structure in the layers if possible (i.e. More... | |
void | solve_layer_optimization_problem (int num_of_parameters, gsl_vector *solution_guess_gsl) |
Call to solve layer by layer the optimization problem. More... | |
void | solve_optimization_problem (double *solution_guess, int solution_guess_num) |
This method can be used to solve the main optimization problem which is devidid into sub-layer optimization processes. More... | |
void | start_decomposition (bool finalize_decomp, bool prepare_export) |
Start the disentanglig process of the unitary. More... | |
~N_Qubit_Decomposition () | |
Destructor of the class. More... | |
Static Public Member Functions | |
static void | Init_max_layer_num () |
Initializes default layer numbers. More... | |
static double | optimization_problem (const gsl_vector *parameters, void *void_instance) |
The optimization problem of the final optimization. More... | |
static void | optimization_problem_combined (const gsl_vector *parameters, void *void_instance, double *f0, gsl_vector *grad) |
Call to calculate both the cost function and the its gradient components. More... | |
static void | optimization_problem_grad (const gsl_vector *parameters, void *void_instance, gsl_vector *grad) |
Calculate the approximate derivative (f-f0)/(x-x0) of the cost function with respect to the free parameters. More... | |
Public Attributes | |
int | optimization_block |
number of operation blocks used in one shot of the optimization process More... | |
double | optimization_tolerance |
The maximal allowed error of the optimization problem. More... | |
bool | verbose |
Logical variable. Set true for verbose mode, or to false to suppress output messages. More... | |
Static Public Attributes | |
static std::map< int, int > | max_layer_num_def |
A map of <int n: int num> indicating that how many layers should be used in the subdecomposition process by default for the subdecomposing of the nth qubits. More... | |
Protected Attributes | |
int | control_qbit |
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations. More... | |
double | current_minimum |
The current minimum of the optimization problem. More... | |
double | decomposition_error |
error of the unitarity of the final decomposition More... | |
bool | decomposition_finalized |
logical value describing whether the decomposition was finalized or not (i.e. whether the decomposed qubits were rotated into the state |0> or not) More... | |
int | finalizing_operations_num |
number of finalizing (deterministic) opertaions rotating the disentangled qubits into state |0>. More... | |
int | finalizing_parameter_num |
the number of the finalizing (deterministic) parameters of operations rotating the disentangled qubits into state |0>. More... | |
double | global_target_minimum |
The global target minimum of the optimization problem. More... | |
std::map< int, int > | identical_blocks |
A map of <int n: int num> indicating that how many identical succesive blocks should be used in the disentanglement of the nth qubit from the others. More... | |
guess_type | initial_guess |
type to guess the initial values for the optimization. Possible values: ZEROS=0, RANDOM=1, CLOSE_TO_ZERO=2 More... | |
std::map< int, int > | iteration_loops |
A map of <int n: int num> indicating the number of iteration in each step of the decomposition. More... | |
int | layer_num |
number of operation layers More... | |
int | matrix_size |
The size N of the NxN matrix associated with the operations. More... | |
int | max_iterations |
Maximal number of iterations allowed in the optimization process. More... | |
std::map< int, int > | max_layer_num |
A map of <int n: int num> indicating that how many layers should be used in the subdecomposition process for the subdecomposing of the nth qubits. More... | |
int | num_threads |
Number of outer OpenMP threads. (During the calculations OpenMP multithreading is turned off.) More... | |
std::vector< Operation * > | operations |
The list of stored operations. More... | |
bool | optimization_problem_solved |
logical value describing whether the optimization problem was solved or not More... | |
bool | optimize_layer_num |
logical value. Set true to optimize the minimum number of operation layers required in the decomposition, or false when the predefined maximal number of layer gates is used (ideal for general unitaries). More... | |
double * | optimized_parameters |
The optimized parameters for the operations. More... | |
unsigned int | parameter_num |
the number of free parameters of the operation More... | |
int | qbit_num |
number of qubits spanning the matrix of the operation More... | |
int | target_qbit |
The index of the qubit on which the operation acts (target_qbit >= 0) More... | |
operation_type | type |
The type of the operation (see enumeration operation_type) More... | |
Matrix | Umtx |
The unitary to be decomposed. More... | |
A class to determine the decomposition of a unitary into a sequence of CNOT and U3 operations.
Definition at line 36 of file N_Qubit_Decomposition.h.
N_Qubit_Decomposition::N_Qubit_Decomposition | ( | Matrix | Umtx_in, |
int | qbit_num_in, | ||
bool | optimize_layer_num_in, | ||
guess_type | initial_guess_in = CLOSE_TO_ZERO |
||
) |
Constructor of the class.
Umtx_in | The unitary matrix to be decomposed |
qbit_num_in | The number of qubits spanning the unitary Umtx |
optimize_layer_num_in | Optional logical value. If true, then the optimization tries to determine the lowest number of the layers needed for the decomposition. If False (default), the optimization is performed for the maximal number of layers. |
initial_guess_in | Enumeration element indicating the method to guess initial values for the optimization. Possible values: 'zeros=0' ,'random=1', 'close_to_zero=2' |
Definition at line 35 of file N_Qubit_Decomposition.cpp.
N_Qubit_Decomposition::~N_Qubit_Decomposition | ( | ) |
Destructor of the class.
Definition at line 64 of file N_Qubit_Decomposition.cpp.
|
inherited |
Append a C_NOT gate operation to the list of operations.
control_qbit | The identification number of the control qubit. (0 <= target_qbit <= qbit_num-1) |
target_qbit | The identification number of the target qubit. (0 <= target_qbit <= qbit_num-1) |
Definition at line 264 of file Operation_block (copy).cpp.
|
inherited |
Add a C_NOT gate operation to the front of the list of operations.
control_qbit | The identification number of the control qubit. (0 <= target_qbit <= qbit_num-1) |
target_qbit | The identification number of the target qubit. (0 <= target_qbit <= qbit_num-1) |
Definition at line 281 of file Operation_block (copy).cpp.
|
inherited |
Append a general operation to the list of operations.
operation | A pointer to a class Operation describing an operation. |
Definition at line 322 of file Operation_block (copy).cpp.
|
inherited |
Add an operation to the front of the list of operations.
operation | A pointer to a class Operation describing an operation. |
Definition at line 345 of file Operation_block (copy).cpp.
|
inherited |
Append a list of operations to the list of operations.
operations_in | A list of operation class instances. |
Definition at line 295 of file Operation_block (copy).cpp.
|
inherited |
Add an array of operations to the front of the list of operations.
operations_in | A list of operation class instances. |
Definition at line 308 of file Operation_block (copy).cpp.
|
inherited |
Append a U3 gate to the list of operations.
target_qbit | The identification number of the targt qubit. (0 <= target_qbit <= qbit_num-1) |
Theta | The Theta parameter of the U3 operation |
Phi | The Phi parameter of the U3 operation |
Lambda | The Lambda parameter of the U3 operation |
Definition at line 233 of file Operation_block (copy).cpp.
|
inherited |
Add a U3 gate to the front of the list of operations.
target_qbit | The identification number of the targt qubit. (0 <= target_qbit <= qbit_num-1) |
Theta | The Theta parameter of the U3 operation |
Phi | The Phi parameter of the U3 operation |
Lambda | The Lambda parameter of the U3 operation |
Definition at line 249 of file Operation_block (copy).cpp.
|
inherited |
Apply an operations on the input matrix.
operation_mtx | The matrix of the operation. |
input_matrix | The input matrix to be transformed. |
Definition at line 711 of file Decomposition_Base.cpp.
|
inherited |
check_optimization_solution
Checks the convergence of the optimization problem.
Definition at line 568 of file Decomposition_Base.cpp.
N_Qubit_Decomposition * N_Qubit_Decomposition::clone | ( | ) |
Create a clone of the present class.
Definition at line 885 of file N_Qubit_Decomposition.cpp.
|
inherited |
Call to append the operations of an operation block to the current block.
op_block | A pointer to an instance of class Operation_block |
Definition at line 593 of file Operation_block (copy).cpp.
void N_Qubit_Decomposition::decompose_submatrix | ( | ) |
Start the decompostion process to recursively decompose the submatrices.
Definition at line 248 of file N_Qubit_Decomposition.cpp.
|
inherited |
Call to extract the operations stored in the class.
op_block | An instance of Operation_block class in which the operations will be stored. (The current operations will be erased) |
Definition at line 686 of file Operation_block (copy).cpp.
void N_Qubit_Decomposition::extract_subdecomposition_results | ( | Sub_Matrix_Decomposition * | cSub_decomposition | ) |
Call to extract and store the calculated parameters and operations of the sub-decomposition processes.
cSub_decomposition | An instance of class Sub_Matrix_Decomposition used to disentangle the n-th qubit from the others. |
Definition at line 187 of file N_Qubit_Decomposition.cpp.
void N_Qubit_Decomposition::final_optimization | ( | ) |
final optimization procedure improving the accuracy of the decompositin when all the qubits were already disentangled.
Definition at line 352 of file N_Qubit_Decomposition.cpp.
|
inherited |
After the main optimization problem is solved, the indepent qubits can be rotated into state |0> by this def.
The constructed operations are added to the array of operations needed to the decomposition of the input unitary.
Definition at line 132 of file Decomposition_Base.cpp.
|
inherited |
Call to get the index of the control qubit.
Definition at line 157 of file Operation.cpp.
|
inherited |
Calculate the decomposed matrix resulted by the effect of the optimized operations on the unitary Umtx.
Definition at line 699 of file Decomposition_Base.cpp.
|
inherited |
Call to get the error of the decomposition.
Definition at line 1059 of file Decomposition_Base.cpp.
|
inherited |
This method determine the operations needed to rotate the indepent qubits into the state |0>
mtx | The unitary describing indepent qubits. The resulting matrix is returned by this pointer |
finalizing_operations | Pointer pointig to a block of operations containing the final operations. |
finalizing_parameters | Parameters corresponding to the finalizing operations. |
Definition at line 203 of file Decomposition_Base.cpp.
|
inherited |
Call to get the number of the individual gate types in the list of operations.
Definition at line 369 of file Operation_block (copy).cpp.
|
inherited |
Call to get the qubits involved in the operations stored in the block of operations.
Definition at line 552 of file Operation_block (copy).cpp.
|
inherited |
Call to get the list of matrix representation of the operations grouped in the block.
parameters | Array of parameters to calculate the matrix of the operation block |
Definition at line 174 of file Operation_block (copy).cpp.
|
inherited |
Call to retrieve the operation matrix (Which is the product of all the operation matrices stored in the operation block)
parameters | An array pointing to the parameters of the operations |
Definition at line 106 of file Operation_block (copy).cpp.
|
inherited |
Call to retrieve the operation matrix.
Definition at line 97 of file Operation.cpp.
|
inherited |
Call to prepare the optimized operations to export.
n | Integer labeling the n-th oepration (n>=0). |
type | The type of the operation from enumeration operation_type is returned via this parameter. |
target_qbit | The ID of the target qubit is returned via this input parameter. |
control_qbit | The ID of the control qubit is returned via this input parameter. |
parameters | The parameters of the operations |
Definition at line 1009 of file Decomposition_Base.cpp.
|
inherited |
Call to get the number of operations grouped in the class.
Definition at line 418 of file Operation_block (copy).cpp.
|
inherited |
Calculate the list of gate operation matrices such that the i>0-th element in the result list is the product of the operations of all 0<=n<i operations from the input list and the 0th element in the result list is the identity.
parameters | An array containing the parameters of the U3 operations. |
operations_it | An iterator pointing to the forst operation. |
num_of_operations | The number of operations involved in the calculations |
parameters | An array containing the parameters of the operations. |
operations_it | An iterator pointing to the first operation. |
num_of_operations | The number of operations involved in the calculations |
Definition at line 35 of file Functor_Get_Operation_Products.cpp.
|
inherited |
Call to get the operations stored in the class.
Definition at line 584 of file Operation_block (copy).cpp.
|
inherited |
Call to get the optimized parameters.
Definition at line 596 of file Decomposition_Base.cpp.
|
inherited |
Call to get the optimized parameters.
ret | Preallocated array to store the optimized parameters. |
Definition at line 606 of file Decomposition_Base.cpp.
|
inherited |
Call to get the number of free parameters.
Definition at line 409 of file Operation_block (copy).cpp.
|
inherited |
Call to get the number of qubits composing the unitary.
Definition at line 183 of file Operation.cpp.
|
inherited |
Call to get the index of the target qubit.
Definition at line 149 of file Operation.cpp.
|
inherited |
Calculate the transformed matrix resulting by an array of operations on the matrix Umtx.
parameters | An array containing the parameters of the U3 operations. |
operations_it | An iterator pointing to the first operation to be applied on the initial matrix. |
num_of_operations | The number of operations to be applied on the initial matrix |
Definition at line 619 of file Decomposition_Base.cpp.
|
inherited |
Calculate the transformed matrix resulting by an array of operations on a given initial matrix.
parameters | An array containing the parameters of the U3 operations. |
operations_it | An iterator pointing to the first operation to be applied on the initial matrix. |
num_of_operations | The number of operations to be applied on the initial matrix |
initial_matrix | The initial matrix wich is transformed by the given operations. |
parameters | An array containing the parameters of the U3 operations. |
operations_it | An iterator pointing to the first operation to be applied on the initial matrix. |
num_of_operations | The number of operations to be applied on the initial matrix |
initial_matrix | The initial matrix wich is transformed by the given operations. (by deafult it is set to the attribute Umtx) |
Definition at line 634 of file Decomposition_Base.cpp.
|
inherited |
Call to get the type of the operation.
Definition at line 174 of file Operation.cpp.
|
inherited |
Call to retrive a pointer to the unitary to be transformed.
Definition at line 579 of file Decomposition_Base.cpp.
|
inherited |
Call to get the size of the unitary to be transformed.
Definition at line 588 of file Decomposition_Base.cpp.
|
staticinherited |
Initializes default layer numbers.
Definition at line 853 of file Decomposition_Base.cpp.
|
inherited |
Call to print the operations decomposing the initial unitary.
These operations brings the intial matrix into unity.
start_index | The index of the first operation |
Definition at line 188 of file Decomposition_Base.cpp.
|
inherited |
Call to print the list of operations stored in the block of operations for a specific set of parameters.
parameters | The parameters of the operations that should be printed. |
start_index | The ordinal number of the first operation. |
Definition at line 428 of file Operation_block (copy).cpp.
|
virtual |
The optimization problem of the final optimization.
parameters | An array of the free parameters to be optimized. (The number of teh free paramaters should be equal to the number of parameters in one sub-layer) |
Reimplemented from Decomposition_Base.
Definition at line 472 of file N_Qubit_Decomposition.cpp.
|
static |
The optimization problem of the final optimization.
parameters | A GNU Scientific Library containing the parameters to be optimized. |
void_instance | A void pointer pointing to the instance of the current class. |
Definition at line 489 of file N_Qubit_Decomposition.cpp.
|
static |
Call to calculate both the cost function and the its gradient components.
parameters | A GNU Scientific Library vector containing the free parameters to be optimized. |
void_instance | A void pointer pointing to the instance of the current class. |
f0 | The value of the cost function at x0. |
grad | A GNU Scientific Library vector containing the calculated gradient components. |
Definition at line 35 of file Functor_Cost_Function_Gradient.cpp.
|
static |
Calculate the approximate derivative (f-f0)/(x-x0) of the cost function with respect to the free parameters.
parameters | A GNU Scientific Library vector containing the free parameters to be optimized. |
void_instance | A void pointer pointing to the instance of the current class. |
grad | A GNU Scientific Library vector containing the calculated gradient components. |
Definition at line 17 of file Functor_Cost_Function_Gradient.cpp.
|
inherited |
Call to prepare the optimized operations to export.
The operations are stored in the attribute operations
Definition at line 870 of file Decomposition_Base.cpp.
|
inherited |
Call to prepare the optimized operations to export.
ops | A list of operations |
parameters | The parameters of the operations |
Definition at line 888 of file Decomposition_Base.cpp.
|
inherited |
Call to prepare the operations of an operation block to export.
block_op | A pointer to a block of operations |
parameters | The parameters of the operations |
Definition at line 990 of file Decomposition_Base.cpp.
|
inherited |
Call to release the stored operations.
Definition at line 68 of file Operation_block (copy).cpp.
|
virtualinherited |
Call to reorder the qubits in the matrix of the operation.
qbit_list | The reordered list of qubits spanning the matrix |
Reimplemented from Operation.
Definition at line 760 of file Decomposition_Base.cpp.
int N_Qubit_Decomposition::set_identical_blocks | ( | int | n, |
int | identical_blocks_in | ||
) |
Set the number of identical successive blocks during the subdecomposition of the n-th qubit.
n | The number of qubits for which the maximal number of layers should be used in the subdecomposition. |
identical_blocks_in | The number of successive identical layers used in the subdecomposition. |
Definition at line 849 of file N_Qubit_Decomposition.cpp.
int N_Qubit_Decomposition::set_identical_blocks | ( | std::map< int, int > | identical_blocks_in | ) |
Set the number of identical successive blocks during the subdecomposition of the n-th qubit.
identical_blocks_in | An <int,int> map containing the number of successive identical layers used in the subdecompositions. |
Definition at line 870 of file N_Qubit_Decomposition.cpp.
|
inherited |
Set the number of iteration loops during the subdecomposition of the n-th qubit.
n | The number of qubits for which number of iteration loops should be used in the subdecomposition., |
iteration_loops_in | The number of iteration loops in each sted of the subdecomposition. |
Definition at line 818 of file Decomposition_Base.cpp.
|
inherited |
Set the number of iteration loops during the subdecomposition of the qbit-th qubit.
iteration_loops_in | An <int,int> map containing the number of iteration loops for the individual subdecomposition processes |
Definition at line 838 of file Decomposition_Base.cpp.
|
inherited |
Call to set the stored matrix in the operation.
input | The operation matrix to be stored. The matrix is stored by attribute matrix_alloc. |
Definition at line 109 of file Operation.cpp.
|
inherited |
Call to set the maximal number of the iterations in the optimization process.
max_iterations_in | maximal number of iteartions in the optimization process |
Definition at line 124 of file Decomposition_Base.cpp.
|
inherited |
Set the maximal number of layers used in the subdecomposition of the n-th qubit.
n | The number of qubits for which the maximal number of layers should be used in the subdecomposition. |
max_layer_num_in | The maximal number of the operation layers used in the subdecomposition. |
Definition at line 724 of file Decomposition_Base.cpp.
|
inherited |
Set the maximal number of layers used in the subdecomposition of the n-th qubit.
max_layer_num_in | An <int,int> map containing the maximal number of the operation layers used in the subdecomposition. |
Definition at line 744 of file Decomposition_Base.cpp.
|
inherited |
Call to set the number of operation blocks to be optimized in one shot.
optimization_block_in | The number of operation blocks to be optimized in one shot |
Definition at line 116 of file Decomposition_Base.cpp.
|
virtualinherited |
Set the number of qubits spanning the matrix of the operations stored in the block of operations.
qbit_num_in | The number of qubits spanning the matrices. |
Reimplemented from Operation.
Definition at line 633 of file Operation_block (copy).cpp.
|
inherited |
Call to set the verbose attribute to true or false.
verbose_in | Logical variable. Set true for verbose mode, or to false to suppress output messages. |
Definition at line 1048 of file Decomposition_Base.cpp.
int N_Qubit_Decomposition::simplify_layer | ( | Operation_block * | layer, |
double * | parameters, | ||
unsigned int | parameter_num_block, | ||
std::map< int, int > | max_layer_num_loc, | ||
Operation_block *& | simplified_layer, | ||
double *& | simplified_parameters, | ||
unsigned int & | simplified_parameter_num | ||
) |
Call to simplify the gate structure in a block of operations (i.e.
tries to reduce the number of CNOT gates)
layer | An instance of class Operation_block containing the 2-qubit gate structure to be simplified |
parameters | An array of parameters to calculate the matrix representation of the operations in the block of operations. |
parameter_num_block | NUmber of parameters in the block of operations to be simplified. |
max_layer_num_loc | A map of <int n: int num> indicating the maximal number of CNOT operations allowed in the simplification. |
simplified_layer | An instance of Operation_block containing the simplified structure of operations. |
simplified_parameters | An array of parameters containing the parameters of the simplified block structure. |
simplified_parameter_num | The number of parameters in the simplified block structure. |
Definition at line 710 of file N_Qubit_Decomposition.cpp.
void N_Qubit_Decomposition::simplify_layers | ( | ) |
Call to simplify the gate structure in the layers if possible (i.e.
tries to reduce the number of CNOT gates)
Definition at line 512 of file N_Qubit_Decomposition.cpp.
|
virtual |
Call to solve layer by layer the optimization problem.
The optimalized parameters are stored in attribute optimized_parameters.
num_of_parameters | Number of parameters to be optimized |
solution_guess_gsl | A GNU Scientific Library vector containing the solution guess. |
Reimplemented from Decomposition_Base.
Definition at line 373 of file N_Qubit_Decomposition.cpp.
|
inherited |
This method can be used to solve the main optimization problem which is devidid into sub-layer optimization processes.
(The aim of the optimization problem is to disentangle one or more qubits) The optimalized parameters are stored in attribute optimized_parameters.
solution_guess | An array of the guessed parameters |
solution_guess_num | The number of guessed parameters. (not necessarily equal to the number of free parameters) |
Definition at line 283 of file Decomposition_Base.cpp.
void N_Qubit_Decomposition::start_decomposition | ( | bool | finalize_decomp = true , |
bool | prepare_export = true |
||
) |
Start the disentanglig process of the unitary.
finalize_decomp | Optional logical parameter. If true (default), the decoupled qubits are rotated into state |0> when the disentangling of the qubits is done. Set to False to omit this procedure |
prepare_export | Logical parameter. Set true to prepare the list of operations to be exported, or false otherwise. |
Definition at line 76 of file N_Qubit_Decomposition.cpp.
|
protectedinherited |
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations.
Definition at line 52 of file Operation.h.
|
protectedinherited |
The current minimum of the optimization problem.
Definition at line 90 of file Decomposition_Base.h.
|
protectedinherited |
error of the unitarity of the final decomposition
Definition at line 81 of file Decomposition_Base.h.
|
protectedinherited |
logical value describing whether the decomposition was finalized or not (i.e. whether the decomposed qubits were rotated into the state |0> or not)
Definition at line 78 of file Decomposition_Base.h.
|
protectedinherited |
number of finalizing (deterministic) opertaions rotating the disentangled qubits into state |0>.
Definition at line 84 of file Decomposition_Base.h.
|
protectedinherited |
the number of the finalizing (deterministic) parameters of operations rotating the disentangled qubits into state |0>.
Definition at line 87 of file Decomposition_Base.h.
|
protectedinherited |
The global target minimum of the optimization problem.
Definition at line 93 of file Decomposition_Base.h.
|
protected |
A map of <int n: int num> indicating that how many identical succesive blocks should be used in the disentanglement of the nth qubit from the others.
Definition at line 48 of file N_Qubit_Decomposition.h.
|
protectedinherited |
type to guess the initial values for the optimization. Possible values: ZEROS=0, RANDOM=1, CLOSE_TO_ZERO=2
Definition at line 102 of file Decomposition_Base.h.
|
protectedinherited |
A map of <int n: int num> indicating the number of iteration in each step of the decomposition.
Definition at line 69 of file Decomposition_Base.h.
|
protectedinherited |
number of operation layers
Definition at line 43 of file Operation_block.h.
|
protectedinherited |
The size N of the NxN matrix associated with the operations.
Definition at line 54 of file Operation.h.
|
protectedinherited |
Maximal number of iterations allowed in the optimization process.
Definition at line 99 of file Decomposition_Base.h.
|
protectedinherited |
A map of <int n: int num> indicating that how many layers should be used in the subdecomposition process for the subdecomposing of the nth qubits.
Definition at line 66 of file Decomposition_Base.h.
|
staticinherited |
A map of <int n: int num> indicating that how many layers should be used in the subdecomposition process by default for the subdecomposing of the nth qubits.
Definition at line 58 of file Decomposition_Base.h.
|
protectedinherited |
Number of outer OpenMP threads. (During the calculations OpenMP multithreading is turned off.)
Definition at line 105 of file Decomposition_Base.h.
|
protectedinherited |
The list of stored operations.
Definition at line 41 of file Operation_block.h.
|
inherited |
number of operation blocks used in one shot of the optimization process
Definition at line 55 of file Decomposition_Base.h.
|
protectedinherited |
logical value describing whether the optimization problem was solved or not
Definition at line 96 of file Decomposition_Base.h.
|
inherited |
The maximal allowed error of the optimization problem.
Definition at line 61 of file Decomposition_Base.h.
|
protected |
logical value. Set true to optimize the minimum number of operation layers required in the decomposition, or false when the predefined maximal number of layer gates is used (ideal for general unitaries).
Definition at line 45 of file N_Qubit_Decomposition.h.
|
protectedinherited |
The optimized parameters for the operations.
Definition at line 75 of file Decomposition_Base.h.
|
protectedinherited |
the number of free parameters of the operation
Definition at line 56 of file Operation.h.
|
protectedinherited |
number of qubits spanning the matrix of the operation
Definition at line 46 of file Operation.h.
|
protectedinherited |
The index of the qubit on which the operation acts (target_qbit >= 0)
Definition at line 50 of file Operation.h.
|
protectedinherited |
The type of the operation (see enumeration operation_type)
Definition at line 48 of file Operation.h.
|
protectedinherited |
The unitary to be decomposed.
Definition at line 72 of file Decomposition_Base.h.
|
inherited |
Logical variable. Set true for verbose mode, or to false to suppress output messages.
Definition at line 52 of file Decomposition_Base.h.