| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "sabirov_s_min_val_matrix/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <cstdint> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "sabirov_s_min_val_matrix/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace sabirov_s_min_val_matrix { | ||
| 11 | |||
| 12 | 96 | SabirovSMinValMatrixSEQ::SabirovSMinValMatrixSEQ(const InType &in) { | |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 | 96 | GetInput() = in; | |
| 15 | GetOutput().clear(); | ||
| 16 | 96 | } | |
| 17 | |||
| 18 | 96 | bool SabirovSMinValMatrixSEQ::ValidationImpl() { | |
| 19 |
2/4✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
|
96 | return (GetInput() > 0) && (GetOutput().empty()); |
| 20 | } | ||
| 21 | |||
| 22 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
|
96 | bool SabirovSMinValMatrixSEQ::PreProcessingImpl() { |
| 23 | GetOutput().clear(); | ||
| 24 | 96 | GetOutput().reserve(GetInput()); | |
| 25 | 96 | return true; | |
| 26 | } | ||
| 27 | |||
| 28 | 96 | bool SabirovSMinValMatrixSEQ::RunImpl() { | |
| 29 | 96 | InType n = GetInput(); | |
| 30 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
|
96 | if (n == 0) { |
| 31 | return false; | ||
| 32 | } | ||
| 33 | |||
| 34 | GetOutput().clear(); | ||
| 35 | 96 | GetOutput().reserve(n); | |
| 36 | |||
| 37 | auto generate_value = [](int64_t i, int64_t j) -> InType { | ||
| 38 | constexpr int64_t kA = 1103515245LL; | ||
| 39 | constexpr int64_t kC = 12345LL; | ||
| 40 | constexpr int64_t kM = 2147483648LL; | ||
| 41 | 2874392 | int64_t seed = ((i % kM) * (100000007LL % kM) + (j % kM) * (1000000009LL % kM)) % kM; | |
| 42 | 2874392 | seed = (seed ^ 42LL) % kM; | |
| 43 | 2874392 | int64_t val = ((kA % kM) * (seed % kM) + kC) % kM; | |
| 44 | 2874392 | return static_cast<InType>((val % 2000001LL) - 1000000LL); | |
| 45 | }; | ||
| 46 | |||
| 47 |
2/2✓ Branch 0 taken 9000 times.
✓ Branch 1 taken 96 times.
|
9096 | for (InType i = 0; i < n; i++) { |
| 48 | 9000 | InType min_val = generate_value(static_cast<int64_t>(i), 0); | |
| 49 |
2/2✓ Branch 0 taken 2865392 times.
✓ Branch 1 taken 9000 times.
|
2874392 | for (InType j = 1; j < n; j++) { |
| 50 | 2865392 | InType val = generate_value(static_cast<int64_t>(i), static_cast<int64_t>(j)); | |
| 51 | 2865392 | min_val = std::min(min_val, val); | |
| 52 | } | ||
| 53 | GetOutput().push_back(min_val); | ||
| 54 | } | ||
| 55 | |||
| 56 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
|
96 | return !GetOutput().empty() && (GetOutput().size() == static_cast<size_t>(n)); |
| 57 | } | ||
| 58 | |||
| 59 |
1/2✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
|
96 | bool SabirovSMinValMatrixSEQ::PostProcessingImpl() { |
| 60 |
2/4✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
|
96 | return !GetOutput().empty() && (GetOutput().size() == static_cast<size_t>(GetInput())); |
| 61 | } | ||
| 62 | |||
| 63 | } // namespace sabirov_s_min_val_matrix | ||
| 64 |