Quantum Gate Decomposer  v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
U3.h
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright (C) 2020 Peter Rakyta, Ph.D.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see http://www.gnu.org/licenses/.
17 
18 @author: Peter Rakyta, Ph.D.
19 */
24 #ifndef U3_H
25 #define U3_H
26 
27 #include "qgd/Operation.h"
28 #include "qgd/matrix.h"
29 #include <math.h>
30 
31 
35 class U3: public Operation {
36 
37 protected:
38 
44  bool theta;
46  bool phi;
48  bool lambda;
50  double* parameters;
51 
52 
53 
54 public:
63 U3(int qbit_num_in, int target_qbit_in, bool theta_in, bool phi_in, bool lambda_in);
64 
68 ~U3();
69 
75 Matrix get_matrix( const double* parameters );
76 
83 int composite_u3_Theta_Phi_Lambda(const double* parameters, Matrix& U3_matrix);
84 
91 int composite_u3_Phi_Lambda(const double* parameters, Matrix& U3_matrix);
92 
99 int composite_u3_Theta_Lambda(const double* parameters, Matrix& U3_matrix);
100 
107 int composite_u3_Theta_Phi(const double* parameters, Matrix& U3_matrix);
108 
115 int composite_u3_Lambda(const double* parameters, Matrix& U3_matrix);
116 
123 int composite_u3_Phi(const double* parameters, Matrix& U3_matrix);
124 
131 int composite_u3_Theta(const double* parameters, Matrix& U3_matrix );
132 
133 
141 QGD_Complex16* composite_u3(double Theta, double Phi, double Lambda );
142 
143 
152 int composite_u3(double Theta, double Phi, double Lambda, Matrix& U3_matrix );
153 
158 
163 void set_qbit_num(int qbit_num_in);
164 
165 
166 
171 void reorder_qubits( std::vector<int> qbit_list);
172 
177 bool is_theta_parameter();
178 
183 bool is_phi_parameter();
184 
189 bool is_lambda_parameter();
190 
191 
192 
200 Matrix calc_one_qubit_u3(double Theta, double Phi, double Lambda );
201 
202 
207 U3* clone();
208 
209 
216 void set_optimized_parameters(double Theta, double Phi, double Lambda );
217 
222 void get_optimized_parameters(double *parameters_in );
223 
224 };
225 
226 
227 #endif //U3
228 
A class representing a U3 operation.
Definition: U3.h:35
Base class for the representation of one- and two-qubit operations.
Definition: Operation.h:40
int composite_u3_Lambda(const double *parameters, Matrix &U3_matrix)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on the space...
Definition: U3.cpp:234
int composite_u3_Theta_Lambda(const double *parameters, Matrix &U3_matrix)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on the space...
Definition: U3.cpp:214
int * indexes_target_qubit_0
the base indices of the target qubit for state |0>
Definition: U3.h:40
void determine_base_indices()
Determine the base indices corresponding to the target qubit states |0> and |1>
Definition: U3.cpp:326
Header file for a class for the representation of one- and two-qubit operations.
void get_optimized_parameters(double *parameters_in)
Call to get the final optimized parameters of the operation.
Definition: U3.cpp:502
Matrix calc_one_qubit_u3(double Theta, double Phi, double Lambda)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on a single ...
Definition: U3.cpp:432
void set_optimized_parameters(double Theta, double Phi, double Lambda)
Call to set the final optimized parameters of the operation.
Definition: U3.cpp:483
int composite_u3_Theta_Phi_Lambda(const double *parameters, Matrix &U3_matrix)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on the space...
Definition: U3.cpp:194
bool is_theta_parameter()
Call to check whether theta is a free parameter of the gate.
Definition: U3.cpp:402
void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operation.
Definition: U3.cpp:387
U3 * clone()
Call to create a clone of the present class.
Definition: U3.cpp:462
int composite_u3_Phi_Lambda(const double *parameters, Matrix &U3_matrix)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on the space...
Definition: U3.cpp:204
U3(int qbit_num_in, int target_qbit_in, bool theta_in, bool phi_in, bool lambda_in)
Constructor of the class.
Definition: U3.cpp:36
QGD_Complex16 * composite_u3(double Theta, double Phi, double Lambda)
Calculate the matrix of a U3 gate operation corresponding corresponding to the given parameters actin...
Definition: U3.cpp:265
int composite_u3_Theta(const double *parameters, Matrix &U3_matrix)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on the space...
Definition: U3.cpp:254
bool phi
logical value indicating whether the matrix creation takes an argument phi
Definition: U3.h:46
int * indexes_target_qubit_1
the base indices of the target qubit for state |1>
Definition: U3.h:42
Structure type representing complex numbers in the QGD package.
Definition: QGDTypes.h:39
Matrix get_matrix()
Call to retrieve the operation matrix.
Definition: Operation.cpp:97
Class to store data of complex arrays and its properties.
Definition: matrix.h:12
bool theta
logical value indicating whether the matrix creation takes an argument theta
Definition: U3.h:44
~U3()
Destructor of the class.
Definition: U3.cpp:112
bool is_lambda_parameter()
Call to check whether Lambda is a free parameter of the gate.
Definition: U3.cpp:419
bool is_phi_parameter()
Call to check whether Phi is a free parameter of the gate.
Definition: U3.cpp:411
bool lambda
logical value indicating whether the matrix creation takes an argument lambda
Definition: U3.h:48
double * parameters
Parameters theta, phi, lambda of the U3 operation after the decomposition of the unitary is done.
Definition: U3.h:50
int composite_u3_Phi(const double *parameters, Matrix &U3_matrix)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on the space...
Definition: U3.cpp:244
void set_qbit_num(int qbit_num_in)
Call to set the number of qubits spanning the matrix of the operation.
Definition: U3.cpp:372
int composite_u3_Theta_Phi(const double *parameters, Matrix &U3_matrix)
Calculate the matrix of a U3 gate operation corresponding to the given parameters acting on the space...
Definition: U3.cpp:224