From d6c7720964565b2a2991a2c60ed3cf7bfd2b8132 Mon Sep 17 00:00:00 2001 From: mariodeaconescu Date: Thu, 20 Apr 2023 21:33:48 +0300 Subject: [PATCH] v0.2 Check --- CHECKLIST.md | 4 ++-- examples/basic_circuit.cpp | 10 +++++----- examples/shors_algorithm.hpp | 2 +- include/circuit.hpp | 4 +--- include/templates/phase.tpp | 5 ++++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHECKLIST.md b/CHECKLIST.md index 372b96c..2aa3b48 100644 --- a/CHECKLIST.md +++ b/CHECKLIST.md @@ -40,8 +40,8 @@ - [x] funcții și atribute `static` - [x] STL - [x] cât mai multe `const` -- [ ] la sfârșit: commit separat cu adăugarea unei noi derivate fără a modifica restul codului -- [ ] tag de `git`: de exemplu `v0.2` +- [x] la sfârșit: commit separat cu adăugarea unei noi derivate fără a modifica restul codului +- [x] tag de `git`: de exemplu `v0.2` ## Tema 3 diff --git a/examples/basic_circuit.cpp b/examples/basic_circuit.cpp index cd41a0e..9b662ad 100644 --- a/examples/basic_circuit.cpp +++ b/examples/basic_circuit.cpp @@ -11,19 +11,19 @@ int main(){ /// This examples showcases the basic usage of the library // Instantiate the probability engine with the desired floating point type - std::shared_ptr> probabilityEngine = std::make_shared>(); + std::shared_ptr> probabilityEngine = std::make_shared>(); // Create a single qubit and inject the probability engine into it - auto qubit = Qubit(probabilityEngine); + auto qubit = QPP::Qubit(probabilityEngine); std::cout << "Qubit: \n" << qubit << "\n\n"; - auto classicBit = ClassicBit(); - classicBit.setState(ClassicBit::ONE); + auto classicBit = QPP::ClassicBit(); + classicBit.setState(QPP::ClassicBit::ONE); std::cout << "Classic bit: \n" << classicBit << "\n\n"; // Create a circuit and inject the probability engine into it // This circuit will have 2 qubits and 2 classical bits - auto circuit = Circuit(probabilityEngine, 2, 2); + auto circuit = QPP::Circuit(probabilityEngine, 2, 2); // Add a Hadamard gate to the first qubit, which will enter the superposition state circuit.addHadamardGate(0); diff --git a/examples/shors_algorithm.hpp b/examples/shors_algorithm.hpp index 7a0985f..8660360 100644 --- a/examples/shors_algorithm.hpp +++ b/examples/shors_algorithm.hpp @@ -12,7 +12,7 @@ QPP::Circuit::CircuitGate UGate(const size_t& a, const unsigned long& po if(a != 2 && a != 4 && a != 7 && a != 8 && a != 11 && a != 13){ throw std::invalid_argument("a must be coprime to N (15)"); } - auto circuit = Circuit(std::make_shared>(), 4); + auto circuit = QPP::Circuit(std::make_shared>(), 4); for (size_t iteration = 0; iteration < power; iteration++) { if(a == 2 || a == 13){ circuit.addSwapGate(2, 3); diff --git a/include/circuit.hpp b/include/circuit.hpp index 11125af..cf2a27a 100644 --- a/include/circuit.hpp +++ b/include/circuit.hpp @@ -690,8 +690,6 @@ namespace QPP { /// @tparam FloatingNumberType The type of the floating-point number used to represent the probabilities. class ControlledPhaseGate : public ControlledGate, public PhaseGate { protected: - const size_t controlQubitIndex; - [[nodiscard]] typename Gate::Drawings getDrawings(const Circuit *circuit) const override; @@ -703,7 +701,7 @@ namespace QPP { /// @brief Creates a ControlledPhaseGate with the given control qubit index. /// @param controlQubitIndex The control qubit index. - explicit ControlledPhaseGate(const size_t &controlQubitIndex, const size_t &qubitIndex, + ControlledPhaseGate(const size_t &controlQubitIndex, const size_t &qubitIndex, const double &angle); /// @brief Returns a string representation of the Controlled Phase gate. diff --git a/include/templates/phase.tpp b/include/templates/phase.tpp index 578c5c2..c82d3fe 100644 --- a/include/templates/phase.tpp +++ b/include/templates/phase.tpp @@ -14,7 +14,10 @@ template Circuit::PhaseGate::PhaseGate(const size_t &qubitIndex, const double& angle): SingleTargetGate(qubitIndex), angle(angle) {} template -Circuit::ControlledPhaseGate::ControlledPhaseGate(const size_t &controlQubitIndex, const size_t &qubitIndex, const double& angle): Circuit::ControlledGate(controlQubitIndex), Circuit::PhaseGate(qubitIndex, angle) {} +Circuit::ControlledPhaseGate::ControlledPhaseGate(const size_t &controlQubitIndex, const size_t &qubitIndex, const double& angle): +Circuit::SingleTargetGate(qubitIndex), +Circuit::ControlledGate(controlQubitIndex), +Circuit::PhaseGate(qubitIndex, angle) {} template std::string Circuit::PhaseGate::getRepresentation() const {