Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
X.cpp
Go to the documentation of this file.
2 #include "X.h"
3 
4 X::X() : X(-1, -1) {}
5 
6 X::X(int qbit_num_in, int target_qbit_in) : U3(qbit_num_in, target_qbit_in) {
7  name = "X";
9  parameter_num = 0;
10  control_qbit = -1;
11 }
12 
13 X::~X() {}
14 
15 X* X::clone() {
16  X* ret = new X(qbit_num, target_qbit);
18  ret->set_parents(parents);
19  ret->set_children(children);
20  return ret;
21 }
22 
23 Matrix X::gate_kernel(const Matrix_real& /*parameters*/) {
24  return x_gate_kernel<Matrix, double>();
25 }
26 
28  return x_gate_kernel<Matrix_float, float>();
29 }
30 
31 Matrix X::inverse_gate_kernel(const Matrix_real& /*parameters*/) {
32  return x_gate_kernel<Matrix, double>();
33 }
34 
36  return x_gate_kernel<Matrix_float, float>();
37 }
38 
39 void X::gate_kernel_to(const Matrix_real& /*parameters*/, Matrix& output) {
40  x_gate_kernel_to<Matrix, double>(output);
41 }
42 
43 void X::gate_kernel_to(const Matrix_real_float& /*parameters*/, Matrix_float& output) {
44  x_gate_kernel_to<Matrix_float, float>(output);
45 }
46 
47 void X::inverse_gate_kernel_to(const Matrix_real& /*parameters*/, Matrix& output) {
48  x_gate_kernel_to<Matrix, double>(output);
49 }
50 
52  x_gate_kernel_to<Matrix_float, float>(output);
53 }
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
Definition: Gate.h:112
Copyright (C) Miklos Maroti, 2021 SPDX-License-Identifier: Apache-2.0.
Definition: U3.h:19
Definition: X.h:11
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...
Definition: Gate.h:100
X()
Definition: X.cpp:4
void set_children(std::vector< Gate *> &children_)
Call to set the children of the current gate.
Definition: Gate.cpp:2523
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
Definition: Gate.h:98
gate_type type
The type of the operation (see enumeration gate_type)
Definition: Gate.h:96
~X() override
Definition: X.cpp:13
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 ...
Definition: Gate.cpp:2500
int get_parameter_start_idx()
Call to get the starting index of the parameters in the parameter array corresponding to the circuit ...
Definition: Gate.cpp:2535
virtual Matrix gate_kernel(const Matrix_real &parameters) override
Compute the gate kernel matrix from precomputed trigonometric values.
Definition: X.cpp:23
virtual X * clone() override
Call to create a clone of the present class.
Definition: X.cpp:15
Double-precision complex matrix (float64).
Definition: matrix.h:38
std::string name
A string labeling the gate operation.
Definition: Gate.h:92
Single-precision complex matrix (float32).
Definition: matrix_float.h:41
std::vector< Gate * > children
list of child gates to be applied after this current gate
Definition: Gate.h:114
int parameter_num
the number of free parameters of the operation
Definition: Gate.h:108
void set_parents(std::vector< Gate *> &parents_)
Call to set the parents of the current gate.
Definition: Gate.cpp:2511
virtual void gate_kernel_to(const Matrix_real &parameters, Matrix &output) override
Definition: X.cpp:39
virtual Matrix inverse_gate_kernel(const Matrix_real &parameters) override
Definition: X.cpp:31
virtual void inverse_gate_kernel_to(const Matrix_real &parameters, Matrix &output) override
Definition: X.cpp:47
int qbit_num
number of qubits spanning the matrix of the operation
Definition: Gate.h:94
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:41