8 U2::U2(
int qbit_num_in,
int target_qbit_in) :
U3(qbit_num_in, target_qbit_in) {
30 const int phi_offset = 0 * precomputed_sincos.
stride;
31 const int lambda_offset = 1 * precomputed_sincos.
stride;
32 const double s_phi = precomputed_sincos[phi_offset + 0];
33 const double c_phi = precomputed_sincos[phi_offset + 1];
34 const double s_lambda = precomputed_sincos[lambda_offset + 0];
35 const double c_lambda = precomputed_sincos[lambda_offset + 1];
36 return u2_gate_kernel_from_trig<Matrix, double>(s_phi, c_phi, s_lambda, c_lambda);
40 const int phi_offset = 0 * precomputed_sincos.
stride;
41 const int lambda_offset = 1 * precomputed_sincos.
stride;
42 const float s_phi = precomputed_sincos[phi_offset + 0];
43 const float c_phi = precomputed_sincos[phi_offset + 1];
44 const float s_lambda = precomputed_sincos[lambda_offset + 0];
45 const float c_lambda = precomputed_sincos[lambda_offset + 1];
46 return u2_gate_kernel_from_trig<Matrix_float, float>(s_phi, c_phi, s_lambda, c_lambda);
50 const int phi_offset = 0 * precomputed_sincos.
stride;
51 const int lambda_offset = 1 * precomputed_sincos.
stride;
52 const double s_phi = precomputed_sincos[phi_offset + 0];
53 const double c_phi = precomputed_sincos[phi_offset + 1];
54 const double s_lambda = precomputed_sincos[lambda_offset + 0];
55 const double c_lambda = precomputed_sincos[lambda_offset + 1];
56 return u2_inverse_gate_kernel_from_trig<Matrix, double>(s_phi, c_phi, s_lambda, c_lambda);
60 const int phi_offset = 0 * precomputed_sincos.
stride;
61 const int lambda_offset = 1 * precomputed_sincos.
stride;
62 const float s_phi = precomputed_sincos[phi_offset + 0];
63 const float c_phi = precomputed_sincos[phi_offset + 1];
64 const float s_lambda = precomputed_sincos[lambda_offset + 0];
65 const float c_lambda = precomputed_sincos[lambda_offset + 1];
66 return u2_inverse_gate_kernel_from_trig<Matrix_float, float>(s_phi, c_phi, s_lambda, c_lambda);
70 const int phi_offset = 0 * precomputed_sincos.
stride;
71 const int lambda_offset = 1 * precomputed_sincos.
stride;
72 const double s_phi = precomputed_sincos[phi_offset + 0];
73 const double c_phi = precomputed_sincos[phi_offset + 1];
74 const double s_lambda = precomputed_sincos[lambda_offset + 0];
75 const double c_lambda = precomputed_sincos[lambda_offset + 1];
78 return u2_derivative_kernel_phi_from_trig<Matrix, double>(s_phi, c_phi, s_lambda, c_lambda);
81 return u2_derivative_kernel_lambda_from_trig<Matrix, double>(s_phi, c_phi, s_lambda, c_lambda);
88 const int phi_offset = 0 * precomputed_sincos.
stride;
89 const int lambda_offset = 1 * precomputed_sincos.
stride;
90 const float s_phi = precomputed_sincos[phi_offset + 0];
91 const float c_phi = precomputed_sincos[phi_offset + 1];
92 const float s_lambda = precomputed_sincos[lambda_offset + 0];
93 const float c_lambda = precomputed_sincos[lambda_offset + 1];
96 return u2_derivative_kernel_phi_from_trig<Matrix_float, float>(s_phi, c_phi, s_lambda, c_lambda);
99 return u2_derivative_kernel_lambda_from_trig<Matrix_float, float>(s_phi, c_phi, s_lambda, c_lambda);
106 const int lambda_offset = precomputed_sincos.
stride;
107 u2_gate_kernel_from_trig_to<Matrix, double>(
109 precomputed_sincos[0],
110 precomputed_sincos[1],
111 precomputed_sincos[lambda_offset + 0],
112 precomputed_sincos[lambda_offset + 1]
117 const int lambda_offset = precomputed_sincos.
stride;
118 u2_gate_kernel_from_trig_to<Matrix_float, float>(
120 precomputed_sincos[0],
121 precomputed_sincos[1],
122 precomputed_sincos[lambda_offset + 0],
123 precomputed_sincos[lambda_offset + 1]
128 const int lambda_offset = precomputed_sincos.
stride;
129 u2_inverse_gate_kernel_from_trig_to<Matrix, double>(
131 precomputed_sincos[0],
132 precomputed_sincos[1],
133 precomputed_sincos[lambda_offset + 0],
134 precomputed_sincos[lambda_offset + 1]
139 const int lambda_offset = precomputed_sincos.
stride;
140 u2_inverse_gate_kernel_from_trig_to<Matrix_float, float>(
142 precomputed_sincos[0],
143 precomputed_sincos[1],
144 precomputed_sincos[lambda_offset + 0],
145 precomputed_sincos[lambda_offset + 1]
150 const int lambda_offset = precomputed_sincos.
stride;
151 const double s_phi = precomputed_sincos[0];
152 const double c_phi = precomputed_sincos[1];
153 const double s_lambda = precomputed_sincos[lambda_offset + 0];
154 const double c_lambda = precomputed_sincos[lambda_offset + 1];
156 if (param_idx == 0) {
157 u2_derivative_kernel_phi_from_trig_to<Matrix, double>(
output, s_phi, c_phi, s_lambda, c_lambda);
160 if (param_idx == 1) {
161 u2_derivative_kernel_lambda_from_trig_to<Matrix, double>(
output, s_phi, c_phi, s_lambda, c_lambda);
168 const int lambda_offset = precomputed_sincos.
stride;
169 const float s_phi = precomputed_sincos[0];
170 const float c_phi = precomputed_sincos[1];
171 const float s_lambda = precomputed_sincos[lambda_offset + 0];
172 const float c_lambda = precomputed_sincos[lambda_offset + 1];
174 if (param_idx == 0) {
175 u2_derivative_kernel_phi_from_trig_to<Matrix_float, float>(
output, s_phi, c_phi, s_lambda, c_lambda);
178 if (param_idx == 1) {
179 u2_derivative_kernel_lambda_from_trig_to<Matrix_float, float>(
output, s_phi, c_phi, s_lambda, c_lambda);
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
Copyright (C) Miklos Maroti, 2021 SPDX-License-Identifier: Apache-2.0.
Class to store single-precision real arrays and properties.
virtual U2 * clone() override
Call to create a clone of the present class.
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.
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
virtual void gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output) override
gate_type type
The type of the operation (see enumeration gate_type)
static const double M_PIOver4
virtual Matrix inverse_gate_kernel(const Matrix_real &precomputed_sincos) override
virtual void inverse_gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output) override
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 ...
virtual void derivative_kernel_to(const Matrix_real &precomputed_sincos, int param_idx, Matrix &output) override
Double-precision complex matrix (float64).
std::string name
A string labeling the gate operation.
Single-precision complex matrix (float32).
std::vector< Gate * > children
list of child gates to be applied after this current gate
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
virtual Matrix gate_kernel(const Matrix_real &precomputed_sincos) override
Compute the gate kernel matrix from precomputed trigonometric values.
virtual std::vector< double > get_parameter_multipliers() const override
Returns the per-parameter multipliers relative to 2Ï used by extract_parameters. ...
Class to store data of complex arrays and its properties.
virtual Matrix derivative_kernel(const Matrix_real &precomputed_sincos, int param_idx) override