Quantum Gate Decomposer  v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes
Sub_Matrix_Decomposition Class Reference

A class responsible for the disentanglement of one qubit from the others. More...

#include <Sub_Matrix_Decomposition.h>

Inheritance diagram for Sub_Matrix_Decomposition:
Inheritance graph
[legend]

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...
 
Sub_Matrix_Decompositionclone ()
 Call to 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 disentangle_submatrices ()
 Start the optimization process to disentangle the most significant qubit from the others. More...
 
int extract_operations (Operation_block *op_block)
 Call to extract the operations stored in the class. 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< Matrixget_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...
 
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 qbit, int identical_blocks_in)
 Set the number of identical successive blocks during the subdecomposition of the qbit-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...
 
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...
 
 Sub_Matrix_Decomposition (Matrix Umtx_in, int qbit_num_in, bool optimize_layer_num_in, guess_type initial_guess_in)
 Constructor of the class. More...
 
 ~Sub_Matrix_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

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...
 
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 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...
 
Matrix subdecomposed_mtx
 The subdecomposed matrix. More...
 
bool subdisentaglement_done
 logical value indicating whether the disentamglement of a qubit from the othetrs was done or not 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...
 
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...
 
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...
 

Detailed Description

A class responsible for the disentanglement of one qubit from the others.

Definition at line 35 of file Sub_Matrix_Decomposition.h.

Constructor & Destructor Documentation

◆ Sub_Matrix_Decomposition()

Sub_Matrix_Decomposition::Sub_Matrix_Decomposition ( Matrix  Umtx_in,
int  qbit_num_in,
bool  optimize_layer_num_in = false,
guess_type  initial_guess_in = CLOSE_TO_ZERO 
)

Constructor of the class.

Parameters
Umtx_inThe unitary matrix to be decomposed
qbit_num_inThe number of qubits spanning the unitary Umtx
optimize_layer_num_inOptional 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_inEnumeration element indicating the method to guess initial values for the optimization. Possible values: 'zeros=0' ,'random=1', 'close_to_zero=2'
Returns
An instance of the class

Definition at line 38 of file Sub_Matrix_Decomposition.cpp.

Here is the caller graph for this function:

◆ ~Sub_Matrix_Decomposition()

Sub_Matrix_Decomposition::~Sub_Matrix_Decomposition ( )

Destructor of the class.

Definition at line 73 of file Sub_Matrix_Decomposition.cpp.

Member Function Documentation

◆ add_cnot_to_end()

void Operation_block::add_cnot_to_end ( int  control_qbit,
int  target_qbit 
)
inherited

Append a C_NOT gate operation to the list of operations.

Parameters
control_qbitThe identification number of the control qubit. (0 <= target_qbit <= qbit_num-1)
target_qbitThe identification number of the target qubit. (0 <= target_qbit <= qbit_num-1)

Definition at line 264 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_cnot_to_front()

void Operation_block::add_cnot_to_front ( int  control_qbit,
int  target_qbit 
)
inherited

Add a C_NOT gate operation to the front of the list of operations.

Parameters
control_qbitThe identification number of the control qubit. (0 <= target_qbit <= qbit_num-1)
target_qbitThe identification number of the target qubit. (0 <= target_qbit <= qbit_num-1)

Definition at line 281 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ add_operation_to_end()

void Operation_block::add_operation_to_end ( Operation operation)
inherited

Append a general operation to the list of operations.

Parameters
operationA pointer to a class Operation describing an operation.

Definition at line 322 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_operation_to_front()

void Operation_block::add_operation_to_front ( Operation operation)
inherited

Add an operation to the front of the list of operations.

Parameters
operationA pointer to a class Operation describing an operation.

Definition at line 345 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_operations_to_end()

void Operation_block::add_operations_to_end ( std::vector< Operation * >  operations_in)
inherited

Append a list of operations to the list of operations.

Parameters
operations_inA list of operation class instances.

Definition at line 295 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ add_operations_to_front()

void Operation_block::add_operations_to_front ( std::vector< Operation * >  operations_in)
inherited

Add an array of operations to the front of the list of operations.

Parameters
operations_inA list of operation class instances.

Definition at line 308 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ add_u3_to_end()

void Operation_block::add_u3_to_end ( int  target_qbit,
bool  Theta,
bool  Phi,
bool  Lambda 
)
inherited

