Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Hybrid Schrödinger-Feynman Simulation Preparation #12

Merged
merged 16 commits into from
May 7, 2021
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14...3.19)
# project definition
project(DDPackage
LANGUAGES CXX
VERSION 2.0.1
VERSION 2.0.2
DESCRIPTION "JKQ decision diagram package tailored to quantum computing")

# enable organization of targets into folders
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Alwin Zulehner, Stefan Hillmich, Lukas Burgholzer and Robert Wille
Copyright (c) 2021 Hartwig Bauer, Lukas Burgholzer, Thomas Grurl, Stefan Hillmich, Robert Wille, and Alwin Zulehner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ A small example shows how to create set a single qubit in superposition.

```c++
#include <memory>
#include "DDpackage.h"
#include "GateMatrixDefinitions.h"
#include "dd/Package.hpp"

auto dd = std::make_unique<dd::Package>(); // Create new package instance
auto dd = std::make_unique<dd::Package>(1); // Create new package instance capable of handling a single qubit
auto zero_state = dd->makeZeroState(1) ; // zero_state = |0>

/* Creating a DD requires the following inputs:
Expand Down
11 changes: 11 additions & 0 deletions include/dd/ComplexValue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@ namespace dd {

return ss.str();
}

ComplexValue& operator+=(const ComplexValue& rhs) {
r += rhs.r;
i += rhs.i;
return *this;
}

friend ComplexValue operator+(ComplexValue lhs, const ComplexValue& rhs) {
lhs += rhs;
return lhs;
}
};

inline std::ostream& operator<<(std::ostream& os, const ComplexValue& c) {
Expand Down
24 changes: 12 additions & 12 deletions include/dd/Export.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace dd {
return os;
}

static std::ostream& modernNode(const Package::mEdge& e, std::ostream& os) {
[[maybe_unused]] static std::ostream& modernNode(const Package::mEdge& e, std::ostream& os) {
auto nodelabel = (reinterpret_cast<std::uintptr_t>(e.p) & 0x001fffffU) >> 1U; // this allows for 2^20 (roughly 1e6) unique nodes
os << nodelabel << "[label=<";
os << R"(<font point-size="10"><table border="1" cellspacing="0" cellpadding="2" style="rounded">)";
Expand All @@ -155,7 +155,7 @@ namespace dd {
os << "</table></font>>,tooltip=\"q" << static_cast<std::size_t>(e.p->v) << "\"]\n";
return os;
}
static std::ostream& modernNode(const Package::vEdge& e, std::ostream& os) {
[[maybe_unused]] static std::ostream& modernNode(const Package::vEdge& e, std::ostream& os) {
auto nodelabel = (reinterpret_cast<std::uintptr_t>(e.p) & 0x001fffffU) >> 1U; // this allows for 2^20 (roughly 1e6) unique nodes
os << nodelabel << "[label=<";
os << R"(<font point-size="8"><table border="1" cellspacing="0" cellpadding="0" style="rounded">)";
Expand All @@ -165,7 +165,7 @@ namespace dd {
os << "</tr></table></font>>,tooltip=\"q" << static_cast<std::size_t>(e.p->v) << "\"]\n";
return os;
}
static std::ostream& classicNode(const Package::mEdge& e, std::ostream& os) {
[[maybe_unused]] static std::ostream& classicNode(const Package::mEdge& e, std::ostream& os) {
auto nodelabel = (reinterpret_cast<std::uintptr_t>(e.p) & 0x001fffffU) >> 1U; // this allows for 2^20 (roughly 1e6) unique nodes
os << nodelabel << "[shape=circle, width=0.53, fixedsize=true, label=<";
os << R"(<font point-size="6"><table border="0" cellspacing="0" cellpadding="0">)";
Expand Down Expand Up @@ -203,7 +203,7 @@ namespace dd {
os << "<td></td></tr></table></font>>,tooltip=\"q" << static_cast<std::size_t>(e.p->v) << "\"]\n";
return os;
}
static std::ostream& classicNode(const Package::vEdge& e, std::ostream& os) {
[[maybe_unused]] static std::ostream& classicNode(const Package::vEdge& e, std::ostream& os) {
auto nodelabel = (reinterpret_cast<std::uintptr_t>(e.p) & 0x001fffffU) >> 1U; // this allows for 2^20 (roughly 1e6) unique nodes
os << nodelabel << "[shape=circle, width=0.46, fixedsize=true, label=<";
os << R"(<font point-size="6"><table border="0" cellspacing="0" cellpadding="0">)";
Expand Down Expand Up @@ -249,7 +249,7 @@ namespace dd {
return os;
}

static std::ostream& bwEdge(const Package::mEdge& from, const Package::mEdge& to, short idx, std::ostream& os, bool edgeLabels = false, bool classic = false) {
[[maybe_unused]] static std::ostream& bwEdge(const Package::mEdge& from, const Package::mEdge& to, short idx, std::ostream& os, bool edgeLabels = false, bool classic = false) {
auto fromlabel = (reinterpret_cast<std::uintptr_t>(from.p) & 0x001fffffU) >> 1U;
auto tolabel = (reinterpret_cast<std::uintptr_t>(to.p) & 0x001fffffU) >> 1U;

Expand Down Expand Up @@ -288,7 +288,7 @@ namespace dd {

return os;
}
static std::ostream& bwEdge(const Package::vEdge& from, const Package::vEdge& to, short idx, std::ostream& os, bool edgeLabels = false, [[maybe_unused]] bool classic = false) {
[[maybe_unused]] static std::ostream& bwEdge(const Package::vEdge& from, const Package::vEdge& to, short idx, std::ostream& os, bool edgeLabels = false, [[maybe_unused]] bool classic = false) {
auto fromlabel = (reinterpret_cast<std::uintptr_t>(from.p) & 0x001fffffU) >> 1U;
auto tolabel = (reinterpret_cast<std::uintptr_t>(to.p) & 0x001fffffU) >> 1U;

Expand All @@ -312,7 +312,7 @@ namespace dd {

return os;
}
static std::ostream& coloredEdge(const Package::mEdge& from, const Package::mEdge& to, short idx, std::ostream& os, bool edgeLabels = false, bool classic = false) {
[[maybe_unused]] static std::ostream& coloredEdge(const Package::mEdge& from, const Package::mEdge& to, short idx, std::ostream& os, bool edgeLabels = false, bool classic = false) {
auto fromlabel = (reinterpret_cast<std::uintptr_t>(from.p) & 0x001fffffU) >> 1U;
auto tolabel = (reinterpret_cast<std::uintptr_t>(to.p) & 0x001fffffU) >> 1U;

Expand Down Expand Up @@ -349,7 +349,7 @@ namespace dd {

return os;
}
static std::ostream& coloredEdge(const Package::vEdge& from, const Package::vEdge& to, short idx, std::ostream& os, bool edgeLabels = false, [[maybe_unused]] bool classic = false) {
[[maybe_unused]] static std::ostream& coloredEdge(const Package::vEdge& from, const Package::vEdge& to, short idx, std::ostream& os, bool edgeLabels = false, [[maybe_unused]] bool classic = false) {
auto fromlabel = (reinterpret_cast<std::uintptr_t>(from.p) & 0x001fffffU) >> 1U;
auto tolabel = (reinterpret_cast<std::uintptr_t>(to.p) & 0x001fffffU) >> 1U;

Expand Down Expand Up @@ -486,7 +486,7 @@ namespace dd {
}

template<class Edge>
static void export2Dot(Edge basic, const std::string& outputFilename, bool colored = true, bool edgeLabels = false, bool classic = false, bool memory = false, bool show = true) {
[[maybe_unused]] static void export2Dot(Edge basic, const std::string& outputFilename, bool colored = true, bool edgeLabels = false, bool classic = false, bool memory = false, bool show = true) {
std::ofstream init(outputFilename);
toDot(basic, init, colored, edgeLabels, classic, memory);
init.close();
Expand All @@ -504,7 +504,7 @@ namespace dd {
/// Note: do not rely on the binary format being portable across different architectures/platforms
///

static void serialize(const Package::vEdge& basic, std::ostream& os, bool writeBinary = false) {
[[maybe_unused]] static void serialize(const Package::vEdge& basic, std::ostream& os, bool writeBinary = false) {
if (writeBinary) {
os.write(reinterpret_cast<const char*>(&SERIALIZATION_VERSION), sizeof(decltype(SERIALIZATION_VERSION)));
basic.w.writeBinary(os);
Expand Down Expand Up @@ -629,7 +629,7 @@ namespace dd {
}
}
}
static void serialize(const Package::mEdge& basic, std::ostream& os, bool writeBinary = false) {
[[maybe_unused]] static void serialize(const Package::mEdge& basic, std::ostream& os, bool writeBinary = false) {
if (writeBinary) {
os.write(reinterpret_cast<const char*>(&SERIALIZATION_VERSION), sizeof(decltype(SERIALIZATION_VERSION)));
basic.w.writeBinary(os);
Expand All @@ -644,7 +644,7 @@ namespace dd {
}
template<class Edge>
static void serialize(const Edge& basic, const std::string& outputFilename, bool writeBinary = false) {
std::ofstream ofs(outputFilename);
std::ofstream ofs = std::ofstream(outputFilename, std::ios::binary);

if (!ofs.good()) {
throw std::invalid_argument("Cannot open file: " + outputFilename);
Expand Down
Loading