| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "lifanov_k_trapezoid_method/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include "lifanov_k_trapezoid_method/common/include/common.hpp" | ||
| 4 | |||
| 5 | namespace { | ||
| 6 | double Function(double x, double y) { | ||
| 7 | 105944 | return (x * x) + (y * y); | |
| 8 | } | ||
| 9 | } // namespace | ||
| 10 | |||
| 11 | namespace lifanov_k_trapezoid_method { | ||
| 12 | |||
| 13 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | LifanovKTrapezoidMethodSEQ::LifanovKTrapezoidMethodSEQ(const InType &in) { |
| 14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 15 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | GetInput() = in; |
| 16 | 24 | GetOutput() = 0.0; | |
| 17 | 24 | } | |
| 18 | |||
| 19 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | bool LifanovKTrapezoidMethodSEQ::ValidationImpl() { |
| 20 | const auto &in = GetInput(); | ||
| 21 | |||
| 22 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (in.size() != 6) { |
| 23 | return false; | ||
| 24 | } | ||
| 25 | |||
| 26 | 24 | const double ax = in[0]; | |
| 27 | 24 | const double bx = in[1]; | |
| 28 | 24 | const double ay = in[2]; | |
| 29 | 24 | const double by = in[3]; | |
| 30 | 24 | const int nx = static_cast<int>(in[4]); | |
| 31 | 24 | const int ny = static_cast<int>(in[5]); | |
| 32 | |||
| 33 |
2/4✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
24 | return (bx > ax) && (by > ay) && (nx > 0) && (ny > 0); |
| 34 | } | ||
| 35 | |||
| 36 | 24 | bool LifanovKTrapezoidMethodSEQ::PreProcessingImpl() { | |
| 37 | 24 | GetOutput() = 0.0; | |
| 38 | 24 | return true; | |
| 39 | } | ||
| 40 | |||
| 41 | 24 | bool LifanovKTrapezoidMethodSEQ::RunImpl() { | |
| 42 | const auto &in = GetInput(); | ||
| 43 | |||
| 44 | 24 | const double ax = in[0]; | |
| 45 | 24 | const double bx = in[1]; | |
| 46 | 24 | const double ay = in[2]; | |
| 47 | 24 | const double by = in[3]; | |
| 48 | 24 | const int nx = static_cast<int>(in[4]); | |
| 49 | 24 | const int ny = static_cast<int>(in[5]); | |
| 50 | |||
| 51 | 24 | const double hx = (bx - ax) / nx; | |
| 52 | 24 | const double hy = (by - ay) / ny; | |
| 53 | |||
| 54 | double integral = 0.0; | ||
| 55 | |||
| 56 |
2/2✓ Branch 0 taken 1384 times.
✓ Branch 1 taken 24 times.
|
1408 | for (int i = 0; i <= nx; ++i) { |
| 57 | 1384 | const double x = ax + (i * hx); | |
| 58 |
2/2✓ Branch 0 taken 1336 times.
✓ Branch 1 taken 48 times.
|
1384 | const double wx = (i == 0 || i == nx) ? 0.5 : 1.0; |
| 59 | |||
| 60 |
2/2✓ Branch 0 taken 105944 times.
✓ Branch 1 taken 1384 times.
|
107328 | for (int j = 0; j <= ny; ++j) { |
| 61 | 105944 | const double y = ay + (j * hy); | |
| 62 |
2/2✓ Branch 0 taken 103176 times.
✓ Branch 1 taken 2768 times.
|
105944 | const double wy = (j == 0 || j == ny) ? 0.5 : 1.0; |
| 63 | |||
| 64 | 105944 | integral += wx * wy * Function(x, y); | |
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | 24 | GetOutput() = integral * hx * hy; | |
| 69 | 24 | return true; | |
| 70 | } | ||
| 71 | |||
| 72 | 24 | bool LifanovKTrapezoidMethodSEQ::PostProcessingImpl() { | |
| 73 | 24 | return true; | |
| 74 | } | ||
| 75 | |||
| 76 | } // namespace lifanov_k_trapezoid_method | ||
| 77 |