GCC Code Coverage Report


Directory: ./
File: OpType/include/OpType/OpTypeInfo.hpp
Date: 2022-10-15 05:10:18
Exec Total Coverage
Lines: 0 4 0.0%
Functions: 0 3 0.0%
Branches: 0 8 0.0%
Decisions: 0 0 -%

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 <map>
18 #include <optional>
19 #include <string>
20
21 #include "EdgeType.hpp"
22 #include "OpType.hpp"
23
24 namespace tket {
25
26 /**
27 * General information about an \p OpType
28 */
29 struct OpTypeInfo {
30 const std::string name; /**< name */
31 const std::string latex_name; /**< name in Latex representation */
32
33 /** Number of phase parameters */
34 unsigned n_params() const { return param_mod.size(); }
35
36 /**
37 * Moduli of parameters.
38 *
39 * This is a vector whose i'th entry is the least n > 0 such that adding n
40 * to the i'th parameter leaves the operation unchanged.
41 */
42 const std::vector<unsigned> param_mod;
43
44 const std::optional<op_signature_t>
45 signature; /** types of inputs and outputs */
46 };
47
48 /** Information including name and shape of each operation type */
49 const std::map<OpType, OpTypeInfo> &optypeinfo();
50
51 /** Operation type not valid in the current context */
52 class BadOpType : public std::logic_error {
53 public:
54 BadOpType(const std::string &message, OpType optype)
55 : std::logic_error(message + ": " + optypeinfo().at(optype).name) {}
56 explicit BadOpType(OpType optype) : BadOpType("Bad operation type", optype) {}
57 };
58
59 } // namespace tket
60