MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / UniqueRandomSubset

Function UniqueRandomSubset

Src/Base/AMReX_Random.cpp:201–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void
202UniqueRandomSubset (Vector<int> &uSet, int setSize, int poolSize,
203 bool printSet)
204{
205 if(setSize > poolSize) {
206 Abort("**** Error in UniqueRandomSubset: setSize > poolSize.");
207 }
208 std::set<int> copySet;
209 uSet.clear();
210 while(std::ssize(copySet) < setSize) {
211 int r = static_cast<int>(Random_int(poolSize));
212 if(!copySet.contains(r)) {
213 copySet.insert(r);
214 uSet.push_back(r);
215 }
216 }
217 if(printSet) {
218 for(int i(0); i < uSet.size(); ++i) {
219 AllPrint() << "uSet[" << i << "] = " << uSet[i] << '\n';
220 }
221 }
222}
223
224void ResetRandomSeed (ULong cpu_seed, ULong gpu_seed)
225{

Callers

nothing calls this directly

Calls 8

AbortFunction · 0.85
Random_intFunction · 0.85
AllPrintClass · 0.85
clearMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected