GCC Code Coverage Report


Directory: ./
File: tasks/kutergin_v_multidimensional_integration_rect_method/seq/src/rect_method_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 5 5 100.0%
Branches: 20 32 62.5%

Line Branch Exec Source
1 #include "../include/rect_method_seq.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5 #include <cstddef>
6 #include <vector>
7
8 #include "../../common/include/common.hpp"
9
10 namespace kutergin_v_multidimensional_integration_rect_method {
11
12
1/2
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
40 RectMethodSequential::RectMethodSequential(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14
1/2
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
40 GetInput() = in;
15 40 GetOutput() = 0.0;
16 40 }
17
18
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 bool RectMethodSequential::ValidationImpl() {
19 const auto &input = GetInput();
20
2/4
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
40 if (input.limits.size() != input.n_steps.size() || input.limits.empty()) {
21 return false;
22 }
23 return std::ranges::all_of(input.n_steps, [](int n) { return n > 0; });
24 }
25
26 40 bool RectMethodSequential::PreProcessingImpl() {
27 40 local_input_ = GetInput();
28 40 res_ = 0.0;
29 40 return true;
30 }
31
32 40 bool RectMethodSequential::RunImpl() {
33 size_t dims = local_input_.limits.size(); // число размерностей пространства
34 40 std::vector<double> coords(dims); // создание вектора координат размером dims
35
36 size_t total_iterations = 1;
37
1/4
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
40 std::vector<double> h(dims);
38
39 double d_v = 1.0;
40
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 40 times.
160 for (size_t i = 0; i < dims; i++) {
41 120 total_iterations *= local_input_.n_steps[i];
42 120 h[i] = (local_input_.limits[i].second - local_input_.limits[i].first) / local_input_.n_steps[i];
43 120 d_v *= h[i];
44 }
45
46 double total_sum = 0.0;
47
1/4
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
40 std::vector<int> current_indices(dims, 0);
48
49
2/2
✓ Branch 0 taken 91744 times.
✓ Branch 1 taken 40 times.
91784 for (size_t i = 0; i < total_iterations; ++i) {
50
2/2
✓ Branch 0 taken 262520 times.
✓ Branch 1 taken 91744 times.
354264 for (size_t dm = 0; dm < dims; ++dm) {
51 262520 coords[dm] = local_input_.limits[dm].first + ((current_indices[dm] + 0.5) * h[dm]);
52 }
53 91744 total_sum += local_input_.func(coords);
54
2/2
✓ Branch 0 taken 97704 times.
✓ Branch 1 taken 40 times.
97744 for (int dm = static_cast<int>(dims) - 1; dm >= 0; --dm) {
55
2/2
✓ Branch 0 taken 6000 times.
✓ Branch 1 taken 91704 times.
97704 current_indices[dm]++;
56
2/2
✓ Branch 0 taken 6000 times.
✓ Branch 1 taken 91704 times.
97704 if (current_indices[dm] < local_input_.n_steps[dm]) {
57 break;
58 }
59 6000 current_indices[dm] = 0;
60 }
61 }
62
63
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 res_ = total_sum * d_v;
64 40 return true;
65 }
66
67 40 bool RectMethodSequential::PostProcessingImpl() {
68 40 GetOutput() = res_;
69 40 return true;
70 }
71
72 } // namespace kutergin_v_multidimensional_integration_rect_method
73