Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated lib to cpp20 #253

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions include/find_embedding/find_embedding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,38 +174,38 @@ class pathfinder_wrapper {

private:
template <bool parallel, bool fixed, bool restricted, bool verbose, typename... Args>
inline std::unique_ptr<pathfinder_public_interface> _pf_parse4(Args &&... args) {
inline std::unique_ptr<pathfinder_public_interface> _pf_parse4(Args &&...args) {
return std::unique_ptr<pathfinder_public_interface>(static_cast<pathfinder_public_interface *>(
new (typename pathfinder_type<parallel, fixed, restricted, verbose>::pathfinder_t)(
std::forward<Args>(args)...)));
}

template <bool parallel, bool fixed, bool restricted, typename... Args>
inline std::unique_ptr<pathfinder_public_interface> _pf_parse3(Args &&... args) {
inline std::unique_ptr<pathfinder_public_interface> _pf_parse3(Args &&...args) {
if (pp.params.verbose <= 0)
return _pf_parse4<parallel, fixed, restricted, false>(std::forward<Args>(args)...);
else
return _pf_parse4<parallel, fixed, restricted, true>(std::forward<Args>(args)...);
}

template <bool parallel, bool fixed, typename... Args>
inline std::unique_ptr<pathfinder_public_interface> _pf_parse2(Args &&... args) {
inline std::unique_ptr<pathfinder_public_interface> _pf_parse2(Args &&...args) {
if (pp.params.restrict_chains.size())
return _pf_parse3<parallel, fixed, true>(std::forward<Args>(args)...);
else
return _pf_parse3<parallel, fixed, false>(std::forward<Args>(args)...);
}

template <bool parallel, typename... Args>
inline std::unique_ptr<pathfinder_public_interface> _pf_parse1(Args &&... args) {
inline std::unique_ptr<pathfinder_public_interface> _pf_parse1(Args &&...args) {
if (pp.params.fixed_chains.size())
return _pf_parse2<parallel, true>(std::forward<Args>(args)...);
else
return _pf_parse2<parallel, false>(std::forward<Args>(args)...);
}

template <typename... Args>
inline std::unique_ptr<pathfinder_public_interface> _pf_parse(Args &&... args) {
inline std::unique_ptr<pathfinder_public_interface> _pf_parse(Args &&...args) {
if (pp.params.threads > 1)
return _pf_parse1<true>(std::forward<Args>(args)...);
else
Expand All @@ -229,8 +229,8 @@ class pathfinder_wrapper {
//! The optional parameters themselves can be found in util.hpp. Respectively,
//! the controlling options for the above are restrict_chains, fixed_chains,
//! and threads.
int findEmbedding(graph::input_graph &var_g, graph::input_graph &qubit_g, optional_parameters &params,
vector<vector<int>> &chains) {
inline int findEmbedding(graph::input_graph &var_g, graph::input_graph &qubit_g, optional_parameters &params,
vector<vector<int>> &chains) {
pathfinder_wrapper pf(var_g, qubit_g, params);
int success = pf.heuristicEmbedding();

Expand Down
6 changes: 3 additions & 3 deletions include/find_embedding/pairing_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class pairing_node : public N {
pairing_node *desc;

public:
pairing_node<N>() {}
pairing_node() {}

template <class... Args>
pairing_node<N>(Args... args) : N(args...), next(nullptr), desc(nullptr) {}
pairing_node(Args... args) : N(args...), next(nullptr), desc(nullptr) {}

//! the basic operation of the pairing queue -- put `this` and `other`
//! into heap-order
Expand Down Expand Up @@ -159,4 +159,4 @@ class pairing_queue {
root = root->merge_pairs();
}
};
}
} // namespace find_embedding
16 changes: 6 additions & 10 deletions include/find_embedding/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@
#include <chrono>
#include <iterator>
#include <map>
#include <memory>
#include <mutex>
#include <queue>
#include <random>
#include <thread>
#include <unordered_map>

#include "../debug.hpp"
#include "../errors.hpp"
#include "../fastrng.hpp"
#include "pairing_queue.hpp"

namespace find_embedding {
// Import some things from the std library
using fastrng::fastrng;
using std::default_random_engine;
using std::map;
using std::max;
Expand All @@ -44,8 +47,6 @@ using std::unordered_map;
using std::vector;
using std::chrono::duration;
using std::chrono::duration_cast;
using fastrng::fastrng;


// Select some default structures and types
using distance_t = long long int;
Expand Down Expand Up @@ -184,21 +185,16 @@ class optional_parameters {
localInteractionPtr->displayOutput(loglevel, buffer);
}

void print_out(int loglevel, const char* format) const {
localInteractionPtr->displayOutput(loglevel, format);
}

void print_out(int loglevel, const char* format) const { localInteractionPtr->displayOutput(loglevel, format); }

template <typename... Args>
void print_err(int loglevel, const char* format, Args... args) const {
char buffer[1024];
snprintf(buffer, 1024, format, args...);
localInteractionPtr->displayError(loglevel, buffer);\
localInteractionPtr->displayError(loglevel, buffer);
}

void print_err(int loglevel, const char* format) const {
localInteractionPtr->displayError(loglevel, format);
}
void print_err(int loglevel, const char* format) const { localInteractionPtr->displayError(loglevel, format); }

template <typename... Args>
void error(const char* format, Args... args) const {
Expand Down