65 SYC::SYC(
int qbit_num_in,
int target_qbit_in,
int control_qbit_in) {
80 std::stringstream sstream;
81 sstream <<
"The index of the target qubit is larger than the number of qubits" << std::endl;
83 throw "The index of the target qubit is larger than the number of qubits";
91 std::stringstream sstream;
92 sstream <<
"The index of the control qubit is larger than the number of qubits" << std::endl;
94 throw "The index of the control qubit is larger than the number of qubits";
110 template<
typename MT,
typename CT,
typename RT>
111 MT build_syc_kernel_impl(
bool inverse) {
113 for (
int idx = 0; idx < m.size(); ++idx) {
117 m[0 * m.stride + 0].real =
static_cast<RT
>(1);
119 const RT i_sign = inverse ?
static_cast<RT
>(1) : static_cast<RT>(-1);
120 m[1 * m.stride + 2].imag = i_sign;
121 m[2 * m.stride + 1].imag = i_sign;
123 const RT phase_real =
static_cast<RT
>(std::sqrt(3.0) / 2.0);
124 const RT phase_imag = inverse ?
static_cast<RT
>(0.5) :
static_cast<RT
>(-0.5);
125 m[3 * m.stride + 3].real = phase_real;
126 m[3 * m.stride + 3].imag = phase_imag;
136 return build_syc_kernel_impl<Matrix, QGD_Complex16, double>(
false);
142 return build_syc_kernel_impl<Matrix_float, QGD_Complex8, float>(
false);
148 return build_syc_kernel_impl<Matrix, QGD_Complex16, double>(
true);
154 return build_syc_kernel_impl<Matrix_float, QGD_Complex8, float>(
true);
parameter_num
[set adaptive gate structure]
Class to store single-precision real arrays and properties.
void set_children(std::vector< Gate *> &children_)
Call to set the children of the current gate.
SYC()
Nullary constructor of the class.
Matrix inverse_gate_kernel(const Matrix_real &precomputed_sincos) 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 ...
~SYC()
Destructor of the class.
SYC * clone() override
Call to create a clone of the present class.
int Power_of_2(int n)
Calculates the n-th power of 2.
Double-precision complex matrix (float64).
Single-precision complex matrix (float32).
Matrix gate_kernel(const Matrix_real &precomputed_sincos) override
Return the fixed 4x4 SYC two-qubit kernel.
void set_parents(std::vector< Gate *> &parents_)
Call to set the parents of the current gate.
A class representing a SYC operation.
Class to store data of complex arrays and its properties.
Header file for a class representing a Sycamore gate.