diff options
| -rw-r--r-- | expt_0722.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/expt_0722.cpp b/expt_0722.cpp index 5e881b0..dac83a4 100644 --- a/expt_0722.cpp +++ b/expt_0722.cpp @@ -9,7 +9,7 @@ constexpr size_t length = 1048576; std::vector<unsigned long long> population_vector, sample_vector, original_vector; // std::vector<std::vector<unsigned long long>> result_storage; -std::vector<bool> result_storage; +std::vector<short> result_storage; long double sample_cdf(long double x) { auto it = lower_bound(sample_vector.begin(), sample_vector.end(), x); @@ -42,11 +42,11 @@ inline void store_into_vector(unsigned long long value) { population_vector.push_back(value); } -constexpr long scale_size = 10000; -constexpr long sample_length = 1024, split_size = 1024 * scale_size; +constexpr long scale_size = 5; +constexpr long sample_length = 1024, split_size = 2048 * scale_size; constexpr long test_size = 2048; -int main(int argc, char const *argv[]) { +int main(int _argc, char const *_argv[]) { assert((length & 1) == 0); assert(length > 1024); @@ -62,24 +62,27 @@ int main(int argc, char const *argv[]) { sample_vector = std::vector<unsigned long long>( original_vector.begin(), original_vector.begin() + sample_length); - result_storage.resize(split_size, false); - sample_vector.push_back(min_value); sample_vector.push_back(max_value); std::sort(sample_vector.begin(), sample_vector.end()); + + result_storage.resize(split_size, 0); + const auto slice_size = 1.0 / (long double)(split_size); for (long i = 0; i < test_size; i++) { auto index = safe_ceil(sample_cdf(original_vector[i + sample_length]) / slice_size) - 1; - printf("%Lf\n", index); - auto &&item = result_storage[(int)index]; - if (item) { - printf("process: %ld Fail at: %lld\n", i, original_vector[i]); - break; + // printf("%Lf\n", index); + result_storage[(int)index]++; + } + auto element_size_max = 0; + for (auto element : result_storage) { + if (element_size_max < element) { + element_size_max = element; } - item = true; } + printf("scale: %ld, max: %d\n", scale_size, element_size_max); }
\ No newline at end of file |