Append a U3 gate to the list of operations.

Parameters
target_qbitThe identification number of the targt qubit. (0 <= target_qbit <= qbit_num-1)
ThetaThe Theta parameter of the U3 operation
PhiThe Phi parameter of the U3 operation
LambdaThe Lambda parameter of the U3 operation

Definition at line 233 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_u3_to_front()

void Operation_block::add_u3_to_front ( int  target_qbit,
bool  Theta,
bool  Phi,
bool  Lambda 
)
inherited

Add a U3 gate to the front of the list of operations.

Parameters
target_qbitThe identification number of the targt qubit. (0 <= target_qbit <= qbit_num-1)
ThetaThe Theta parameter of the U3 operation
PhiThe Phi parameter of the U3 operation
LambdaThe Lambda parameter of the U3 operation

Definition at line 249 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ apply_operation()

Matrix Decomposition_Base::apply_operation ( Matrix operation_mtx,
Matrix input_matrix 
)
inherited

Apply an operations on the input matrix.

Parameters
operation_mtxThe matrix of the operation.
input_matrixThe input matrix to be transformed.
Returns
Returns with the transformed matrix

Definition at line 711 of file Decomposition_Base.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_optimization_solution()

bool Decomposition_Base::check_optimization_solution ( )
inherited

check_optimization_solution

Checks the convergence of the optimization problem.

Returns
Returns with true if the target global minimum was reached during the optimization process, or false otherwise.

Definition at line 568 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ clone()

Sub_Matrix_Decomposition * Sub_Matrix_Decomposition::clone ( )

Call to create a clone of the present class.

Create a clone of the present class.

Returns
Return with a pointer pointing to the cloned object
Return with a pointer pointing to the cloned object.

Definition at line 411 of file Sub_Matrix_Decomposition.cpp.

Here is the call graph for this function:

◆ combine()

void Operation_block::combine ( Operation_block op_block)
inherited

Call to append the operations of an operation block to the current block.

Parameters
op_blockA pointer to an instance of class Operation_block

Definition at line 593 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disentangle_submatrices()

void Sub_Matrix_Decomposition::disentangle_submatrices ( )

Start the optimization process to disentangle the most significant qubit from the others.

The optimized parameters and operations are stored in the attributes optimized_parameters and operations.

Definition at line 85 of file Sub_Matrix_Decomposition.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_operations()

int Operation_block::extract_operations ( Operation_block op_block)
inherited

Call to extract the operations stored in the class.

Parameters
op_blockAn instance of Operation_block class in which the operations will be stored. (The current operations will be erased)
Returns
Return with 0 on success.

Definition at line 686 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalize_decomposition()

void Decomposition_Base::finalize_decomposition ( )
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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_control_qbit()

int Operation::get_control_qbit ( )
inherited

Call to get the index of the control qubit.

Returns
Return with the index of the control qubit (return with -1 if control qubit was not set)

Definition at line 157 of file Operation.cpp.

Here is the caller graph for this function:

◆ get_decomposed_matrix()

Matrix Decomposition_Base::get_decomposed_matrix ( )
inherited

Calculate the decomposed matrix resulted by the effect of the optimized operations on the unitary Umtx.

Returns
Returns with the decomposed matrix.

Definition at line 699 of file Decomposition_Base.cpp.

Here is the call graph for this function:

◆ get_decomposition_error()

double Decomposition_Base::get_decomposition_error ( )
inherited

Call to get the error of the decomposition.

Returns
Returns with the error of the decomposition

Definition at line 1059 of file Decomposition_Base.cpp.

◆ get_finalizing_operations()

Matrix Decomposition_Base::get_finalizing_operations ( Matrix mtx,
Operation_block finalizing_operations,
double *  finalizing_parameters 
)
inherited

This method determine the operations needed to rotate the indepent qubits into the state |0>

Parameters
mtxThe unitary describing indepent qubits. The resulting matrix is returned by this pointer
finalizing_operationsPointer pointig to a block of operations containing the final operations.
finalizing_parametersParameters corresponding to the finalizing operations.
Returns
Returns with the finalized matrix

Definition at line 203 of file Decomposition_Base.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_gate_nums()

gates_num Operation_block::get_gate_nums ( )
inherited

Call to get the number of the individual gate types in the list of operations.

