| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "rozenberg_a_radix_simple_merge/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <array> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <cstdint> | ||
| 6 | #include <cstring> | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "rozenberg_a_radix_simple_merge/common/include/common.hpp" | ||
| 10 | |||
| 11 | namespace rozenberg_a_radix_simple_merge { | ||
| 12 | |||
| 13 | 96 | RozenbergARadixSimpleMergeSEQ::RozenbergARadixSimpleMergeSEQ(const InType &in) { | |
| 14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 15 | |||
| 16 | InType empty; | ||
| 17 | GetInput().swap(empty); | ||
| 18 | |||
| 19 |
2/2✓ Branch 0 taken 2776 times.
✓ Branch 1 taken 96 times.
|
2872 | for (const auto &elem : in) { |
| 20 | GetInput().push_back(elem); | ||
| 21 | } | ||
| 22 | |||
| 23 | GetOutput().clear(); | ||
| 24 | 96 | } | |
| 25 | |||
| 26 |
1/2✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
|
96 | bool RozenbergARadixSimpleMergeSEQ::ValidationImpl() { |
| 27 |
2/4✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
|
96 | return (!(GetInput().empty())) && (GetOutput().empty()); |
| 28 | } | ||
| 29 | |||
| 30 | 96 | bool RozenbergARadixSimpleMergeSEQ::PreProcessingImpl() { | |
| 31 | 96 | GetOutput().resize(GetInput().size()); | |
| 32 | 96 | return GetOutput().size() == GetInput().size(); | |
| 33 | } | ||
| 34 | |||
| 35 | 96 | bool RozenbergARadixSimpleMergeSEQ::RunImpl() { | |
| 36 | 96 | InType data = GetInput(); | |
| 37 | size_t n = data.size(); | ||
| 38 |
1/4✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
96 | InType buffer(n); |
| 39 | |||
| 40 |
2/2✓ Branch 0 taken 768 times.
✓ Branch 1 taken 96 times.
|
864 | for (int shift = 0; shift < 64; shift += 8) { |
| 41 | 768 | std::array<size_t, 256> count = {0}; | |
| 42 | |||
| 43 |
4/4✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 17600 times.
✓ Branch 2 taken 22208 times.
✓ Branch 3 taken 768 times.
|
22976 | for (double val : data) { |
| 44 | uint64_t u = 0; | ||
| 45 | std::memcpy(&u, &val, sizeof(double)); | ||
| 46 | |||
| 47 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 17600 times.
|
22208 | u = (u >> 63 != 0U) ? ~u : (u ^ 0x8000000000000000); |
| 48 | |||
| 49 | 22208 | auto byte = static_cast<uint8_t>((u >> shift) & 0xFF); | |
| 50 | 22208 | count.at(byte)++; | |
| 51 | } | ||
| 52 | |||
| 53 |
2/2✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 768 times.
|
196608 | for (int i = 1; i < 256; ++i) { |
| 54 | 195840 | count.at(i) += count.at(i - 1); | |
| 55 | } | ||
| 56 | |||
| 57 |
2/2✓ Branch 0 taken 22208 times.
✓ Branch 1 taken 768 times.
|
22976 | for (int i = static_cast<int>(n) - 1; i >= 0; --i) { |
| 58 | uint64_t u = 0; | ||
| 59 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 17600 times.
|
22208 | std::memcpy(&u, &data[i], 8); |
| 60 | |||
| 61 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 17600 times.
|
22208 | u = (u >> 63 != 0U) ? ~u : (u ^ 0x8000000000000000); |
| 62 | |||
| 63 | 22208 | auto byte = static_cast<uint8_t>((u >> shift) & 0xFF); | |
| 64 | 22208 | buffer[--count.at(byte)] = data[i]; | |
| 65 | } | ||
| 66 |
1/2✓ Branch 1 taken 768 times.
✗ Branch 2 not taken.
|
768 | data = buffer; |
| 67 | } | ||
| 68 | |||
| 69 |
1/2✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
|
96 | GetOutput() = data; |
| 70 | |||
| 71 | 96 | return true; | |
| 72 | } | ||
| 73 | |||
| 74 | 96 | bool RozenbergARadixSimpleMergeSEQ::PostProcessingImpl() { | |
| 75 | 96 | return true; | |
| 76 | } | ||
| 77 | |||
| 78 | } // namespace rozenberg_a_radix_simple_merge | ||
| 79 |