diff options
| author | KunoiSayami <[email protected]> | 2022-07-28 13:29:18 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2022-07-28 13:29:18 +0800 |
| commit | 01a204956deca5c2afb23d0b295aec7cbe67a936 (patch) | |
| tree | ca30350da940c1b547274ef74931b904af411bda /expt_0722.cpp | |
| parent | 72b148b1e2cd5bf45d26b3f6c7591482c385780c (diff) | |
feat: Implement calculate element count
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'expt_0722.cpp')
| -rw-r--r-- | expt_0722.cpp | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/expt_0722.cpp b/expt_0722.cpp index dac83a4..eb1ffed 100644 --- a/expt_0722.cpp +++ b/expt_0722.cpp @@ -10,6 +10,7 @@ std::vector<unsigned long long> population_vector, sample_vector, original_vector; // std::vector<std::vector<unsigned long long>> result_storage; std::vector<short> result_storage; +std::vector<short> counter; long double sample_cdf(long double x) { auto it = lower_bound(sample_vector.begin(), sample_vector.end(), x); @@ -42,10 +43,44 @@ inline void store_into_vector(unsigned long long value) { population_vector.push_back(value); } -constexpr long scale_size = 5; -constexpr long sample_length = 1024, split_size = 2048 * scale_size; +constexpr long sample_length = 1024; constexpr long test_size = 2048; +void mian(long scale_size) { + const long split_size = test_size * scale_size; + counter.resize(8); + + 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); + result_storage[(int)index]++; + } + auto element_size_max = 0; + for (auto element : result_storage) { + if (element > 1) { + counter[element]++; + } + if (element_size_max < element) { + element_size_max = element; + } + } + printf("scale: %2ld, max: %d ", scale_size, element_size_max); + for (int i = 2; i < 8; i++) { + if (counter[i]) { + printf(" %d: %3d", i, counter[i]); + } + } + puts(""); + result_storage.clear(); + counter.clear(); +} + int main(int _argc, char const *_argv[]) { assert((length & 1) == 0); assert(length > 1024); @@ -67,22 +102,7 @@ int main(int _argc, char const *_argv[]) { 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); - result_storage[(int)index]++; - } - auto element_size_max = 0; - for (auto element : result_storage) { - if (element_size_max < element) { - element_size_max = element; - } + for (int i = 2; i <= 16; i++) { + mian(i); } - printf("scale: %ld, max: %d\n", scale_size, element_size_max); }
\ No newline at end of file |