Returns
Returns with an instance gates_num describing the number of the individual gate types

Definition at line 369 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_involved_qubits()

std::vector< int > Operation_block::get_involved_qubits ( )
inherited

Call to get the qubits involved in the operations stored in the block of operations.

Returns
Return with a list of the invovled qubits

Definition at line 552 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_matrices()

std::vector< Matrix > Operation_block::get_matrices ( const double *  parameters)
inherited

Call to get the list of matrix representation of the operations grouped in the block.

Parameters
parametersArray of parameters to calculate the matrix of the operation block
Returns
Returns with the list of the operations

Definition at line 174 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_matrix() [1/2]

Matrix Operation_block::get_matrix ( const double *  parameters)
inherited

Call to retrieve the operation matrix (Which is the product of all the operation matrices stored in the operation block)

Parameters
parametersAn array pointing to the parameters of the operations
Returns
Returns with the operation matrix

Definition at line 106 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_matrix() [2/2]

Matrix Operation::get_matrix ( )
inherited

Call to retrieve the operation matrix.

Returns
Returns with a matrix of the operation

Definition at line 97 of file Operation.cpp.

Here is the caller graph for this function:

◆ get_operation()

int Decomposition_Base::get_operation ( unsigned int  n,
operation_type type,
int &  target_qbit,
int &  control_qbit,
double *  parameters 
)
inherited

Call to prepare the optimized operations to export.

Parameters
nInteger labeling the n-th oepration (n>=0).
typeThe type of the operation from enumeration operation_type is returned via this parameter.
target_qbitThe ID of the target qubit is returned via this input parameter.
control_qbitThe ID of the control qubit is returned via this input parameter.
parametersThe parameters of the operations
Returns
Returns with 0 if the export of the n-th operation was successful. If the n-th operation does not exists, -1 is returned. If the operation is not allowed to be exported, i.e. it is not a CNOT or U3 operation, then -2 is returned.

Definition at line 1009 of file Decomposition_Base.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_operation_num()

int Operation_block::get_operation_num ( )
inherited

Call to get the number of operations grouped in the class.

Returns
Return with the number of the operations grouped in the operation block.

Definition at line 418 of file Operation_block (copy).cpp.

Here is the caller graph for this function:

◆ get_operation_products()

std::vector< Matrix, tbb::cache_aligned_allocator< Matrix > > Decomposition_Base::get_operation_products ( double *  parameters,
std::vector< Operation * >::iterator  operations_it,
int  num_of_operations 
)
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
parametersAn array containing the parameters of the U3 operations.
operations_itAn iterator pointing to the forst operation.
num_of_operationsThe number of operations involved in the calculations
Returns
Returns with a vector of the product matrices.
Parameters
parametersAn array containing the parameters of the operations.
operations_itAn iterator pointing to the first operation.
num_of_operationsThe number of operations involved in the calculations
Returns
Returns with a vector of the product matrices.

Definition at line 35 of file Functor_Get_Operation_Products.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_operations()

std::vector< Operation * > Operation_block::get_operations ( )
inherited

Call to get the operations stored in the class.

Returns
Return with a list of the operations.

Definition at line 584 of file Operation_block (copy).cpp.

Here is the caller graph for this function:

◆ get_optimized_parameters() [1/2]

double * Decomposition_Base::get_optimized_parameters ( )
inherited

Call to get the optimized parameters.

Returns
Return with the pointer pointing to the array storing the optimized parameters

Definition at line 596 of file Decomposition_Base.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_optimized_parameters() [2/2]

void Decomposition_Base::get_optimized_parameters ( double *  ret)
inherited

Call to get the optimized parameters.

Parameters
retPreallocated array to store the optimized parameters.

Definition at line 606 of file Decomposition_Base.cpp.

◆ get_parameter_num()

int Operation_block::get_parameter_num ( )
inherited

Call to get the number of free parameters.

Returns
Return with the number of parameters of the operations grouped in the operation block.

Definition at line 409 of file Operation_block (copy).cpp.

Here is the caller graph for this function:

◆ get_qbit_num()

int Operation::get_qbit_num ( )
inherited

Call to get the number of qubits composing the unitary.

Returns
Return with the number of qubits composing the unitary

Definition at line 183 of file Operation.cpp.

◆ get_target_qbit()

