6 R::R(
int qbit_num_in,
int target_qbit_in) :
U3(qbit_num_in, target_qbit_in) {
28 const int theta_offset = 0 * precomputed_sincos.
stride;
29 const int phi_offset = 1 * precomputed_sincos.
stride;
30 const double s_theta = precomputed_sincos[theta_offset + 0];
31 const double c_theta = precomputed_sincos[theta_offset + 1];
32 const double s_phi = precomputed_sincos[phi_offset + 0];
33 const double c_phi = precomputed_sincos[phi_offset + 1];
34 return r_gate_kernel_from_trig<Matrix, double>(s_theta, c_theta, s_phi, c_phi);
38 const int theta_offset = 0 * precomputed_sincos.
stride;
39 const int phi_offset = 1 * precomputed_sincos.
stride;
40 const float s_theta = precomputed_sincos[theta_offset + 0];
41 const float c_theta = precomputed_sincos[theta_offset + 1];
42 const float s_phi = precomputed_sincos[phi_offset + 0];
43 const float c_phi = precomputed_sincos[phi_offset + 1];
44 return r_gate_kernel_from_trig<Matrix_float, float>(s_theta, c_theta, s_phi, c_phi);
48 const int theta_offset = 0 * precomputed_sincos.
stride;
49 const int phi_offset = 1 * precomputed_sincos.
stride;
50 const double s_theta = precomputed_sincos[theta_offset + 0];
51 const double c_theta = precomputed_sincos[theta_offset + 1];
52 const double s_phi = precomputed_sincos[phi_offset + 0];
53 const double c_phi = precomputed_sincos[phi_offset + 1];
54 return r_inverse_gate_kernel_from_trig<Matrix, double>(s_theta, c_theta, s_phi, c_phi);
58 const int theta_offset = 0 * precomputed_sincos.
stride;
59 const int phi_offset = 1 * precomputed_sincos.
stride;
60 const float s_theta = precomputed_sincos[theta_offset + 0];
61 const float c_theta = precomputed_sincos[theta_offset + 1];
62 const float s_phi = precomputed_sincos[phi_offset + 0];
63 const float c_phi = precomputed_sincos[phi_offset + 1];
64 return r_inverse_gate_kernel_from_trig<Matrix_float, float>(s_theta, c_theta, s_phi, c_phi);
68 const int theta_offset = 0 * precomputed_sincos.
stride;
69 const int phi_offset = 1 * precomputed_sincos.
stride;
70 const double s_theta = precomputed_sincos[theta_offset + 0];
71 const double c_theta = precomputed_sincos[theta_offset + 1];
72 const double s_phi = precomputed_sincos[phi_offset + 0];
73 const double c_phi = precomputed_sincos[phi_offset + 1];
76 return r_derivative_kernel_theta_from_trig<Matrix, double>(s_theta, c_theta, s_phi, c_phi);
79 return r_derivative_kernel_phi_from_trig<Matrix, double>(s_theta, s_phi, c_phi);
86 const int theta_offset = 0 * precomputed_sincos.
stride;
87 const int phi_offset = 1 * precomputed_sincos.
stride;
88 const float s_theta = precomputed_sincos[theta_offset + 0];
89 const float c_theta = precomputed_sincos[theta_offset + 1];
90 const float s_phi = precomputed_sincos[phi_offset + 0];
91 const float c_phi = precomputed_sincos[phi_offset + 1];
94 return r_derivative_kernel_theta_from_trig<Matrix_float, float>(s_theta, c_theta, s_phi, c_phi);
97 return r_derivative_kernel_phi_from_trig<Matrix_float, float>(s_theta, s_phi, c_phi);
104 const int phi_offset = precomputed_sincos.
stride;
105 r_gate_kernel_from_trig_to<Matrix, double>(
107 precomputed_sincos[0],
108 precomputed_sincos[1],
109 precomputed_sincos[phi_offset + 0],
110 precomputed_sincos[phi_offset + 1]
115 const int phi_offset = precomputed_sincos.
stride;
116 r_gate_kernel_from_trig_to<Matrix_float, float>(
118 precomputed_sincos[0],
119 precomputed_sincos[1],
120 precomputed_sincos[phi_offset + 0],
121 precomputed_sincos[phi_offset + 1]
126 const int phi_offset = precomputed_sincos.
stride;
127 r_inverse_gate_kernel_from_trig_to<Matrix, double>(
129 precomputed_sincos[0],
130 precomputed_sincos[1],
131 precomputed_sincos[phi_offset + 0],
132 precomputed_sincos[phi_offset + 1]
137 const int phi_offset = precomputed_sincos.
stride;
138 r_inverse_gate_kernel_from_trig_to<Matrix_float, float>(
140 precomputed_sincos[0],
141 precomputed_sincos[1],
142 precomputed_sincos[phi_offset + 0],
143 precomputed_sincos[phi_offset + 1]
148 const int phi_offset = precomputed_sincos.
stride;
149 const double s_theta = precomputed_sincos[0];
150 const double c_theta = precomputed_sincos[1];
151 const double s_phi = precomputed_sincos[phi_offset + 0];
152 const double c_phi = precomputed_sincos[phi_offset + 1];
154 if (param_idx == 0) {
155 r_derivative_kernel_theta_from_trig_to<Matrix, double>(
output, s_theta, c_theta, s_phi, c_phi);
158 if (param_idx == 1) {
159 r_derivative_kernel_phi_from_trig_to<Matrix, double>(
output, s_theta, s_phi, c_phi);
166 const int phi_offset = precomputed_sincos.
stride;
167 const float s_theta = precomputed_sincos[0];
168 const float c_theta = precomputed_sincos[1];
169 const float s_phi = precomputed_sincos[phi_offset + 0];
170 const float c_phi = precomputed_sincos[phi_offset + 1];
172 if (param_idx == 0) {
173 r_derivative_kernel_theta_from_trig_to<Matrix_float, float>(
output, s_theta, c_theta, s_phi, c_phi);
176 if (param_idx == 1) {
177 r_derivative_kernel_phi_from_trig_to<Matrix_float, float>(
output, s_theta, s_phi, c_phi);
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.
virtual void derivative_kernel_to(const Matrix_real &precomputed_sincos, int param_idx, Matrix &output) override
Class to store single-precision real arrays and properties.
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations...
virtual Matrix gate_kernel(const Matrix_real &precomputed_sincos) override
Compute the gate kernel matrix from precomputed trigonometric values.
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 inverse_gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output) override
gate_type type
The type of the operation (see enumeration gate_type)
virtual R * clone() override
Call to create a clone of the present class.
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 ...
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
virtual void gate_kernel_to(const Matrix_real &precomputed_sincos, Matrix &output) override
virtual Matrix derivative_kernel(const Matrix_real &precomputed_sincos, int param_idx) 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
virtual Matrix inverse_gate_kernel(const Matrix_real &precomputed_sincos) override
Class to store data of complex arrays and its properties.
virtual std::vector< double > get_parameter_multipliers() const override
Returns the per-parameter multipliers relative to 2Ï used by extract_parameters. ...