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 | #include "Op.hpp" | |||
16 | ||||
17 | #include <sstream> | |||
18 | ||||
19 | #include "Ops/OpPtr.hpp" | |||
20 | #include "Utils/Json.hpp" | |||
21 | ||||
22 | namespace tket { | |||
23 | ||||
24 | 864 | std::string Op::get_name(bool latex) const { | ||
25 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 859 times.
|
2/2✓ Decision 'true' taken 10 times.
✓ Decision 'false' taken 854 times.
|
864 | if (latex) { |
26 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
10 | return get_desc().latex(); | |
27 | } else { | |||
28 |
1/2✓ Branch 2 taken 859 times.
✗ Branch 3 not taken.
|
1718 | return get_desc().name(); | |
29 | } | |||
30 | } | |||
31 | ||||
32 | 1176 | std::string Op::get_command_str(const unit_vector_t& args) const { | ||
33 |
1/2✓ Branch 1 taken 1176 times.
✗ Branch 2 not taken.
|
1176 | std::stringstream out; | |
34 |
2/4✓ Branch 1 taken 1176 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1176 times.
✗ Branch 5 not taken.
|
1176 | out << get_name(); | |
35 |
1/2✓ Branch 1 taken 1176 times.
✗ Branch 2 not taken.
|
1/2✓ Decision 'true' taken 1176 times.
✗ Decision 'false' not taken.
|
1176 | if (!args.empty()) { |
36 |
3/6✓ Branch 1 taken 1176 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1176 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1176 times.
✗ Branch 9 not taken.
|
1176 | out << " " << args[0].repr(); | |
37 |
2/2✓ Branch 1 taken 144 times.
✓ Branch 2 taken 1176 times.
|
2/2✓ Decision 'true' taken 144 times.
✓ Decision 'false' taken 1176 times.
|
1320 | for (unsigned i = 1; i < args.size(); i++) { |
38 |
3/6✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 144 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 144 times.
✗ Branch 9 not taken.
|
144 | out << ", " << args[i].repr(); | |
39 | } | |||
40 | } | |||
41 |
1/2✓ Branch 1 taken 1176 times.
✗ Branch 2 not taken.
|
1176 | out << ";"; | |
42 |
1/2✓ Branch 1 taken 1176 times.
✗ Branch 2 not taken.
|
2352 | return out.str(); | |
43 | 1176 | } | ||
44 | ||||
45 | ✗ | std::ostream& operator<<(std::ostream& os, Op const& operation) { | ||
46 | ✗ | return os << operation.get_name(); | ||
47 | } | |||
48 | ||||
49 | 80 | void to_json(nlohmann::json& j, const Op_ptr& op) { j = op->serialize(); } | ||
50 | ||||
51 | } // namespace tket | |||
52 |