49 RZZ::RZZ(
int qbit_num_in,
const std::vector<int>& target_qbits_in)
50 :
Gate(qbit_num_in, target_qbits_in) {
59 if (target_qbits_in.size() != 2) {
60 std::stringstream sstream;
61 sstream <<
"RZZ gate requires exactly 2 target qubits, got " << target_qbits_in.size() << std::endl;
67 if (target_qbits_in[0] == target_qbits_in[1]) {
68 std::stringstream sstream;
69 sstream <<
"The two target qubits cannot be the same" << std::endl;
121 const int theta_offset = 0 * precomputed_sincos.
stride;
122 const double s_theta = precomputed_sincos[theta_offset + 0];
123 const double c_theta = precomputed_sincos[theta_offset + 1];
124 build_rzz_kernel_from_trig_to<Matrix, double>(
output, s_theta, c_theta);
128 const int theta_offset = 0 * precomputed_sincos.
stride;
129 const float s_theta = precomputed_sincos[theta_offset + 0];
130 const float c_theta = precomputed_sincos[theta_offset + 1];
131 build_rzz_kernel_from_trig_to<Matrix_float, float>(
output, s_theta, c_theta);
135 const int theta_offset = 0 * precomputed_sincos.
stride;
136 const double s_theta = precomputed_sincos[theta_offset + 0];
137 const double c_theta = precomputed_sincos[theta_offset + 1];
138 build_rzz_kernel_from_trig_to<Matrix, double>(
output, -s_theta, c_theta);
142 const int theta_offset = 0 * precomputed_sincos.
stride;
143 const float s_theta = precomputed_sincos[theta_offset + 0];
144 const float c_theta = precomputed_sincos[theta_offset + 1];
145 build_rzz_kernel_from_trig_to<Matrix_float, float>(
output, -s_theta, c_theta);
149 if (param_idx != 0) {
153 const int theta_offset = 0 * precomputed_sincos.
stride;
154 const double s_theta = precomputed_sincos[theta_offset + 0];
155 const double c_theta = precomputed_sincos[theta_offset + 1];
156 build_rzz_derivative_kernel_from_trig_to<Matrix, double>(
output, s_theta, c_theta);
160 if (param_idx != 0) {
164 const int theta_offset = 0 * precomputed_sincos.
stride;
165 const float s_theta = precomputed_sincos[theta_offset + 0];
166 const float c_theta = precomputed_sincos[theta_offset + 1];
167 build_rzz_derivative_kernel_from_trig_to<Matrix_float, float>(
output, s_theta, c_theta);
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
Gate()
Default constructor of the class.
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
Class to store single-precision real arrays and properties.
~RZZ()
Destructor of the class.
std::vector< int > target_qbits
Vector of target qubit indices (for multi-qubit gates)
Matrix derivative_kernel(const Matrix_real &precomputed_sincos, int param_idx) override
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.
Class representing a RZZ gate.
RZZ()
Nullary constructor of the class.
std::vector< double > get_parameter_multipliers() const override
Call to extract parameters from the parameter array corresponding to the circuit, in which the gate i...
gate_type type
The type of the operation (see enumeration gate_type)
Matrix gate_kernel(const Matrix_real &precomputed_sincos) override
Build and return the 4x4 RZZ unitary for the given parameter.
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 ...
A class representing a RZZ gate.
Double-precision complex matrix (float64).
RZZ * clone() override
Call to create a clone of the present class.
std::string name
A string labeling the gate operation.
Single-precision complex matrix (float32).
void inverse_gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output) override
std::vector< Gate * > children
list of child gates to be applied after this current gate
void derivative_kernel_to(const Matrix_real &precomputed_sincos, int param_idx, Matrix &output) override
void gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output) override
int parameter_num
the number of free parameters 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
Matrix inverse_gate_kernel(const Matrix_real &precomputed_sincos) override
Class to store data of complex arrays and its properties.