| 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 | ✗ | MorozovaSMatrixMaxValueSEQ::MorozovaSMatrixMaxValueSEQ(const InType &in) : BaseTask() { | |
| 11 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 12 | ✗ | GetInput() = InType(in); | |
| 13 | ✗ | GetOutput() = 0; | |
| 14 | ✗ | } | |
| 15 | |||
| 16 | ✗ | 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 | ✗ | bool MorozovaSMatrixMaxValueSEQ::PreProcessingImpl() { | |
| 30 | ✗ | return true; | |
| 31 | } | ||
| 32 | |||
| 33 | ✗ | bool MorozovaSMatrixMaxValueSEQ::RunImpl() { | |
| 34 | const auto &matrix = GetInput(); | ||
| 35 | ✗ | if (matrix.empty() || matrix[0].empty()) { | |
| 36 | ✗ | GetOutput() = 0; | |
| 37 | ✗ | return true; | |
| 38 | } | ||
| 39 | const size_t cols = matrix[0].size(); | ||
| 40 | ✗ | if (!std::ranges::all_of(matrix, [cols](const auto &row) { return row.size() == cols; })) { | |
| 41 | ✗ | GetOutput() = 0; | |
| 42 | ✗ | return true; | |
| 43 | } | ||
| 44 | ✗ | int max_value = matrix[0][0]; | |
| 45 | ✗ | for (const auto &row : matrix) { | |
| 46 | ✗ | for (int value : row) { | |
| 47 | ✗ | max_value = std::max(max_value, value); | |
| 48 | } | ||
| 49 | } | ||
| 50 | ✗ | GetOutput() = max_value; | |
| 51 | ✗ | return true; | |
| 52 | } | ||
| 53 | |||
| 54 | ✗ | bool MorozovaSMatrixMaxValueSEQ::PostProcessingImpl() { | |
| 55 | ✗ | return true; | |
| 56 | } | ||
| 57 | |||
| 58 | } // namespace morozova_s_matrix_max_value | ||
| 59 |