| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "ovsyannikov_n_simpson_method/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include "ovsyannikov_n_simpson_method/common/include/common.hpp" | ||
| 4 | |||
| 5 | namespace ovsyannikov_n_simpson_method { | ||
| 6 | |||
| 7 | // Тестовая функция: f(x, y) = x + y | ||
| 8 | ✗ | double OvsyannikovNSimpsonMethodSEQ::Function(double x, double y) { | |
| 9 | 68448 | return x + y; | |
| 10 | } | ||
| 11 | |||
| 12 | 48 | OvsyannikovNSimpsonMethodSEQ::OvsyannikovNSimpsonMethodSEQ(const InType &in) { | |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 | 48 | GetInput() = in; | |
| 15 | 48 | } | |
| 16 | |||
| 17 | 48 | bool OvsyannikovNSimpsonMethodSEQ::ValidationImpl() { | |
| 18 |
4/8✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 48 times.
|
48 | return GetInput().nx > 0 && GetInput().nx % 2 == 0 && GetInput().ny > 0 && GetInput().ny % 2 == 0; |
| 19 | } | ||
| 20 | |||
| 21 | 48 | bool OvsyannikovNSimpsonMethodSEQ::PreProcessingImpl() { | |
| 22 | 48 | params_ = GetInput(); | |
| 23 | 48 | res_ = 0; | |
| 24 | 48 | return true; | |
| 25 | } | ||
| 26 | |||
| 27 | 48 | bool OvsyannikovNSimpsonMethodSEQ::RunImpl() { | |
| 28 | 48 | double hx = (params_.bx - params_.ax) / params_.nx; | |
| 29 | 48 | double hy = (params_.by - params_.ay) / params_.ny; | |
| 30 | double total_sum = 0.0; | ||
| 31 | |||
| 32 |
2/2✓ Branch 0 taken 1648 times.
✓ Branch 1 taken 48 times.
|
1696 | for (int i = 0; i <= params_.nx; ++i) { |
| 33 | 1648 | double x = params_.ax + (i * hx); | |
| 34 | double coeff_x = 2.0; | ||
| 35 |
4/4✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 1552 times.
✓ Branch 3 taken 48 times.
|
1648 | if (i == 0 || i == params_.nx) { |
| 36 | coeff_x = 1.0; | ||
| 37 |
2/2✓ Branch 0 taken 800 times.
✓ Branch 1 taken 752 times.
|
1552 | } else if (i % 2 == 1) { |
| 38 | coeff_x = 4.0; | ||
| 39 | } | ||
| 40 | |||
| 41 |
2/2✓ Branch 0 taken 68448 times.
✓ Branch 1 taken 1648 times.
|
70096 | for (int j = 0; j <= params_.ny; ++j) { |
| 42 | 68448 | double y = params_.ay + (j * hy); | |
| 43 | double coeff_y = 2.0; | ||
| 44 |
4/4✓ Branch 0 taken 66800 times.
✓ Branch 1 taken 1648 times.
✓ Branch 2 taken 65152 times.
✓ Branch 3 taken 1648 times.
|
68448 | if (j == 0 || j == params_.ny) { |
| 45 | coeff_y = 1.0; | ||
| 46 |
2/2✓ Branch 0 taken 33400 times.
✓ Branch 1 taken 31752 times.
|
65152 | } else if (j % 2 == 1) { |
| 47 | coeff_y = 4.0; | ||
| 48 | } | ||
| 49 | |||
| 50 | 68448 | total_sum += coeff_x * coeff_y * Function(x, y); | |
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | 48 | res_ = (hx * hy / 9.0) * total_sum; | |
| 55 | 48 | return true; | |
| 56 | } | ||
| 57 | |||
| 58 | 48 | bool OvsyannikovNSimpsonMethodSEQ::PostProcessingImpl() { | |
| 59 | 48 | GetOutput() = res_; | |
| 60 | 48 | return true; | |
| 61 | } | ||
| 62 | |||
| 63 | } // namespace ovsyannikov_n_simpson_method | ||
| 64 |