131 apply_to(parameters, ON_matrix, parallel);
134 if (ON_matrix.
isnan()) {
135 std::stringstream sstream;
136 sstream <<
"U3::get_matrix: ON_matrix contains NaN." << std::endl;
154 std::string err(
"ON::apply_to: Wrong input size in ON gate apply.");
159 std::stringstream sstream;
160 sstream <<
"Not enough parameters given for the ON gate" << std::endl;
173 Matrix Transformed_Block0 =
dot( Umtx, Block0 );
174 Matrix Transformed_Block1 =
dot( Umtx, Block1 );
177 memcpy( input.
get_data(), Transformed_Block0.get_data(), Transformed_Block0.size()*
sizeof(
QGD_Complex16) );
193 std::stringstream sstream;
194 sstream <<
"Wrong matrix size in ON gate apply" << std::endl;
200 std::stringstream sstream;
201 sstream <<
"Not enough parameters given for the ON gate" << std::endl;
214 Matrix Transformed_Block0 =
dot( Block0, Umtx );
215 Matrix Transformed_Block1 =
dot( Block1, Umtx );
218 for (
int row_idx=0; row_idx<input.
rows; row_idx++) {
219 memcpy( input.
get_data()+row_idx*input.
stride, Transformed_Block0.get_data() + row_idx*Transformed_Block0.stride, Transformed_Block0.cols*
sizeof(
QGD_Complex16) );
251 if ((
int)qbit_list.size() !=
qbit_num ) {
252 std::stringstream sstream;
253 sstream <<
"Wrong number of qubits" << std::endl;
263 for (
int idx=0; idx<
qbit_num; idx++) {
265 target_qbit_new = qbit_num-1-idx;
268 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...
virtual void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operation.
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
Matrix_real parameters
Parameters after the decomposition of the ONitary is done.
virtual Matrix get_matrix()
Call to retrieve the operation matrix.
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.
void apply_to(Matrix_real ¶meters, Matrix &input, int parallel)
Call to apply the gate on the input array/matrix.
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
ON()
Default constructor of the 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.
A class to cerate general random unitary matrix according to arXiv:1303:5904v1.
virtual void set_qbit_num(int qbit_num_in)
Set the number of qubits spanning the matrix of the operation.
gate_type type
The type of the operation (see enumeration gate_type)
int rows
The number of rows.
int cols
The number of columns.
virtual ~ON()
Destructor of the class.
Umtx
The unitary to be decomposed.
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 ...
Matrix Construct_Orthogonal_Matrix()
Call to create a random unitary.
int get_parameter_start_idx()
Call to get the starting index of the parameters in the parameter array corresponding to the circuit ...
gate_type get_type()
Call to get the type of the operation.
Structure type representing complex numbers in the SQUANDER package.
Matrix get_submatrix(Matrix_real ¶meters)
Call to retrieve the qbut_num-1 kernel of the operation.
int Power_of_2(int n)
Calculates the n-th power of 2.
Class to store data of complex arrays and its properties.
int get_parameter_num()
Call to get the number of free parameters.
int size() const
Call to get the number of the allocated elements.
std::string name
A string labeling the gate operation.
std::vector< Gate * > children
list of child gates to be applied after this current gate
Matrix create_identity(int matrix_size)
Call to create an identity matrix.
int parameter_num
the number of free parameters of the operation
Header file for commonly used functions and wrappers to CBLAS functions.
ON * clone()
Call to create a clone of the present class.
void apply_from_right(Matrix_real ¶meters, Matrix &input)
Call to apply the gate on the input array/matrix by input*Gate.
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
Header file for a class for the representation of general gate operations on the first qbit_num-1 qub...
gate_type
Type definition of operation types (also generalized for decomposition classes derived from the class...
Base class for the representation of general gate operations.
int get_qbit_num()
Call to get the number of qubits composing the ONitary.
void set_optimized_parameters(Matrix_real parameters_)
Call to set the final optimized parameters of the gate.
Class to store data of complex arrays and its properties.
Matrix_real get_optimized_parameters()
Call to get the final optimized parameters of the gate.