| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "pylaeva_s_max_elem_matrix/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> // для std::max | ||
| 4 | #include <cstddef> // для size_t | ||
| 5 | #include <limits> // для std::numeric_limits | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "pylaeva_s_max_elem_matrix/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace pylaeva_s_max_elem_matrix { | ||
| 11 | |||
| 12 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | PylaevaSMaxElemMatrixSEQ::PylaevaSMaxElemMatrixSEQ(const InType &in) { |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 | GetInput() = in; | ||
| 15 | 80 | GetOutput() = std::numeric_limits<int>::min(); | |
| 16 | 80 | } | |
| 17 | |||
| 18 | 80 | bool PylaevaSMaxElemMatrixSEQ::ValidationImpl() { | |
| 19 | 80 | const auto rows = static_cast<size_t>(std::get<0>(GetInput())); | |
| 20 | 80 | const auto columns = static_cast<size_t>(std::get<1>(GetInput())); | |
| 21 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | size_t matrix_size = rows * columns; |
| 22 | |||
| 23 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | return (matrix_size == std::get<2>(GetInput()).size()) && (rows > 0) && (columns > 0); |
| 24 | } | ||
| 25 | |||
| 26 | 80 | bool PylaevaSMaxElemMatrixSEQ::PreProcessingImpl() { | |
| 27 | 80 | return true; | |
| 28 | } | ||
| 29 | |||
| 30 | 80 | bool PylaevaSMaxElemMatrixSEQ::RunImpl() { | |
| 31 | 80 | const auto &matrix_rows = static_cast<size_t>(std::get<0>(GetInput())); | |
| 32 | 80 | const auto &matrix_columns = static_cast<size_t>(std::get<1>(GetInput())); | |
| 33 | const auto &matrix_data = std::get<2>(GetInput()); | ||
| 34 | |||
| 35 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | size_t matrix_size = matrix_rows * matrix_columns; |
| 36 | |||
| 37 |
3/6✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
|
80 | if (matrix_data.empty() || matrix_size == 0 || matrix_data.size() != matrix_size) { |
| 38 | return false; | ||
| 39 | } | ||
| 40 | |||
| 41 | 80 | int max_element = std::numeric_limits<int>::min(); | |
| 42 | |||
| 43 |
2/2✓ Branch 0 taken 24541240 times.
✓ Branch 1 taken 80 times.
|
24541320 | for (size_t i = 0; i < matrix_size; ++i) { |
| 44 | 24541240 | max_element = std::max(matrix_data[i], max_element); | |
| 45 | } | ||
| 46 | |||
| 47 | 80 | GetOutput() = max_element; | |
| 48 | 80 | return true; | |
| 49 | } | ||
| 50 | |||
| 51 | 80 | bool PylaevaSMaxElemMatrixSEQ::PostProcessingImpl() { | |
| 52 | 80 | return true; | |
| 53 | } | ||
| 54 | |||
| 55 | } // namespace pylaeva_s_max_elem_matrix | ||
| 56 |