| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "kutuzov_i_simpson_integration/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <tuple> | ||
| 4 | |||
| 5 | #include "kutuzov_i_simpson_integration/common/include/common.hpp" | ||
| 6 | |||
| 7 | namespace kutuzov_i_simpson_integration { | ||
| 8 | |||
| 9 | 128 | KutuzovISimpsonIntegrationSEQ::KutuzovISimpsonIntegrationSEQ(const InType &in) { | |
| 10 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 11 | GetInput() = in; | ||
| 12 | GetOutput() = {}; | ||
| 13 | 128 | } | |
| 14 | |||
| 15 | 128 | bool KutuzovISimpsonIntegrationSEQ::ValidationImpl() { | |
| 16 | 128 | int n = std::get<0>(GetInput()); | |
| 17 | 128 | double x_min = std::get<1>(GetInput()).first; | |
| 18 | 128 | double x_max = std::get<1>(GetInput()).second; | |
| 19 | 128 | double y_min = std::get<2>(GetInput()).first; | |
| 20 | 128 | double y_max = std::get<2>(GetInput()).second; | |
| 21 | 128 | int function_id = std::get<3>(GetInput()); | |
| 22 | |||
| 23 |
1/2✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
|
128 | if (x_min >= x_max) { |
| 24 | return false; | ||
| 25 | } | ||
| 26 |
1/2✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
|
128 | if (y_min >= y_max) { |
| 27 | return false; | ||
| 28 | } | ||
| 29 |
2/4✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
|
128 | if (n <= 0 || n % 2 != 0) { |
| 30 | return false; | ||
| 31 | } | ||
| 32 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
|
128 | if (function_id <= 0 || function_id > 4) { |
| 33 | ✗ | return false; | |
| 34 | } | ||
| 35 | return true; | ||
| 36 | } | ||
| 37 | |||
| 38 | 128 | bool KutuzovISimpsonIntegrationSEQ::PreProcessingImpl() { | |
| 39 | 128 | GetOutput() = 0.0; | |
| 40 | 128 | return true; | |
| 41 | } | ||
| 42 | |||
| 43 | 128 | bool KutuzovISimpsonIntegrationSEQ::RunImpl() { | |
| 44 | 128 | int n = std::get<0>(GetInput()); | |
| 45 | 128 | double x_min = std::get<0>(std::get<1>(GetInput())); | |
| 46 | 128 | double x_max = std::get<1>(std::get<1>(GetInput())); | |
| 47 | 128 | double y_min = std::get<0>(std::get<2>(GetInput())); | |
| 48 | 128 | double y_max = std::get<1>(std::get<2>(GetInput())); | |
| 49 | 128 | int function_id = std::get<3>(GetInput()); | |
| 50 | |||
| 51 | 128 | double step_x = (x_max - x_min) / n; | |
| 52 | 128 | double step_y = (y_max - y_min) / n; | |
| 53 | |||
| 54 | double sum = 0; | ||
| 55 |
2/2✓ Branch 0 taken 1088 times.
✓ Branch 1 taken 128 times.
|
1216 | for (int i = 0; i <= n; i++) { |
| 56 | 1088 | double x = x_min + (step_x * i); | |
| 57 | |||
| 58 |
2/2✓ Branch 0 taken 16000 times.
✓ Branch 1 taken 1088 times.
|
17088 | for (int j = 0; j <= n; j++) { |
| 59 | 16000 | double y = y_min + (step_y * j); | |
| 60 | 16000 | sum += GetWeight(i, n) * GetWeight(j, n) * CallFunction(function_id, x, y); | |
| 61 | } | ||
| 62 | } | ||
| 63 | 128 | sum *= step_x * step_y / 9; | |
| 64 | 128 | GetOutput() = sum; | |
| 65 | 128 | return true; | |
| 66 | } | ||
| 67 | |||
| 68 | 128 | bool KutuzovISimpsonIntegrationSEQ::PostProcessingImpl() { | |
| 69 | 128 | return true; | |
| 70 | } | ||
| 71 | |||
| 72 | ✗ | double KutuzovISimpsonIntegrationSEQ::GetWeight(int i, int n) { | |
| 73 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 13824 times.
✓ Branch 3 taken 2176 times.
✓ Branch 4 taken 13824 times.
✓ Branch 5 taken 2176 times.
|
29824 | if (i == 0 || i == n) { |
| 74 | return 1.0; | ||
| 75 | } | ||
| 76 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7456 times.
✓ Branch 3 taken 6368 times.
✓ Branch 4 taken 7456 times.
✓ Branch 5 taken 6368 times.
|
27648 | if (i % 2 == 1) { |
| 77 | 14912 | return 4.0; | |
| 78 | } | ||
| 79 | return 2.0; | ||
| 80 | } | ||
| 81 | |||
| 82 | } // namespace kutuzov_i_simpson_integration | ||
| 83 |