int Operation::get_target_qbit ( )
inherited

Call to get the index of the target qubit.

Returns
Return with the index of the target qubit (return with -1 if target qubit was not set)

Definition at line 149 of file Operation.cpp.

Here is the caller graph for this function:

◆ get_transformed_matrix() [1/2]

Matrix Decomposition_Base::get_transformed_matrix ( const double *  parameters,
std::vector< Operation * >::iterator  operations_it,
int  num_of_operations 
)
inherited

Calculate the transformed matrix resulting by an array of operations on the matrix Umtx.

Parameters
parametersAn array containing the parameters of the U3 operations.
operations_itAn iterator pointing to the first operation to be applied on the initial matrix.
num_of_operationsThe number of operations to be applied on the initial matrix
Returns
Returns with the transformed matrix.

Definition at line 619 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ get_transformed_matrix() [2/2]

Matrix Decomposition_Base::get_transformed_matrix ( const double *  parameters,
std::vector< Operation * >::iterator  operations_it,
int  num_of_operations,
Matrix initial_matrix 
)
inherited

Calculate the transformed matrix resulting by an array of operations on a given initial matrix.

Parameters
parametersAn array containing the parameters of the U3 operations.
operations_itAn iterator pointing to the first operation to be applied on the initial matrix.
num_of_operationsThe number of operations to be applied on the initial matrix
initial_matrixThe initial matrix wich is transformed by the given operations.
Returns
Returns with the transformed matrix.
Parameters
parametersAn array containing the parameters of the U3 operations.
operations_itAn iterator pointing to the first operation to be applied on the initial matrix.
num_of_operationsThe number of operations to be applied on the initial matrix
initial_matrixThe initial matrix wich is transformed by the given operations. (by deafult it is set to the attribute Umtx)
Returns
Returns with the transformed matrix.

Definition at line 634 of file Decomposition_Base.cpp.

Here is the call graph for this function:

◆ get_type()

operation_type Operation::get_type ( )
inherited

Call to get the type of the operation.

Returns
Return with the type of the operation (see operation_type for details)

Definition at line 174 of file Operation.cpp.

Here is the caller graph for this function:

◆ get_Umtx()

Matrix Decomposition_Base::get_Umtx ( )
inherited

Call to retrive a pointer to the unitary to be transformed.

Returns
Return with the unitary Umtx

Definition at line 579 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ get_Umtx_size()

int Decomposition_Base::get_Umtx_size ( )
inherited

Call to get the size of the unitary to be transformed.

Returns
Return with the size N of the unitary NxN

Definition at line 588 of file Decomposition_Base.cpp.

◆ Init_max_layer_num()

void Decomposition_Base::Init_max_layer_num ( )
staticinherited

Initializes default layer numbers.

Definition at line 853 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ list_operations() [1/2]

void Decomposition_Base::list_operations ( int  start_index)
inherited

Call to print the operations decomposing the initial unitary.

These operations brings the intial matrix into unity.

Parameters
start_indexThe index of the first operation

Definition at line 188 of file Decomposition_Base.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_operations() [2/2]

void Operation_block::list_operations ( const double *  parameters,
int  start_index 
)
inherited

Call to print the list of operations stored in the block of operations for a specific set of parameters.

Parameters
parametersThe parameters of the operations that should be printed.
start_indexThe ordinal number of the first operation.

Definition at line 428 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ optimization_problem() [1/2]

double Sub_Matrix_Decomposition::optimization_problem ( const double *  parameters)
virtual

The optimization problem of the final optimization.

Parameters
parametersAn 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)
Returns
Returns with the cost function. (zero if the qubits are desintangled.)

Reimplemented from Decomposition_Base.

Definition at line 332 of file Sub_Matrix_Decomposition.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ optimization_problem() [2/2]

double Sub_Matrix_Decomposition::optimization_problem ( const gsl_vector *  parameters,
void *  void_instance 
)
static

The optimization problem of the final optimization.

Parameters
parametersA GNU Scientific Library containing the parameters to be optimized.
void_instanceA void pointer pointing to the instance of the current class.
Returns
Returns with the cost function. (zero if the qubits are desintangled.)
Parameters
parametersA GNU Scientific Library containing the parameters to be optimized.
void_instanceA void pointer pointing to the instance of the current class.
Returns
Returns with the cost function. (zero if the qubits are disentangled.)

