128 apply_to(parameters, UN_matrix, parallel);
131 if (UN_matrix.
isnan()) {
132 std::stringstream sstream;
133 sstream <<
"U3::get_matrix: UN_matrix contains NaN." << std::endl;
151 std::string err(
"UN::apply_to: Wrong input size in UN gate apply");
156 std::stringstream sstream;
157 sstream <<
"Not enough parameters given for the UN gate" << std::endl;
170 Matrix Transformed_Block0 =
dot( Umtx, Block0 );
171 Matrix Transformed_Block1 =
dot( Umtx, Block1 );
174 memcpy( input.
get_data(), Transformed_Block0.get_data(), Transformed_Block0.size()*
sizeof(
QGD_Complex16) );
189 std::stringstream sstream;
190 sstream <<
"Wrong matrix size in UN gate apply" << std::endl;
196 std::stringstream sstream;
197 sstream <<
"Not enough parameters given for the UN gate" << std::endl;
210 Matrix Transformed_Block0 =
dot( Block0, Umtx );
211 Matrix Transformed_Block1 =
dot( Block1, Umtx );
214 for (
int row_idx=0; row_idx<input.
rows; row_idx++) {
215 memcpy( input.
get_data()+row_idx*input.
stride, Transformed_Block0.get_data() + row_idx*Transformed_Block0.stride, Transformed_Block0.cols*
sizeof(
QGD_Complex16) );
230 double* vartheta = parameters.
get_data();
231 double* varphi = parameters.
get_data() + matrix_size_loc*(matrix_size_loc-1)/2;
232 double* varkappa = parameters.
get_data() + matrix_size_loc*(matrix_size_loc-1);
235 Matrix Umtx = ru.Construct_Unitary_Matrix( vartheta, varphi, varkappa );
249 if ((
int)qbit_list.size() !=
qbit_num ) {
250 std::stringstream sstream;
251 sstream <<
"Wrong number of qubits" << std::endl;
260 for (
int idx=0; idx<
qbit_num; idx++) {
262 target_qbit_new = qbit_num-1-idx;
265 control_qbit_new = qbit_num-1-idx;
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
bool isnan()
Call to check the array for NaN entries.
Matrix dot(Matrix &A, Matrix &B)
Call to calculate the product of two complex matrices by calling method zgemm3m from the CBLAS librar...
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
virtual ~UN()
Destructor of the class.
Matrix_real get_optimized_parameters()
Call to get the final optimized parameters of the gate.
virtual Matrix get_matrix()
Call to retrieve the operation matrix.
Matrix_real parameters
Parameters theta, phi, lambda of the U3 gate after the decomposition of the unitary is done...
UN()
Default constructor of the class.
Matrix_real copy() const
Call to create a copy of the matrix.
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations...
int stride
The column stride of the array. (The array elements in one row are a_0, a_1, ... a_{cols-1}, 0, 0, 0, 0. The number of zeros is stride-cols)
void set_children(std::vector< Gate *> &children_)
Call to set the children of the current gate.
virtual void set_qbit_num(int qbit_num_in)
Set the number of qubits spanning the matrix of the operation.
virtual void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operation.
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
void apply_from_right(Matrix_real ¶meters, Matrix &input)
Call to apply the gate on the input array/matrix by input*Gate.
UN * clone()
Call to create a clone of the present class.
int matrix_size
The size N of the NxN matrix associated with the operations.
scalar * get_data() const
Call to get the pointer to the stored data.
int get_parameter_num()
Call to get the number of free parameters.
gate_type type
The type of the operation (see enumeration gate_type)
int rows
The number of rows.
int cols
The number of columns.
Umtx
The unitary to be decomposed.
Header file for a class for the representation of general gate operations on the first qbit_num-1 qub...
void set_parameter_start_idx(int start_idx)
Call to set the starting index of the parameters in the parameter array corresponding to the circuit ...
int get_parameter_start_idx()
Call to get the starting index of the parameters in the parameter array corresponding to the circuit ...
Structure type representing complex numbers in the SQUANDER package.
int Power_of_2(int n)
Calculates the n-th power of 2.
Class to store data of complex arrays and its properties.
int size() const
Call to get the number of the allocated elements.
A class to cerate general random unitary matrix according to arXiv:1303:5904v1.
std::string name
A string labeling the gate operation.
void apply_to(Matrix_real ¶meters, Matrix &input, int parallel)
Call to apply the gate on the input array/matrix.
std::vector< Gate * > children
list of child gates to be applied after this current gate
void set_optimized_parameters(Matrix_real parameters_)
Call to set the final optimized parameters of the gate.
Base class for the representation of general gate operations.
Matrix create_identity(int matrix_size)
Call to create an identity matrix.
int parameter_num
the number of free parameters of the operation
Matrix get_submatrix(Matrix_real ¶meters)
Call to retrieve the qbit_num-1 kernel of the UN gate.
Header file for commonly used functions and wrappers to CBLAS functions.
gate_type get_type()
Call to get the type of the operation.
void set_parents(std::vector< Gate *> &parents_)
Call to set the parents of the current gate.
int qbit_num
number of qubits spanning the matrix of the operation
int get_qbit_num()
Call to get the number of qubits composing the unitary.
gate_type
Type definition of operation types (also generalized for decomposition classes derived from the class...
Class to store data of complex arrays and its properties.