59 N_Qubit_Decomposition_custom::N_Qubit_Decomposition_custom(
Matrix Umtx_in,
int qbit_num_in,
bool optimize_layer_num_in, std::map<std::string, Config_Element>&
config,
guess_type initial_guess_in=
CLOSE_TO_ZERO,
int accelerator_num ) :
Optimization_Interface(Umtx_in, qbit_num_in, optimize_layer_num_in, config, initial_guess_in, accelerator_num) {
98 std::stringstream sstream;
99 sstream <<
"***************************************************************" << std::endl;
100 sstream <<
"Starting to disentangle " <<
qbit_num <<
"-qubit matrix via custom gate structure" << std::endl;
101 sstream <<
"***************************************************************" << std::endl << std::endl << std::endl;
107 #if BLAS==0 // undefined BLAS 112 MKL_Set_Num_Threads(1);
113 #elif BLAS==2 //OpenBLAS 115 openblas_set_num_threads(1);
119 tbb::tick_count
start_time = tbb::tick_count::now();
147 for(
auto it=gate_nums.begin(); it != gate_nums.end(); it++ ) {
148 sstream << it->second <<
" " << it->first <<
" gates" << std::endl;
152 sstream << std::endl;
153 tbb::tick_count current_time = tbb::tick_count::now();
155 sstream <<
"--- In total " << (current_time -
start_time).seconds() <<
" seconds elapsed during the decomposition ---" << std::endl;
160 #if BLAS==0 // undefined BLAS 164 #elif BLAS==2 //OpenBLAS void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
virtual ~N_Qubit_Decomposition_custom()
Destructor of the class.
void set_optimizer(optimization_aglorithms alg_in)
Call to set the optimizer engine to be used in solving the optimization problem.
std::map< std::string, int > get_gate_nums()
Call to get the number of the individual gate types in the list of gates.
N_Qubit_Decomposition_custom()
Nullary constructor of the class.
double optimization_problem(double *parameters)
Evaluate the optimization problem of the optimization.
int layer_num
number of gate layers
virtual void apply_to(Matrix_real ¶meters_mtx, Matrix &input, int parallel=0)
Call to apply the gate on the input array/matrix Gates_block*input.
int max_outer_iterations
Maximal number of iterations allowed in the optimization process.
int accelerator_num
number of utilized accelerators
A base class to determine the decomposition of an N-qubit unitary into a sequence of CNOT and U3 gate...
int num_threads
Store the number of OpenMP threads. (During the calculations OpenMP multithreading is turned off...
Class to store data of complex arrays and its properties.
void calc_decomposition_error(Matrix &decomposed_matrix)
Calculate the error of the decomposition according to the spectral norm of , where is the unitary pr...
int size() const
Call to get the number of the allocated elements.
void omp_set_num_threads(int num_threads)
Set the number of threads on runtime in MKL.
guess_type
Type definition of the types of the initial guess.
std::map< std::string, Config_Element > config
config metadata utilized during the optimization
virtual void start_decomposition()
Start the disentanglig process of the unitary.
Header file for the paralleized calculation of the cost function of the final optimization problem (s...
Matrix Umtx
The unitary to be decomposed.
Matrix copy()
Call to create a copy of the matrix.
void final_optimization()
final optimization procedure improving the accuracy of the decompositin when all the qubits were alre...
int qbit_num
number of qubits spanning the matrix of the operation
double decomposition_error
error of the final decomposition
Matrix_real optimized_parameters_mtx
The optimized parameters for the gates.
int omp_get_max_threads()
get the number of threads in MKL