66 CH::CH(
int qbit_num_in,
int target_qbit_in,
int control_qbit_in) {
85 std::stringstream sstream;
86 sstream <<
"The index of the target qubit is larger than the number of qubits" << std::endl;
96 std::stringstream sstream;
97 sstream <<
"The index of the control qubit is larger than the number of qubits" << std::endl;
121 return get_matrix(
false );
150 std::string err(
"CH::apply_to: Wrong input size in CH gate apply.");
154 Matrix u3_1qbit = calc_one_qubit_u3();
155 apply_kernel_to(u3_1qbit, input,
false, parallel);
169 Matrix u3_1qbit = calc_one_qubit_u3();
170 apply_kernel_from_right(u3_1qbit, input);
208 u3_1qbit[0].real = 1.0/sqrt(2); u3_1qbit[0].imag = 0.0;
209 u3_1qbit[1].real = 1.0/sqrt(2); u3_1qbit[1].imag = 0.0;
210 u3_1qbit[2].real = 1.0/sqrt(2); u3_1qbit[2].imag = 0.0;
211 u3_1qbit[3].real = -1.0/sqrt(2);u3_1qbit[3].imag = 0.0;
225 ret->set_parameter_start_idx( get_parameter_start_idx() );
226 ret->set_parents( parents );
227 ret->set_children( children );
parameter_num
[set adaptive gate structure]
CH * clone()
Call to create a clone of the present class.
virtual void set_qbit_num(int qbit_num_in)
Set the number of qubits spanning the matrix of the operation.
Header file for a class representing a CH operation.
void set_qbit_num(int qbit_num)
Call to set the number of qubits spanning the matrix of the operation.
int rows
The number of rows.
Matrix calc_one_qubit_u3()
Set static values for matrix of the gates.
void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operation.
~CH()
Destructor of the class.
Matrix get_matrix()
Call to retrieve the operation matrix.
def apply_to(self, parameters_mtx, unitary_mtx, parallel=1)
void apply_from_right(Matrix &input)
Call to apply the gate on the input array/matrix by input*CH.
int Power_of_2(int n)
Calculates the n-th power of 2.
Class to store data of complex arrays and its properties.
Matrix create_identity(int matrix_size)
Call to create an identity matrix.
virtual void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operation.
void apply_to(Matrix &input, int parallel)
Call to apply the gate on the input array/matrix CH*input.
CH()
Nullary constructor of the class.