| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "barkalova_m_int_met_trapez/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <vector> | ||
| 4 | |||
| 5 | #include "barkalova_m_int_met_trapez/common/include/common.hpp" | ||
| 6 | // #include "util/include/util.hpp" | ||
| 7 | |||
| 8 | namespace barkalova_m_int_met_trapez { | ||
| 9 | |||
| 10 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | BarkalovaMIntMetTrapezSEQ::BarkalovaMIntMetTrapezSEQ(const InType &in) { |
| 11 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 12 | GetInput() = in; | ||
| 13 | 64 | } | |
| 14 | |||
| 15 |
1/2✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
64 | bool BarkalovaMIntMetTrapezSEQ::ValidationImpl() { |
| 16 | auto &data = GetInput(); | ||
| 17 |
2/4✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
|
64 | return data.limits.size() >= 2 && data.n_i.size() >= 2; |
| 18 | } | ||
| 19 | |||
| 20 | 64 | bool BarkalovaMIntMetTrapezSEQ::PreProcessingImpl() { | |
| 21 | 64 | GetOutput() = 0.0; | |
| 22 | 64 | return true; | |
| 23 | } | ||
| 24 | |||
| 25 | 64 | bool BarkalovaMIntMetTrapezSEQ::RunImpl() { | |
| 26 | 64 | auto data = GetInput(); | |
| 27 | |||
| 28 |
2/4✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
|
64 | if (data.n_i.size() < 2 || data.limits.size() < 2) { |
| 29 | ✗ | GetOutput() = 0.0; | |
| 30 | ✗ | return true; | |
| 31 | } | ||
| 32 | |||
| 33 | 64 | double x1 = data.limits[0].first; | |
| 34 | 64 | double x2 = data.limits[0].second; | |
| 35 | 64 | double y1 = data.limits[1].first; | |
| 36 | 64 | double y2 = data.limits[1].second; | |
| 37 | 64 | int n_steps_x = data.n_i[0]; | |
| 38 | 64 | int n_steps_y = data.n_i[1]; | |
| 39 | 64 | double hx = (x2 - x1) / n_steps_x; | |
| 40 | 64 | double hy = (y2 - y1) / n_steps_y; | |
| 41 | |||
| 42 | double sum = 0.0; | ||
| 43 | |||
| 44 |
2/2✓ Branch 0 taken 8552 times.
✓ Branch 1 taken 64 times.
|
8616 | for (int i = 0; i <= n_steps_x; ++i) { |
| 45 | 8552 | double x = x1 + (i * hx); | |
| 46 |
2/2✓ Branch 0 taken 8424 times.
✓ Branch 1 taken 128 times.
|
8552 | double weight_x = (i == 0 || i == n_steps_x) ? 0.5 : 1.0; |
| 47 | |||
| 48 |
2/2✓ Branch 0 taken 2356648 times.
✓ Branch 1 taken 8552 times.
|
2365200 | for (int j = 0; j <= n_steps_y; ++j) { |
| 49 | 2356648 | double y = y1 + (j * hy); | |
| 50 |
2/2✓ Branch 0 taken 2339544 times.
✓ Branch 1 taken 17104 times.
|
2356648 | double weight_y = (j == 0 || j == n_steps_y) ? 0.5 : 1.0; |
| 51 | 2356648 | sum += Integral::Function(x, y) * weight_x * weight_y; | |
| 52 | } | ||
| 53 | } | ||
| 54 | 64 | GetOutput() = sum * hx * hy; | |
| 55 | 64 | return true; | |
| 56 | 64 | } | |
| 57 | |||
| 58 | 64 | bool BarkalovaMIntMetTrapezSEQ::PostProcessingImpl() { | |
| 59 | 64 | return true; | |
| 60 | } | ||
| 61 | |||
| 62 | } // namespace barkalova_m_int_met_trapez | ||
| 63 |