| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "chernykh_s_yadro_gaussa_horizontal/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <array> | ||
| 5 | #include <cstddef> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "chernykh_s_yadro_gaussa_horizontal/common/include/common.hpp" | ||
| 9 | namespace chernykh_s_yadro_gaussa_horizontal { | ||
| 10 | |||
| 11 | 189505800 | int ChernykhSYadroGaussaHorizontalSEQ::GetGaussianWeight(int ki, int kj) { | |
| 12 | static const std::array<std::array<int, 3>, 3> kKernel = {{{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}}; | ||
| 13 |
2/4✓ Branch 0 taken 189505800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189505800 times.
✗ Branch 3 not taken.
|
189505800 | return kKernel.at(static_cast<size_t>(ki) + 1).at(static_cast<size_t>(kj) + 1); |
| 14 | } | ||
| 15 | |||
| 16 |
1/2✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
|
85 | ChernykhSYadroGaussaHorizontalSEQ::ChernykhSYadroGaussaHorizontalSEQ(const InType &in) { |
| 17 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 18 | 85 | GetInput() = InType(in); | |
| 19 | 85 | } | |
| 20 | |||
| 21 | 85 | bool ChernykhSYadroGaussaHorizontalSEQ::ValidationImpl() { | |
| 22 | 85 | int stolbci = std::get<0>(GetInput()); | |
| 23 | 85 | int stroki = std::get<1>(GetInput()); | |
| 24 | auto &data = std::get<2>(GetInput()); | ||
| 25 |
2/4✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
|
85 | return stolbci > 0 && stroki > 0 && data.size() == static_cast<size_t>(stolbci) * static_cast<size_t>(stroki); |
| 26 | } | ||
| 27 | |||
| 28 | 85 | bool ChernykhSYadroGaussaHorizontalSEQ::PreProcessingImpl() { | |
| 29 | 85 | return true; | |
| 30 | } | ||
| 31 | |||
| 32 | 85 | bool ChernykhSYadroGaussaHorizontalSEQ::RunImpl() { | |
| 33 | 85 | int stolbci = std::get<0>(GetInput()); | |
| 34 | 85 | int stroki = std::get<1>(GetInput()); | |
| 35 | std::vector<int> &input_data = std::get<2>(GetInput()); | ||
| 36 | std::vector<int> &output_data = GetOutput(); | ||
| 37 | |||
| 38 | 85 | output_data.resize(static_cast<size_t>(stolbci) * static_cast<size_t>(stroki)); | |
| 39 | |||
| 40 |
2/2✓ Branch 0 taken 32538 times.
✓ Branch 1 taken 85 times.
|
32623 | for (int i = 0; i < stroki; ++i) { |
| 41 |
2/2✓ Branch 0 taken 21056200 times.
✓ Branch 1 taken 32538 times.
|
21088738 | for (int j = 0; j < stolbci; ++j) { |
| 42 | int sum = 0; | ||
| 43 |
2/2✓ Branch 0 taken 63168600 times.
✓ Branch 1 taken 21056200 times.
|
84224800 | for (int ki = -1; ki <= 1; ++ki) { |
| 44 |
2/2✓ Branch 0 taken 189505800 times.
✓ Branch 1 taken 63168600 times.
|
252674400 | for (int kj = -1; kj <= 1; ++kj) { |
| 45 | 189505800 | int row = std::clamp(i + ki, 0, stroki - 1); | |
| 46 | 189505800 | int column = std::clamp(j + kj, 0, stolbci - 1); | |
| 47 | 189505800 | size_t idx = (static_cast<size_t>(row) * static_cast<size_t>(stolbci)) + static_cast<size_t>(column); | |
| 48 | 189505800 | sum += input_data[idx] * GetGaussianWeight(ki, kj); | |
| 49 | } | ||
| 50 | } | ||
| 51 | 21056200 | size_t out_idx = (static_cast<size_t>(i) * static_cast<size_t>(stolbci)) + static_cast<size_t>(j); | |
| 52 | 21056200 | output_data[out_idx] = sum / 16; | |
| 53 | } | ||
| 54 | } | ||
| 55 | 85 | return true; | |
| 56 | } | ||
| 57 | |||
| 58 | 85 | bool ChernykhSYadroGaussaHorizontalSEQ::PostProcessingImpl() { | |
| 59 | 85 | return true; | |
| 60 | } | ||
| 61 | |||
| 62 | } // namespace chernykh_s_yadro_gaussa_horizontal | ||
| 63 |