| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gasenin_l_mult_int_mstep_trapez/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cmath> | ||
| 4 | |||
| 5 | #include "gasenin_l_mult_int_mstep_trapez/common/include/common.hpp" | ||
| 6 | |||
| 7 | namespace gasenin_l_mult_int_mstep_trapez { | ||
| 8 | |||
| 9 | 136 | GaseninLMultIntMstepTrapezSEQ::GaseninLMultIntMstepTrapezSEQ(const InType &in) { | |
| 10 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 11 | 136 | GetInput() = in; | |
| 12 | 136 | } | |
| 13 | |||
| 14 | 136 | bool GaseninLMultIntMstepTrapezSEQ::ValidationImpl() { | |
| 15 |
3/6✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 136 times.
|
136 | return GetInput().n_steps > 0 && GetInput().x2 > GetInput().x1 && GetInput().y2 > GetInput().y1; |
| 16 | } | ||
| 17 | |||
| 18 | 136 | bool GaseninLMultIntMstepTrapezSEQ::PreProcessingImpl() { | |
| 19 | 136 | GetOutput() = 0.0; | |
| 20 | 136 | return true; | |
| 21 | } | ||
| 22 | |||
| 23 | 136 | bool GaseninLMultIntMstepTrapezSEQ::RunImpl() { | |
| 24 | 136 | auto data = GetInput(); | |
| 25 | 136 | auto f = GetFunction(data.func_id); | |
| 26 | 136 | double hx = (data.x2 - data.x1) / data.n_steps; | |
| 27 | 136 | double hy = (data.y2 - data.y1) / data.n_steps; | |
| 28 | |||
| 29 | double sum = 0.0; | ||
| 30 | |||
| 31 |
2/2✓ Branch 0 taken 12824 times.
✓ Branch 1 taken 136 times.
|
12960 | for (int i = 1; i < data.n_steps; i++) { |
| 32 | 12824 | double x = data.x1 + (i * hx); | |
| 33 |
2/2✓ Branch 0 taken 1755192 times.
✓ Branch 1 taken 12824 times.
|
1768016 | for (int j = 1; j < data.n_steps; j++) { |
| 34 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1755192 times.
|
1755192 | double y = data.y1 + (j * hy); |
| 35 | 1755192 | sum += f(x, y); | |
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 |
2/2✓ Branch 0 taken 12824 times.
✓ Branch 1 taken 136 times.
|
12960 | for (int i = 1; i < data.n_steps; i++) { |
| 40 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12824 times.
|
12824 | double x = data.x1 + (i * hx); |
| 41 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12824 times.
|
12824 | sum += 0.5 * f(x, data.y1); |
| 42 | 12824 | sum += 0.5 * f(x, data.y2); | |
| 43 | } | ||
| 44 | |||
| 45 |
2/2✓ Branch 0 taken 12824 times.
✓ Branch 1 taken 136 times.
|
12960 | for (int j = 1; j < data.n_steps; j++) { |
| 46 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12824 times.
|
12824 | double y = data.y1 + (j * hy); |
| 47 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12824 times.
|
12824 | sum += 0.5 * f(data.x1, y); |
| 48 | 12824 | sum += 0.5 * f(data.x2, y); | |
| 49 | } | ||
| 50 | |||
| 51 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
|
136 | sum += 0.25 * f(data.x1, data.y1); |
| 52 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
|
136 | sum += 0.25 * f(data.x2, data.y1); |
| 53 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
|
136 | sum += 0.25 * f(data.x1, data.y2); |
| 54 | 136 | sum += 0.25 * f(data.x2, data.y2); | |
| 55 | |||
| 56 |
1/2✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
|
136 | GetOutput() = sum * hx * hy; |
| 57 | |||
| 58 | 136 | return true; | |
| 59 | } | ||
| 60 | |||
| 61 | 136 | bool GaseninLMultIntMstepTrapezSEQ::PostProcessingImpl() { | |
| 62 | 136 | return true; | |
| 63 | } | ||
| 64 | |||
| 65 | } // namespace gasenin_l_mult_int_mstep_trapez | ||
| 66 |