Definition at line 350 of file Sub_Matrix_Decomposition.cpp.

Here is the call graph for this function:

◆ optimization_problem_combined()

void Sub_Matrix_Decomposition::optimization_problem_combined ( const gsl_vector *  parameters,
void *  void_instance,
double *  f0,
gsl_vector *  grad 
)
static

Call to calculate both the cost function and the its gradient components.

Parameters
parametersA GNU Scientific Library vector containing the free parameters to be optimized.
void_instanceA void pointer pointing to the instance of the current class.
f0The value of the cost function at x0.
gradA GNU Scientific Library vector containing the calculated gradient components.

Definition at line 95 of file Functor_Cost_Function_Gradient.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ optimization_problem_grad()

void Sub_Matrix_Decomposition::optimization_problem_grad ( const gsl_vector *  parameters,
void *  void_instance,
gsl_vector *  grad 
)
static

Calculate the approximate derivative (f-f0)/(x-x0) of the cost function with respect to the free parameters.

Parameters
parametersA GNU Scientific Library vector containing the free parameters to be optimized.
void_instanceA void pointer pointing to the instance of the current class.
gradA GNU Scientific Library vector containing the calculated gradient components.

Definition at line 76 of file Functor_Cost_Function_Gradient.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare_operations_to_export() [1/3]

void Decomposition_Base::prepare_operations_to_export ( )
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.

Here is the caller graph for this function:

◆ prepare_operations_to_export() [2/3]

std::vector< Operation * > Decomposition_Base::prepare_operations_to_export ( std::vector< Operation * >  ops,
const double *  parameters 
)
inherited

Call to prepare the optimized operations to export.

Parameters
opsA list of operations
parametersThe parameters of the operations
Returns
Returns with a list of CNOT and U3 operations.

Definition at line 888 of file Decomposition_Base.cpp.

Here is the call graph for this function:

◆ prepare_operations_to_export() [3/3]

std::vector< Operation * > Decomposition_Base::prepare_operations_to_export ( Operation_block block_op,
const double *  parameters 
)
inherited

Call to prepare the operations of an operation block to export.

Parameters
block_opA pointer to a block of operations
parametersThe parameters of the operations
Returns
Returns with a list of CNOT and U3 operations.

Definition at line 990 of file Decomposition_Base.cpp.

Here is the call graph for this function:

◆ release_operations()

void Operation_block::release_operations ( )
inherited

Call to release the stored operations.

Definition at line 68 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reorder_qubits()

void Decomposition_Base::reorder_qubits ( std::vector< int >  qbit_list)
virtualinherited

Call to reorder the qubits in the matrix of the operation.

Parameters
qbit_listThe reordered list of qubits spanning the matrix

Reimplemented from Operation.

Definition at line 760 of file Decomposition_Base.cpp.

Here is the call graph for this function:

◆ set_identical_blocks() [1/2]

int Sub_Matrix_Decomposition::set_identical_blocks ( int  qbit,
int  identical_blocks_in 
)

Set the number of identical successive blocks during the subdecomposition of the qbit-th qubit.

Parameters
qbitThe number of qubits for which the maximal number of layers should be used in the subdecomposition.
identical_blocks_inThe number of successive identical layers used in the subdecomposition.
Returns
Returns with zero in case of success.

Definition at line 376 of file Sub_Matrix_Decomposition.cpp.

Here is the caller graph for this function:

◆ set_identical_blocks() [2/2]

int Sub_Matrix_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.

Parameters
identical_blocks_inAn <int,int> map containing the number of successive identical layers used in the subdecompositions.
Returns
Returns with zero in case of success.

Definition at line 396 of file Sub_Matrix_Decomposition.cpp.

Here is the call graph for this function:

◆ set_iteration_loops() [1/2]

int Decomposition_Base::set_iteration_loops ( int  n,
int  iteration_loops_in 
)
inherited

Set the number of iteration loops during the subdecomposition of the n-th qubit.

Parameters
nThe number of qubits for which number of iteration loops should be used in the subdecomposition.,
iteration_loops_inThe number of iteration loops in each sted of the subdecomposition.
Returns
Returns with 0 if succeded.

Definition at line 818 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ set_iteration_loops() [2/2]

