Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
CRX.cpp
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright 2020 Peter Rakyta, Ph.D.
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 
17 @author: Peter Rakyta, Ph.D.
18 */
23 #include "CRX.h"
24 
25 
26 
27 //static tbb::spin_mutex my_mutex;
31 CRX::CRX() : RX() {
32 
33  // A string labeling the gate operation
34  name = "CRX";
35 
36  // A string describing the type of the gate
38 
39 }
40 
41 
42 
51 CRX::CRX(int qbit_num_in, int target_qbit_in, int control_qbit_in) : RX(qbit_num_in, target_qbit_in) {
52 
53  // A string labeling the gate operation
54  name = "CRX";
55 
56  // A string describing the type of the gate
58 
59 
60  if (control_qbit_in >= qbit_num) {
61  std::stringstream sstream;
62  sstream << "The index of the control qubit is larger than the number of qubits in CRX gate." << std::endl;
63  print(sstream, 0);
64  throw sstream.str();
65  }
66 
67  // The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled gates
68  control_qbit = control_qbit_in;
69 
70 
71 }
72 
77 
78 }
79 
80 
81 
82 
83 
84 
85 
86 
87 
93 
94  CRX* ret = new CRX(qbit_num, target_qbit, control_qbit);
95 
97  ret->set_parents( parents );
98  ret->set_children( children );
99 
100  return ret;
101 
102 }
103 
104 
std::vector< Gate * > parents
list of parent gates to be applied in the circuit prior to this current gate
Definition: Gate.h:112
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
Definition: logging.cpp:55
A class representing a controlled RX gate.
Definition: CRX.h:35
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations...
Definition: Gate.h:100
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
Header file for a class representing a controlled X rotation gate.
~CRX() override
Destructor of the class.
Definition: CRX.cpp:76
virtual CRX * clone() override
Call to create a clone of the present class.
Definition: CRX.cpp:92
gate_type type
The type of the operation (see enumeration gate_type)
Definition: Gate.h:96
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
std::string name
A string labeling the gate operation.
Definition: Gate.h:92
std::vector< Gate * > children
list of child gates to be applied after this current gate
Definition: Gate.h:114
void set_parents(std::vector< Gate *> &parents_)
Call to set the parents of the current gate.
Definition: Gate.cpp:2511
CRX()
Nullary constructor of the class.
Definition: CRX.cpp:31
int qbit_num
number of qubits spanning the matrix of the operation
Definition: Gate.h:94
Definition: RX.h:11