-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDDAlternatingChecker.hpp
66 lines (56 loc) · 2.32 KB
/
DDAlternatingChecker.hpp
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
//
// This file is part of the MQT QCEC library released under the MIT license.
// See README.md or go to https://github.com/cda-tum/qcec for more information.
//
#pragma once
#include "DDEquivalenceChecker.hpp"
#include "DDPackageConfigs.hpp"
#include "applicationscheme/LookaheadApplicationScheme.hpp"
namespace ec {
class DDAlternatingChecker final
: public DDEquivalenceChecker<qc::MatrixDD, AlternatingDDPackage> {
public:
DDAlternatingChecker(const qc::QuantumComputation& qc1,
const qc::QuantumComputation& qc2,
ec::Configuration configuration)
: DDEquivalenceChecker(qc1, qc2, std::move(configuration)) {
// gates from the second circuit shall be applied "from the right"
taskManager2.flipDirection();
initializeApplicationScheme(
this->configuration.application.alternatingScheme);
// special treatment for the lookahead application scheme
if (auto* lookahead =
dynamic_cast<LookaheadApplicationScheme<AlternatingDDPackage>*>(
applicationScheme.get())) {
// initialize links for the internal state and the package of the
// lookahead scheme
lookahead->setInternalState(functionality);
lookahead->setPackage(dd.get());
}
}
void json(nlohmann::json& j) const noexcept override {
DDEquivalenceChecker::json(j);
j["checker"] = "decision_diagram_alternating";
}
/// a function to determine whether the alternating checker can handle
/// checking both circuits. In particular, it checks whether both circuits
/// contain non-idle ancillaries.
static bool canHandle(const qc::QuantumComputation& qc1,
const qc::QuantumComputation& qc2);
private:
qc::MatrixDD functionality{};
void initializeTask(
[[maybe_unused]] TaskManager<qc::MatrixDD, AlternatingDDPackage>&
taskManager) override{
// task initialization is conducted separately for this checker
};
void initialize() override;
void execute() override;
void finish() override;
void postprocess() override;
EquivalenceCriterion checkEquivalence() override;
// at some point this routine should probably make its way into the QFR
// library
[[nodiscard]] bool gatesAreIdentical() const;
};
} // namespace ec