int Decomposition_Base::set_iteration_loops ( std::map< int, int >  iteration_loops_in)
inherited

Set the number of iteration loops during the subdecomposition of the qbit-th qubit.

Parameters
iteration_loops_inAn <int,int> map containing the number of iteration loops for the individual subdecomposition processes
Returns
Returns with 0 if succeded.

Definition at line 838 of file Decomposition_Base.cpp.

Here is the call graph for this function:

◆ set_matrix()

void Operation::set_matrix ( Matrix  input)
inherited

Call to set the stored matrix in the operation.

Parameters
inputThe operation matrix to be stored. The matrix is stored by attribute matrix_alloc.
Returns
Returns with 0 on success.

Definition at line 109 of file Operation.cpp.

Here is the caller graph for this function:

◆ set_max_iteration()

void Decomposition_Base::set_max_iteration ( int  max_iterations_in)
inherited

Call to set the maximal number of the iterations in the optimization process.

Parameters
max_iterations_inmaximal number of iteartions in the optimization process

Definition at line 124 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ set_max_layer_num() [1/2]

int Decomposition_Base::set_max_layer_num ( int  n,
int  max_layer_num_in 
)
inherited

Set the maximal number of layers used in the subdecomposition of the n-th qubit.

Parameters
nThe number of qubits for which the maximal number of layers should be used in the subdecomposition.
max_layer_num_inThe maximal number of the operation layers used in the subdecomposition.
Returns
Returns with 0 if succeded.

Definition at line 724 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ set_max_layer_num() [2/2]

int Decomposition_Base::set_max_layer_num ( std::map< int, int >  max_layer_num_in)
inherited

Set the maximal number of layers used in the subdecomposition of the n-th qubit.

Parameters
max_layer_num_inAn <int,int> map containing the maximal number of the operation layers used in the subdecomposition.
Returns
Returns with 0 if succeded.

Definition at line 744 of file Decomposition_Base.cpp.

Here is the call graph for this function:

◆ set_optimization_blocks()

void Decomposition_Base::set_optimization_blocks ( int  optimization_block_in)
inherited

Call to set the number of operation blocks to be optimized in one shot.

Parameters
optimization_block_inThe number of operation blocks to be optimized in one shot

Definition at line 116 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ set_qbit_num()

void Operation_block::set_qbit_num ( int  qbit_num_in)
virtualinherited

Set the number of qubits spanning the matrix of the operations stored in the block of operations.

Parameters
qbit_num_inThe number of qubits spanning the matrices.

Reimplemented from Operation.

Definition at line 633 of file Operation_block (copy).cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_verbose()

void Decomposition_Base::set_verbose ( bool  verbose_in)
inherited

Call to set the verbose attribute to true or false.

Parameters
verbose_inLogical variable. Set true for verbose mode, or to false to suppress output messages.

Definition at line 1048 of file Decomposition_Base.cpp.

Here is the caller graph for this function:

◆ solve_layer_optimization_problem()

void Sub_Matrix_Decomposition::solve_layer_optimization_problem ( int  num_of_parameters,
gsl_vector *  solution_guess_gsl 
)
virtual

Call to solve layer by layer the optimization problem.

The optimalized parameters are stored in attribute optimized_parameters.

Parameters
num_of_parametersNumber of parameters to be optimized
solution_guess_gslA GNU Scientific Library vector containing the solution guess.

Reimplemented from Decomposition_Base.

Definition at line 228 of file Sub_Matrix_Decomposition.cpp.

Here is the call graph for this function:

◆ solve_optimization_problem()

void Decomposition_Base::solve_optimization_problem ( double *  solution_guess,
int  solution_guess_num 
)
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.

Parameters
solution_guessAn array of the guessed parameters
solution_guess_numThe number of guessed parameters. (not necessarily equal to the number of free parameters)

Definition at line 283 of file Decomposition_Base.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ control_qbit

int Operation::control_qbit
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.

◆ current_minimum

double Decomposition_Base::current_minimum
protectedinherited

The current minimum of the optimization problem.

Definition at line 90 of file Decomposition_Base.h.

◆ decomposition_error

double Decomposition_Base::decomposition_error
protectedinherited

error of the unitarity of the final decomposition

Definition at line 81 of file Decomposition_Base.h.

◆ decomposition_finalized

bool Decomposition_Base::decomposition_finalized
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.

