Skip to content

Commit

Permalink
🐛 std::rand replaced by std::mt19937_64 (#124)
Browse files Browse the repository at this point in the history
* 🐛 std::rand replaced by std::mt19937_64

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

---------

Signed-off-by: ClangFormat <[email protected]>
Co-authored-by: Drewniok <[email protected]>
Co-authored-by: ClangFormat <[email protected]>
  • Loading branch information
3 people authored Feb 12, 2023
1 parent b5df6f3 commit 49c183e
Showing 1 changed file with 4 additions and 7 deletions.
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

0 comments on commit 49c183e

Please sign in to comment.