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

Update bell_inequalities.cpp #180

Merged
merged 2 commits into from
Feb 12, 2025
Merged
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
24 changes: 8 additions & 16 deletions examples/bell_inequalities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <iostream>
#include <tuple>
#include <array>

#include "qpp/qpp.hpp"

Expand All @@ -19,11 +20,10 @@ int main() {

// number of "experiments" for each of the 4 detector settings
idx N = 10000;
std::cout << ">> Number N of experiments for each of the 4 measurement";
std::cout << " settings = " << N << '\n';
std::cout << ">> Number N of experiments for each of the 4 measurement settings = " << N << '\n';

idx statistics[4][4] = {{0}}; // total statistics
long E[4] = {0}; // experimental estimate
std::array<std::array<idx, 4>, 4> statistics{}; // total statistics
std::array<long, 4> E{}; // experimental estimate

idx gate_idx = 0; // gate index (0, 1, 2 or 3)
for (auto&& gateA : {Q, R}) // measure Alice's side
Expand Down Expand Up @@ -70,18 +70,10 @@ int main() {
}
}
std::cout << "[N++ | N+- | N-+ | N--] (N++ + N--) - (N+- + N-+)\n";
std::cout << "QS: "
<< disp(statistics[0], 4, IOManipPointerOpts{}.set_sep(" "))
<< " " << E[0] << '\n';
std::cout << "QT: "
<< disp(statistics[1], 4, IOManipPointerOpts{}.set_sep(" "))
<< " " << E[1] << '\n';
std::cout << "RS: "
<< disp(statistics[2], 4, IOManipPointerOpts{}.set_sep(" "))
<< " " << E[2] << '\n';
std::cout << "RT: "
<< disp(statistics[3], 4, IOManipPointerOpts{}.set_sep(" "))
<< " " << E[3] << '\n';
std::cout << "QS: " << disp(statistics[0], IOManipContainerOpts{}.set_sep(" ")) << " " << E[0] << '\n';
std::cout << "QT: " << disp(statistics[1], IOManipContainerOpts{}.set_sep(" ")) << " " << E[1] << '\n';
std::cout << "RS: " << disp(statistics[2], IOManipContainerOpts{}.set_sep(" ")) << " " << E[2] << '\n';
std::cout << "RT: " << disp(statistics[3], IOManipContainerOpts{}.set_sep(" ")) << " " << E[3] << '\n';

// Experimental average
realT exp_avg =
Expand Down