| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "tsyplakov_k_vec_neighbours/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cmath> | ||
| 4 | #include <cstdint> | ||
| 5 | #include <cstdlib> | ||
| 6 | #include <limits> | ||
| 7 | #include <tuple> | ||
| 8 | #include <utility> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | #include "tsyplakov_k_vec_neighbours/common/include/common.hpp" | ||
| 12 | |||
| 13 | namespace tsyplakov_k_vec_neighbours { | ||
| 14 | |||
| 15 |
1/2✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
|
176 | TsyplakovKVecNeighboursSEQ::TsyplakovKVecNeighboursSEQ(const InType &in) { |
| 16 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 17 |
1/2✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
|
176 | GetInput() = in; |
| 18 | GetOutput() = std::make_tuple(-1, -1); | ||
| 19 | 176 | } | |
| 20 | |||
| 21 | 176 | bool TsyplakovKVecNeighboursSEQ::ValidationImpl() { | |
| 22 | 176 | return true; | |
| 23 | } | ||
| 24 | |||
| 25 | 176 | bool TsyplakovKVecNeighboursSEQ::PreProcessingImpl() { | |
| 26 | 176 | vector_data_ = GetInput(); | |
| 27 | 176 | return true; | |
| 28 | } | ||
| 29 | |||
| 30 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 160 times.
|
176 | bool TsyplakovKVecNeighboursSEQ::RunImpl() { |
| 31 | const std::size_t n = vector_data_.size(); | ||
| 32 | |||
| 33 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 160 times.
|
176 | if (n < 2) { |
| 34 | GetOutput() = std::make_tuple(-1, -1); | ||
| 35 | 16 | return true; | |
| 36 | } | ||
| 37 | |||
| 38 | int min_diff = std::numeric_limits<int>::max(); | ||
| 39 | int min_index = -1; | ||
| 40 | |||
| 41 |
2/2✓ Branch 0 taken 1112 times.
✓ Branch 1 taken 160 times.
|
1272 | for (std::size_t i = 0; i + 1 < n; ++i) { |
| 42 | 1112 | int64_t diff = std::llabs(static_cast<int64_t>(vector_data_[i + 1]) - static_cast<int64_t>(vector_data_[i])); | |
| 43 | |||
| 44 |
5/6✓ Branch 0 taken 888 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 608 times.
✓ Branch 3 taken 280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 608 times.
|
1112 | if (diff < min_diff || (diff == min_diff && std::cmp_less(i, static_cast<std::size_t>(min_index)))) { |
| 45 | 224 | min_diff = static_cast<int>(diff); | |
| 46 | 224 | min_index = static_cast<int>(i); | |
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 |
1/2✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
|
160 | if (min_index >= 0) { |
| 51 | 160 | GetOutput() = std::make_tuple(min_index, min_index + 1); | |
| 52 | } else { | ||
| 53 | GetOutput() = std::make_tuple(-1, -1); | ||
| 54 | } | ||
| 55 | |||
| 56 | return true; | ||
| 57 | } | ||
| 58 | |||
| 59 | 176 | bool TsyplakovKVecNeighboursSEQ::PostProcessingImpl() { | |
| 60 | 176 | return true; | |
| 61 | } | ||
| 62 | |||
| 63 | } // namespace tsyplakov_k_vec_neighbours | ||
| 64 |