GCC Code Coverage Report


Directory: ./
File: Converters/include/Converters/PauliGadget.hpp
Date: 2022-10-15 05:10:18
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 1 1 100.0%
Branches: 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 <stdexcept>
18
19 #include "Circuit/Circuit.hpp"
20 #include "Utils/PauliStrings.hpp"
21
22 namespace tket {
23
24 class ImplicitPermutationNotAllowed : public std::logic_error {
25 public:
26 1 explicit ImplicitPermutationNotAllowed(const std::string& message)
27 1 : std::logic_error(message) {}
28 };
29
30 /**
31 * Append a Pauli gadget to the end of a given circuit.
32 * Automatically uses Snake CX configuration
33 *
34 * @param circ circuit to append to
35 * @param pauli Pauli operators and their respective qubits
36 * @param angle angle in half-turns
37 * @param cx_config which type of CX configuration to decompose into
38 */
39 void append_single_pauli_gadget(
40 Circuit& circ, const QubitPauliTensor& pauli, Expr angle,
41 CXConfigType cx_config = CXConfigType::Snake);
42
43 /**
44 * Append a pair of Pauli gadgets to the end of a given circuit.
45 * (shallow) Uses an adapted arrangement of CX that gives balanced trees
46 * over the matching qubits to improve depth. Better performance
47 * is not guaranteed as CXs may not align for cancellation and
48 * it can be harder to route.
49 * (!shallow) Uses the original method with naive arrangement of CXs.
50 *
51 * @param circ circuit to append to
52 * @param pauli0 first Pauli string
53 * @param angle0 angle for \p pauli0 (half-turns)
54 * @param pauli1 second Pauli string
55 * @param angle1 angle for \p pauli1 (half-turns)
56 * @param cx_config which type of CX configuration to decompose into
57 */
58 void append_pauli_gadget_pair(
59 Circuit& circ, QubitPauliTensor pauli0, Expr angle0,
60 QubitPauliTensor pauli1, Expr angle1,
61 CXConfigType cx_config = CXConfigType::Snake);
62
63 } // namespace tket
64