51 CCX::CCX(
int qbit_num_in,
int target_qbit_in,
const std::vector<int>& control_qbits_in)
52 :
Gate(qbit_num_in,
std::vector<
int>{target_qbit_in}, control_qbits_in) {
61 if (control_qbits_in.size() != 2) {
62 std::stringstream sstream;
63 sstream <<
"CCX gate requires exactly 2 control qubits, got " << control_qbits_in.size() << std::endl;
69 if (control_qbits_in[0] == control_qbits_in[1]) {
70 std::stringstream sstream;
71 sstream <<
"The two control 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.
A class representing a CCX (Toffoli) operation.
~CCX() override
Destructor of the class.
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)
Header file for a class representing a CCX (Toffoli) operation.
CCX()
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::vector< int > control_qbits
Vector of control qubit indices (for multi-qubit gates)
virtual CCX * clone() override
Call to create a clone of the present class.
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