Quantum Gate Decomposer  v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
Operation.h
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright (C) 2020 Peter Rakyta, Ph.D.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see http://www.gnu.org/licenses/.
17 
18 @author: Peter Rakyta, Ph.D.
19 */
24 #ifndef OPERATION_H
25 #define OPERATION_H
26 
27 #include <vector>
28 #include "qgd/common.h"
29 #include "qgd/matrix.h"
30 
31 
34 
35 
36 
40 class Operation {
41 
42 
43 protected:
44 
46  int qbit_num;
56  unsigned int parameter_num;
57 
58 private:
59 
62 
63 public:
64 
69 Operation();
70 
74 virtual ~Operation();
75 
76 
82 Operation(int qbit_num_in);
83 
89 
95 void set_matrix( Matrix input );
96 
97 
102 virtual void set_qbit_num( int qbit_num_in );
103 
108 virtual void reorder_qubits( std::vector<int> qbit_list );
109 
110 
115 int get_target_qbit();
116 
117 
122 int get_control_qbit();
123 
124 
129 unsigned int get_parameter_num();
130 
131 
137 
142 int get_qbit_num();
143 
148 Operation* clone();
149 
150 };
151 
152 
153 #endif //OPERATION
Operation * clone()
Call to create a clone of the present class.
Definition: Operation.cpp:192
Base class for the representation of one- and two-qubit operations.
Definition: Operation.h:40
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
Definition: Operation.h:50
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations.
Definition: Operation.h:52
Operation()
Default constructor of the class.
Definition: Operation.cpp:32
int get_target_qbit()
Call to get the index of the target qubit.
Definition: Operation.cpp:149
Matrix matrix_alloc
Matrix of the operation.
Definition: Operation.h:61
int matrix_size
The size N of the NxN matrix associated with the operations.
Definition: Operation.h:54
virtual void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operation.
Definition: Operation.cpp:118
operation_type type
The type of the operation (see enumeration operation_type)
Definition: Operation.h:48
int get_qbit_num()
Call to get the number of qubits composing the unitary.
Definition: Operation.cpp:183
virtual ~Operation()
Destructor of the class.
Definition: Operation.cpp:75
int qbit_num
number of qubits spanning the matrix of the operation
Definition: Operation.h:46
unsigned int parameter_num
the number of free parameters of the operation
Definition: Operation.h:56
Matrix get_matrix()
Call to retrieve the operation matrix.
Definition: Operation.cpp:97
Class to store data of complex arrays and its properties.
Definition: matrix.h:12
unsigned int get_parameter_num()
Call to get the number of free parameters.
Definition: Operation.cpp:165
void set_matrix(Matrix input)
Call to set the stored matrix in the operation.
Definition: Operation.cpp:109
operation_type get_type()
Call to get the type of the operation.
Definition: Operation.cpp:174
virtual void set_qbit_num(int qbit_num_in)
Set the number of qubits spanning the matrix of the operation.
Definition: Operation.cpp:82
Header file for commonly used functions and wrappers to CBLAS functions.
int get_control_qbit()
Call to get the index of the control qubit.
Definition: Operation.cpp:157
operation_type
Type definition of operation types (also generalized for decomposition classes derived from the class...
Definition: Operation.h:33