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

🐛 std::rand replaced by std::mt19937_64 #124

Merged
merged 3 commits into from
Feb 12, 2023
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
11 changes: 4 additions & 7 deletions include/fiction/technology/charge_distribution_surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,10 @@ class charge_distribution_surface<Lyt, false> : public Lyt

if (!candidates.empty())
{
const auto random_index =
static_cast<uint64_t>(std::rand()) % // NOLINT: we use rand() due to its performance advantage; we do
// not need cryptographic security here
candidates.size();

const auto random_element = index_vector[candidates[random_index]];
strg->cell_charge[random_element] = sidb_charge_state::NEGATIVE;
static std::mt19937_64 generator(std::random_device{}());
std::uniform_int_distribution<uint64_t> dist(0, candidates.size() - 1);
const auto random_element = index_vector[candidates[dist(generator)]];
strg->cell_charge[random_element] = sidb_charge_state::NEGATIVE;
negative_indices.push_back(random_element);

strg->system_energy += -(this->get_local_potential_by_index(random_element).value());
Expand Down