| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "kamaletdinov_r_max_matrix_rows_elem/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "kamaletdinov_r_max_matrix_rows_elem/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace kamaletdinov_r_max_matrix_rows_elem { | ||
| 10 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | KamaletdinovRMaxMatrixRowsElemSEQ::KamaletdinovRMaxMatrixRowsElemSEQ(const InType &in) { |
| 11 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 12 | GetInput() = in; | ||
| 13 | 40 | GetOutput() = std::vector<int>(); | |
| 14 | 40 | } | |
| 15 | |||
| 16 | 40 | bool KamaletdinovRMaxMatrixRowsElemSEQ::ValidationImpl() { | |
| 17 | 40 | std::size_t m = std::get<0>(GetInput()); | |
| 18 | 40 | std::size_t n = std::get<1>(GetInput()); | |
| 19 | std::vector<int> &val = std::get<2>(GetInput()); | ||
| 20 |
2/4✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
|
40 | valid_ = (n > 0) && (m > 0) && (val.size() == (n * m)); |
| 21 | 40 | return valid_; | |
| 22 | } | ||
| 23 | |||
| 24 | 40 | bool KamaletdinovRMaxMatrixRowsElemSEQ::PreProcessingImpl() { | |
| 25 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | if (valid_) { |
| 26 | 40 | std::size_t m = std::get<0>(GetInput()); | |
| 27 | 40 | std::size_t n = std::get<1>(GetInput()); | |
| 28 | std::vector<int> &val = std::get<2>(GetInput()); | ||
| 29 | 40 | t_matrix_ = std::vector<int>(n * m); | |
| 30 |
2/2✓ Branch 0 taken 8752 times.
✓ Branch 1 taken 40 times.
|
8792 | for (std::size_t i = 0; i < m; i++) { |
| 31 |
2/2✓ Branch 0 taken 8055120 times.
✓ Branch 1 taken 8752 times.
|
8063872 | for (std::size_t j = 0; j < n; j++) { |
| 32 | 8055120 | t_matrix_[(j * m) + i] = val[(i * n) + j]; | |
| 33 | } | ||
| 34 | } | ||
| 35 | return true; | ||
| 36 | } | ||
| 37 | return false; | ||
| 38 | } | ||
| 39 | |||
| 40 | 40 | bool KamaletdinovRMaxMatrixRowsElemSEQ::RunImpl() { | |
| 41 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | if (!valid_) { |
| 42 | return false; | ||
| 43 | } | ||
| 44 | 40 | std::size_t m = std::get<0>(GetInput()); | |
| 45 | 40 | std::size_t n = std::get<1>(GetInput()); | |
| 46 | |||
| 47 | // debug | ||
| 48 | // std::string deb = "\n\n----\n"; | ||
| 49 | // for(std::size_t i = 0; i < n; i++) { | ||
| 50 | // for(std::size_t j = 0; j < m; j++) { | ||
| 51 | // deb += std::to_string(t_matrix_[i*m + j]) + " "; | ||
| 52 | // } | ||
| 53 | // deb += "\n"; | ||
| 54 | // } | ||
| 55 | // std::cout << deb; | ||
| 56 | |||
| 57 | 40 | std::vector<int> max_rows_elem(n); | |
| 58 |
2/2✓ Branch 0 taken 8848 times.
✓ Branch 1 taken 40 times.
|
8888 | for (std::size_t i = 0; i < n; i++) { |
| 59 | 8848 | max_rows_elem[i] = t_matrix_[(i * m)]; | |
| 60 |
2/2✓ Branch 0 taken 8046272 times.
✓ Branch 1 taken 8848 times.
|
8055120 | for (std::size_t j = 1; j < m; j++) { |
| 61 |
2/2✓ Branch 0 taken 26688 times.
✓ Branch 1 taken 8019584 times.
|
8072960 | max_rows_elem[i] = std::max(max_rows_elem[i], t_matrix_[(i * m) + j]); |
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | // debug output | ||
| 66 | // std::cout << "seq" << ":"; | ||
| 67 | // for(std::size_t i = 0; i < n; i++) { | ||
| 68 | // std::cout << max_rows_elem[i] << " "; | ||
| 69 | // } | ||
| 70 | // std::cout << std::endl; | ||
| 71 | |||
| 72 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | GetOutput() = max_rows_elem; |
| 73 | return true; | ||
| 74 | } | ||
| 75 | |||
| 76 | 40 | bool KamaletdinovRMaxMatrixRowsElemSEQ::PostProcessingImpl() { | |
| 77 | 40 | return true; | |
| 78 | } | ||
| 79 | |||
| 80 | } // namespace kamaletdinov_r_max_matrix_rows_elem | ||
| 81 |