48 CSWAP::CSWAP(
int qbit_num_in,
const std::vector<int>& target_qbits_in,
const std::vector<int>& control_qbits_in)
49 :
SWAP(qbit_num_in, target_qbits_in) {
58 if (control_qbits_in.size() != 1) {
59 std::stringstream sstream;
60 sstream <<
"CSWAP gate requires exactly 1 control qubit, got " << control_qbits_in.size() << std::endl;
66 if (control_qbits_in[0] >= qbit_num_in) {
67 std::stringstream sstream;
68 sstream <<
"Control qubit index " << control_qbits_in[0] <<
" is larger than or equal to the number of qubits" << std::endl;
74 for (
int tq : target_qbits_in) {
75 if (control_qbits_in[0] == tq) {
76 std::stringstream sstream;
77 sstream <<
"The control qubit cannot be the same as any target qubit" << std::endl;
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
Header file for a class representing a CSWAP (Controlled SWAP) operation.
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
std::vector< int > target_qbits
Vector of target qubit indices (for multi-qubit gates)
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations...
~CSWAP() override
Destructor of the class.
void set_children(std::vector< Gate *> &children_)
Call to set the children of the current gate.
A class representing a SWAP operation.
gate_type type
The type of the operation (see enumeration gate_type)
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 CSWAP * clone() override
Call to create a clone of the present class.
CSWAP()
Nullary constructor of the class.
std::vector< int > control_qbits
Vector of control qubit indices (for multi-qubit gates)
std::string name
A string labeling the gate operation.
std::vector< Gate * > children
list of child gates to be applied after this current gate
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
A class representing a CSWAP (Controlled SWAP) operation.