Files
@ fda8425fac05
Branch filter:
Location: AENC/switchchain/cpp/exports.hpp - annotation
fda8425fac05
1.4 KiB
text/x-c++hdr
Add scatter plot of GCM success rate vs mixing time
0f3a4ccb62ea f8cbbd135cc1 bfca8e3039c5 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea 0f3a4ccb62ea bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 bfca8e3039c5 | #pragma once
#include <iostream>
#include <vector>
#include "graph.hpp"
std::ostream &operator<<(std::ostream &s, const Edge &e) {
s << '{' << e.u << ',' << e.v << '}';
return s;
}
// Mathematica style export
std::ostream &operator<<(std::ostream &s, const Graph &g) {
if (g.edgeCount() == 0) {
s << '{' << '}';
return s;
}
s << '{' << g.getEdge(0).u << '<' << '-' << '>' << g.getEdge(0).v;
for (unsigned int i = 1; i < g.edgeCount(); ++i) {
const Edge &e = g.getEdge(i);
s << ',' << e.u << '<' << '-' << '>' << e.v;
}
s << '}';
return s;
}
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::vector<T>& v) {
if (v.empty()) {
s << '{' << '}';
return s;
}
auto iter = v.begin();
s << '{' << *iter++;
for (; iter != v.end(); ++iter) {
s << ',' << *iter;
}
s << '}';
return s;
}
// Mathematica style export for arrays
// SFINAE to disable char arrays since it will mess up
// things of the form s << "some string";
template <
typename T, std::size_t N,
typename = typename std::enable_if<!std::is_same<T, char>::value, T>::type>
std::ostream& operator<<(std::ostream& s, const T (&v)[N]) {
if (N == 0) {
s << '{' << '}';
return s;
}
s << '{' << v[0];
for (size_t i = 1; i < N; ++i)
s << ',' << v[i];
s << '}';
return s;
}
|