◆ finalizing_operations_num

int Decomposition_Base::finalizing_operations_num
protectedinherited

number of finalizing (deterministic) opertaions rotating the disentangled qubits into state |0>.

Definition at line 84 of file Decomposition_Base.h.

◆ finalizing_parameter_num

int Decomposition_Base::finalizing_parameter_num
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.

◆ global_target_minimum

double Decomposition_Base::global_target_minimum
protectedinherited

The global target minimum of the optimization problem.

Definition at line 93 of file Decomposition_Base.h.

◆ identical_blocks

std::map<int,int> Sub_Matrix_Decomposition::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.

Definition at line 50 of file Sub_Matrix_Decomposition.h.

◆ initial_guess

guess_type Decomposition_Base::initial_guess
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.

◆ iteration_loops

std::map<int,int> Decomposition_Base::iteration_loops
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.

◆ layer_num

int Operation_block::layer_num
protectedinherited

number of operation layers

Definition at line 43 of file Operation_block.h.

◆ matrix_size

int Operation::matrix_size
protectedinherited

The size N of the NxN matrix associated with the operations.

Definition at line 54 of file Operation.h.

◆ max_iterations

int Decomposition_Base::max_iterations
protectedinherited

Maximal number of iterations allowed in the optimization process.

Definition at line 99 of file Decomposition_Base.h.

◆ max_layer_num

std::map<int,int> Decomposition_Base::max_layer_num
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.

◆ max_layer_num_def

std::map< int, int > Decomposition_Base::max_layer_num_def
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.

◆ num_threads

int Decomposition_Base::num_threads
protectedinherited

Number of outer OpenMP threads. (During the calculations OpenMP multithreading is turned off.)

Definition at line 105 of file Decomposition_Base.h.

◆ operations

std::vector<Operation*> Operation_block::operations
protectedinherited

The list of stored operations.

Definition at line 41 of file Operation_block.h.

◆ optimization_block

int Decomposition_Base::optimization_block
inherited

number of operation blocks used in one shot of the optimization process

Definition at line 55 of file Decomposition_Base.h.

◆ optimization_problem_solved

bool Decomposition_Base::optimization_problem_solved
protectedinherited

logical value describing whether the optimization problem was solved or not

Definition at line 96 of file Decomposition_Base.h.

◆ optimization_tolerance

double Decomposition_Base::optimization_tolerance
inherited

The maximal allowed error of the optimization problem.

Definition at line 61 of file Decomposition_Base.h.

◆ optimize_layer_num

bool Sub_Matrix_Decomposition::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).

Definition at line 47 of file Sub_Matrix_Decomposition.h.

◆ optimized_parameters

double* Decomposition_Base::optimized_parameters
protectedinherited

The optimized parameters for the operations.

Definition at line 75 of file Decomposition_Base.h.

◆ parameter_num

unsigned int Operation::parameter_num
protectedinherited

the number of free parameters of the operation

Definition at line 56 of file Operation.h.

◆ qbit_num

int Operation::qbit_num
protectedinherited

number of qubits spanning the matrix of the operation

Definition at line 46 of file Operation.h.

◆ subdecomposed_mtx

Matrix Sub_Matrix_Decomposition::subdecomposed_mtx

The subdecomposed matrix.

Definition at line 44 of file Sub_Matrix_Decomposition.h.

◆ subdisentaglement_done

bool Sub_Matrix_Decomposition::subdisentaglement_done

logical value indicating whether the disentamglement of a qubit from the othetrs was done or not

Definition at line 41 of file Sub_Matrix_Decomposition.h.

◆ target_qbit

int Operation::target_qbit
protectedinherited

The index of the qubit on which the operation acts (target_qbit >= 0)

Definition at line 50 of file Operation.h.

◆ type

operation_type Operation::type
protectedinherited

The type of the operation (see enumeration operation_type)

Definition at line 48 of file Operation.h.

◆ Umtx

Matrix Decomposition_Base::Umtx
protectedinherited

The unitary to be decomposed.

Definition at line 72 of file Decomposition_Base.h.

◆ verbose

bool Decomposition_Base::verbose
inherited

Logical variable. Set true for verbose mode, or to false to suppress output messages.

Definition at line 52 of file Decomposition_Base.h.


The documentation for this class was generated from the following files: