Commit 878fa2bc authored by frey_m's avatar frey_m
Browse files

LatinHyperCube: use better container

parent 98f4f8ff
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "Sample/RNGStream.h" #include "Sample/RNGStream.h"
#include <algorithm> #include <algorithm>
#include <deque>
class LatinHyperCube : public SamplingMethod class LatinHyperCube : public SamplingMethod
{ {
...@@ -56,14 +57,11 @@ private: ...@@ -56,14 +57,11 @@ private:
std::size_t bin = bin_m.back(); std::size_t bin = bin_m.back();
bin_m.pop_back(); bin_m.pop_back();
if ( bin_m.size() + 1e4 < bin_m.capacity() )
bin_m.shrink_to_fit();
return binsize_m * (val + bin); return binsize_m * (val + bin);
} }
void fillBins_m(std::size_t n) { void fillBins_m(std::size_t n) {
bin_m.reserve(n); bin_m.resize(n);
std::iota(bin_m.begin(), bin_m.end(), 0); std::iota(bin_m.begin(), bin_m.end(), 0);
std::random_device rd; std::random_device rd;
...@@ -74,7 +72,7 @@ private: ...@@ -74,7 +72,7 @@ private:
private: private:
RNGStream *RNGInstance_m; RNGStream *RNGInstance_m;
std::vector<std::size_t> bin_m; std::deque<std::size_t> bin_m;
double binsize_m; double binsize_m;
dist_t dist_m; dist_t dist_m;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment