Line |
Branch |
Decision |
Exec |
Source |
1 |
|
|
|
// Copyright 2019-2022 Cambridge Quantum Computing |
2 |
|
|
|
// |
3 |
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
4 |
|
|
|
// you may not use this file except in compliance with the License. |
5 |
|
|
|
// You may obtain a copy of the License at |
6 |
|
|
|
// |
7 |
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0 |
8 |
|
|
|
// |
9 |
|
|
|
// Unless required by applicable law or agreed to in writing, software |
10 |
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS, |
11 |
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 |
|
|
|
// See the License for the specific language governing permissions and |
13 |
|
|
|
// limitations under the License. |
14 |
|
|
|
|
15 |
|
|
|
#pragma once |
16 |
|
|
|
|
17 |
|
|
|
#include <exception> |
18 |
|
|
|
#include <stdexcept> |
19 |
|
|
|
#include <string> |
20 |
|
|
|
#include <vector> |
21 |
|
|
|
|
22 |
|
|
|
namespace tket { |
23 |
|
|
|
|
24 |
|
|
|
namespace zx { |
25 |
|
|
|
|
26 |
|
|
|
/** |
27 |
|
|
|
* Error messages |
28 |
|
|
|
**/ |
29 |
|
|
|
class ZXError : public std::logic_error { |
30 |
|
|
|
public: |
31 |
|
|
28 |
explicit ZXError(const std::string& message) : std::logic_error(message) {} |
32 |
|
|
|
}; |
33 |
|
|
|
|
34 |
|
|
|
/** |
35 |
|
|
|
* Type for an edge in a ZX diagram. |
36 |
|
|
|
* `Basic`: normal (identity) edge |
37 |
|
|
|
* `H`: Hamadard edge; |
38 |
|
|
|
**/ |
39 |
|
|
|
enum class ZXWireType { Basic, H }; |
40 |
|
|
|
|
41 |
|
|
|
/** |
42 |
|
|
|
* Provides distinction between classical and quantum diagrams, |
43 |
|
|
|
* wires, and operators, relating to the doubling construction for CP-maps. |
44 |
|
|
|
**/ |
45 |
|
|
|
enum class QuantumType { Quantum, Classical }; |
46 |
|
|
|
|
47 |
|
|
|
/** |
48 |
|
|
|
* Ports are used for non-commutative generators, such as |
49 |
|
|
|
* directed generators, to distinguish the incident wires. |
50 |
|
|
|
* When needed, ports on the source and target vertex are stored |
51 |
|
|
|
* in the wire properties. |
52 |
|
|
|
* Since the graphs are semantically undirected, it is not given |
53 |
|
|
|
* whether a vertex is a source or target of each incident edge at |
54 |
|
|
|
* compile time, so WireEnd variables express which it is at runtime. |
55 |
|
|
|
**/ |
56 |
|
|
|
enum class WireEnd { Source, Target }; |
57 |
|
|
|
|
58 |
|
|
|
} // namespace zx |
59 |
|
|
|
|
60 |
|
|
|
} // namespace tket |
61 |
|
|
|
|