49 SWAP::SWAP(
int qbit_num_in,
const std::vector<int>& target_qbits_in)
50 :
Gate(qbit_num_in, target_qbits_in) {
59 if (target_qbits_in.size() != 2) {
60 std::stringstream sstream;
61 sstream <<
"SWAP gate requires exactly 2 target qubits, got " << target_qbits_in.size() << std::endl;
67 if (target_qbits_in[0] == target_qbits_in[1]) {
68 std::stringstream sstream;
69 sstream <<
"The two target qubits cannot be the same" << std::endl;
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
Gate()
Default constructor of the class.
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)
void set_children(std::vector< Gate *> &children_)
Call to set the children of the current gate.
Header file for a class representing a SWAP operation.
A class representing a SWAP operation.
SWAP()
Nullary constructor of the class.
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 ...
std::string name
A string labeling the gate operation.
std::vector< Gate * > children
list of child gates to be applied after this current gate
~SWAP() override
Destructor of the class.
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.
virtual SWAP * clone() override
Call to create a clone of the present class.
int qbit_num
number of qubits spanning the matrix of the operation