| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "morozova_s_matrix_max_value/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "morozova_s_matrix_max_value/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace morozova_s_matrix_max_value { | ||
| 10 |
1/2✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
|
48 | MorozovaSMatrixMaxValueSEQ::MorozovaSMatrixMaxValueSEQ(const InType &in) : BaseTask() { |
| 11 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 12 |
1/2✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
|
48 | GetInput() = InType(in); |
| 13 | 48 | GetOutput() = 0; | |
| 14 | 48 | } | |
| 15 | |||
| 16 | 48 | bool MorozovaSMatrixMaxValueSEQ::ValidationImpl() { | |
| 17 | const auto &matrix = GetInput(); | ||
| 18 | if (matrix.empty() || matrix[0].empty()) { | ||
| 19 | return true; | ||
| 20 | } | ||
| 21 | const size_t cols = matrix[0].size(); | ||
| 22 | bool all_equal = std::ranges::all_of(matrix, [cols](const auto &row) { return row.size() == cols; }); | ||
| 23 | if (!all_equal) { | ||
| 24 | return true; | ||
| 25 | } | ||
| 26 | return true; | ||
| 27 | } | ||
| 28 | |||
| 29 | 48 | bool MorozovaSMatrixMaxValueSEQ::PreProcessingImpl() { | |
| 30 | 48 | return true; | |
| 31 | } | ||
| 32 | |||
| 33 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 8 times.
|
48 | bool MorozovaSMatrixMaxValueSEQ::RunImpl() { |
| 34 | const auto &matrix = GetInput(); | ||
| 35 |
4/4✓ Branch 0 taken 40 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 32 times.
|
48 | if (matrix.empty() || matrix[0].empty()) { |
| 36 | 16 | GetOutput() = 0; | |
| 37 | 16 | return true; | |
| 38 | } | ||
| 39 | const size_t cols = matrix[0].size(); | ||
| 40 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 24 times.
|
32 | if (!std::ranges::all_of(matrix, [cols](const auto &row) { return row.size() == cols; })) { |
| 41 | 8 | GetOutput() = 0; | |
| 42 | 8 | return true; | |
| 43 | } | ||
| 44 | 24 | int max_value = matrix[0][0]; | |
| 45 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
|
120 | for (const auto &row : matrix) { |
| 46 |
2/2✓ Branch 0 taken 400 times.
✓ Branch 1 taken 96 times.
|
496 | for (int value : row) { |
| 47 | 400 | max_value = std::max(max_value, value); | |
| 48 | } | ||
| 49 | } | ||
| 50 | 24 | GetOutput() = max_value; | |
| 51 | 24 | return true; | |
| 52 | } | ||
| 53 | |||
| 54 | 48 | bool MorozovaSMatrixMaxValueSEQ::PostProcessingImpl() { | |
| 55 | 48 | return true; | |
| 56 | } | ||
| 57 | |||
| 58 | } // namespace morozova_s_matrix_max_value | ||
| 59 |