-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefinitions.hpp
More file actions
72 lines (56 loc) · 2.19 KB
/
Definitions.hpp
File metadata and controls
72 lines (56 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include "operations/Expression.hpp"
#include <bitset>
#include <deque>
#include <map>
#include <memory>
#include <utility>
#include <variant>
#include <vector>
#include <limits>
namespace qc {
class QFRException : public std::invalid_argument {
std::string msg;
public:
explicit QFRException(std::string m)
: std::invalid_argument("QFR Exception"), msg(std::move(m)) {}
[[nodiscard]] const char* what() const noexcept override {
return msg.c_str();
}
};
using Qubit = std::uint32_t;
using Bit = std::uint64_t;
template <class IdxType, class SizeType>
using Register = std::pair<IdxType, SizeType>;
using QuantumRegister = Register<Qubit, std::size_t>;
using ClassicalRegister = Register<Bit, std::size_t>;
template <class RegisterType>
using RegisterMap = std::map<std::string, RegisterType, std::greater<>>;
using QuantumRegisterMap = RegisterMap<QuantumRegister>;
using ClassicalRegisterMap = RegisterMap<ClassicalRegister>;
using RegisterNames = std::vector<std::pair<std::string, std::string>>;
using Targets = std::vector<Qubit>;
using BitString = std::bitset<128>;
// floating-point type used throughout the library
using fp = double;
static inline fp PARAMETER_TOLERANCE = pow(2.0, -48.0);//0.00000381469726563f;//1e-13;
static constexpr fp PI = static_cast<fp>(
3.141592653589793238462643383279502884197169399375105820974L);
static constexpr fp PI_2 = static_cast<fp>(
1.570796326794896619231321691639751442098584699687552910487L);
static constexpr fp PI_4 = static_cast<fp>(
0.785398163397448309615660845819875721049292349843776455243L);
// forward declaration
class Operation;
// supported file formats
enum class Format { Real, OpenQASM, GRCS, TFC, QC, Tensor };
using DAG = std::vector<std::deque<std::unique_ptr<Operation>*>>;
using DAGIterator = std::deque<std::unique_ptr<Operation>*>::iterator;
using DAGReverseIterator =
std::deque<std::unique_ptr<Operation>*>::reverse_iterator;
using DAGIterators = std::vector<DAGIterator>;
using DAGReverseIterators = std::vector<DAGReverseIterator>;
using Symbolic = sym::Expression<fp, fp>;
using VariableAssignment = std::unordered_map<sym::Variable, fp>;
using SymbolOrNumber = std::variant<Symbolic, fp>;
} // namespace qc