| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "tsibareva_e_matrix_column_max/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "tsibareva_e_matrix_column_max/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace tsibareva_e_matrix_column_max { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
|
162 | TsibarevaEMatrixColumnMaxSEQ::TsibarevaEMatrixColumnMaxSEQ(const InType &in) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 |
1/2✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
|
162 | GetInput() = std::vector<std::vector<int>>(in); |
| 14 | 162 | GetOutput() = std::vector<int>(); | |
| 15 | 162 | } | |
| 16 | |||
| 17 | 162 | bool TsibarevaEMatrixColumnMaxSEQ::ValidationImpl() { | |
| 18 | 162 | return true; | |
| 19 | } | ||
| 20 | |||
| 21 |
2/2✓ Branch 0 taken 154 times.
✓ Branch 1 taken 8 times.
|
162 | bool TsibarevaEMatrixColumnMaxSEQ::PreProcessingImpl() { |
| 22 | const auto &matrix = GetInput(); | ||
| 23 |
4/4✓ Branch 0 taken 154 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 146 times.
|
162 | if (matrix.empty() || matrix[0].empty()) { |
| 24 | 16 | GetOutput() = std::vector<int>(); | |
| 25 | 16 | return true; | |
| 26 | } | ||
| 27 | |||
| 28 | size_t first_row_size = matrix[0].size(); | ||
| 29 |
2/2✓ Branch 0 taken 656 times.
✓ Branch 1 taken 138 times.
|
794 | for (size_t i = 1; i < matrix.size(); ++i) { |
| 30 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 648 times.
|
656 | if (matrix[i].size() != first_row_size) { |
| 31 | 8 | GetOutput() = std::vector<int>(); | |
| 32 | 8 | return true; | |
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | 138 | GetOutput() = std::vector<int>(GetInput()[0].size(), 0); | |
| 37 | 138 | return true; | |
| 38 | } | ||
| 39 | |||
| 40 |
2/2✓ Branch 0 taken 138 times.
✓ Branch 1 taken 24 times.
|
162 | bool TsibarevaEMatrixColumnMaxSEQ::RunImpl() { |
| 41 |
2/2✓ Branch 0 taken 138 times.
✓ Branch 1 taken 24 times.
|
162 | if (GetOutput().empty()) { |
| 42 | return true; | ||
| 43 | } | ||
| 44 | |||
| 45 | const auto &matrix = GetInput(); | ||
| 46 | auto &column_maxs = GetOutput(); | ||
| 47 | size_t cols_count = matrix[0].size(); | ||
| 48 | |||
| 49 |
2/2✓ Branch 0 taken 786 times.
✓ Branch 1 taken 138 times.
|
924 | for (size_t col = 0; col < cols_count; ++col) { |
| 50 | 786 | int max_value = matrix[0][col]; | |
| 51 |
2/2✓ Branch 0 taken 4056 times.
✓ Branch 1 taken 786 times.
|
4842 | for (size_t row = 1; row < matrix.size(); ++row) { |
| 52 | 4056 | max_value = std::max(matrix[row][col], max_value); | |
| 53 | } | ||
| 54 | 786 | column_maxs[col] = max_value; | |
| 55 | } | ||
| 56 | |||
| 57 | return true; | ||
| 58 | } | ||
| 59 | |||
| 60 | 162 | bool TsibarevaEMatrixColumnMaxSEQ::PostProcessingImpl() { | |
| 61 | 162 | return true; | |
| 62 | } | ||
| 63 | |||
| 64 | } // namespace tsibareva_e_matrix_column_max | ||
| 65 |